91d96e840ba92bba47f9f23dcd4e094e9c42c68b
[indico-PayWay] / MaKaC / plugins / EPayment / payWay / webinterface / pages / ePayments.py
1 # -*- coding: utf-8 -*-
2 ##
3 ##
4 ## This file is part of Indico.
5 ## Copyright (C) 2002 - 2014 European Organization for Nuclear Research (CERN).
6 ##
7 ## Indico is free software; you can redistribute it and/or
8 ## modify it under the terms of the GNU General Public License as
9 ## published by the Free Software Foundation; either version 3 of the
10 ## License, or (at your option) any later version.
11 ##
12 ## Indico is distributed in the hope that it will be useful, but
13 ## WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 ## General Public License for more details.
16 ##
17 ## You should have received a copy of the GNU General Public License
18 ## along with Indico;if not, see <http://www.gnu.org/licenses/>.
19
20 import MaKaC.webinterface.pages.conferences as conferences
21 import MaKaC.webinterface.pages.registrationForm as registrationForm
22 from MaKaC.webinterface import wcomponents
23 from xml.sax.saxutils import quoteattr
24 from indico.core import config as Configuration
25 from MaKaC.webinterface import urlHandlers
26 import MaKaC
27 from MaKaC.i18n import _
28
29
30 from MaKaC.plugins.EPayment.payPal import MODULE_ID
31 from MaKaC.plugins.EPayment.payPal.webinterface.wcomponents import WTemplated
32 from MaKaC.plugins.EPayment.payPal.webinterface import urlHandlers as localUrlHandlers
33
34
35
36 class WPConfModifEPaymentPayPalBase(registrationForm.WPConfModifRegFormBase):
37
38     def _createTabCtrl( self ):
39         self._tabCtrl = wcomponents.TabControl()
40         self._tabMain = self._tabCtrl.newTab( "main", _("Main"), \
41                 localUrlHandlers.UHConfModifEPaymentPayPal.getURL( self._conf ) )
42         wf = self._rh.getWebFactory()
43         if wf:
44             wf.customiseTabCtrl( self._tabCtrl )
45         self._setActiveTab()
46
47     def _setActiveTab( self ):
48         pass
49
50     def _setActiveSideMenuItem(self):
51         self._regFormMenuItem.setActive(True)
52
53     def _getPageContent( self, params ):
54         self._createTabCtrl()
55         banner = wcomponents.WEpaymentBannerModif(self._conf.getModPay().getPayModByTag(MODULE_ID), self._conf).getHTML()
56         html = wcomponents.WTabControl( self._tabCtrl, self._getAW() ).getHTML( self._getTabContent( params ) )
57         return banner+html
58
59     def _getTabContent( self, params ):
60         return "nothing"
61
62 class WPConfModifEPaymentPayPal( WPConfModifEPaymentPayPalBase ):
63
64     def _getTabContent( self, params ):
65         wc = WConfModifEPaymentPayPal(self._conf)
66         p = {
67              'dataModificationURL': quoteattr(str(localUrlHandlers.UHConfModifEPaymentPayPalDataModif.getURL( self._conf )))
68             }
69         return wc.getHTML(p)
70
71 class WConfModifEPaymentPayPal( WTemplated ):
72
73     def __init__( self, conference ):
74         self._conf = conference
75
76     def getVars( self ):
77         vars = WTemplated.getVars(self)
78         modPayPal = self._conf.getModPay().getPayModByTag(MODULE_ID)
79         vars["title"] = modPayPal.getTitle()
80         vars["url"] = modPayPal.getUrl()
81         vars["business"] =  modPayPal.getBusiness()
82         return vars
83
84 class WPConfModifEPaymentPayPalDataModif( WPConfModifEPaymentPayPalBase ):
85
86     def _getTabContent( self, params ):
87         wc = WConfModifEPaymentPayPalDataModif(self._conf)
88         p = {'postURL': quoteattr(str(localUrlHandlers.UHConfModifEPaymentPayPalPerformDataModif.getURL( self._conf )))
89             }
90         return wc.getHTML(p)
91
92 class WConfModifEPaymentPayPalDataModif( WTemplated ):
93
94     def __init__( self, conference ):
95         self._conf = conference
96
97     def getVars( self ):
98         vars = WTemplated.getVars(self)
99         modPayPal = self._conf.getModPay().getPayModByTag(MODULE_ID)
100         vars["title"] = modPayPal.getTitle()
101         vars["url"] = modPayPal.getUrl()
102         vars["business"] =  modPayPal.getBusiness()
103         return vars
104
105 class WPconfirmEPaymentPayPal( conferences.WPConferenceDefaultDisplayBase ):
106     #navigationEntry = navigation.NERegistrationFormDisplay
107
108     def __init__(self, rh, conf, reg):
109         conferences.WPConferenceDefaultDisplayBase.__init__(self, rh, conf)
110         self._registrant=reg
111
112
113     def _getBody( self, params ):
114         wc = WconfirmEPaymentPayPal(self._conf, self._registrant)
115         return wc.getHTML()
116
117     def _defineSectionMenu( self ):
118         conferences.WPConferenceDefaultDisplayBase._defineSectionMenu(self)
119         self._sectionMenu.setCurrentItem(self._regFormOpt)
120
121
122 class WconfirmEPaymentPayPal( WTemplated ):
123     def __init__( self,configuration, registrant):
124         self._registrant = registrant
125         self._conf = configuration
126
127     def getVars( self ):
128         vars = WTemplated.getVars(self)
129         vars["message"] = "Thank you for the payment!<br/> You have used PayPal"
130         vars["trinfo"]="%s:%s"%(self._registrant.getFirstName(),self._registrant.getSurName())
131         return vars
132
133 class WPCancelEPaymentPayPal( conferences.WPConferenceDefaultDisplayBase ):
134     #navigationEntry = navigation.NERegistrationFormDisplay
135
136     def __init__(self, rh, conf, reg):
137         conferences.WPConferenceDefaultDisplayBase.__init__(self, rh, conf)
138         self._registrant=reg
139
140     def _getBody( self, params ):
141         wc = WCancelEPaymentPayPal( self._conf,self._registrant )
142         return wc.getHTML()
143
144     def _defineSectionMenu( self ):
145         conferences.WPConferenceDefaultDisplayBase._defineSectionMenu(self)
146         self._sectionMenu.setCurrentItem(self._regFormOpt)
147
148 class WCancelEPaymentPayPal( WTemplated ):
149     def __init__( self, conference,reg ):
150         self._conf = conference
151         self._registrant=reg
152
153     def getVars( self ):
154         vars = WTemplated.getVars(self)
155         vars["message"] = "You have cancelled your transaction.\nPlease check your email in order to complete your PayPal transaction."
156         vars["messagedetailPayment"]="%s:%s"%(self._registrant.getFirstName(),self._registrant.getSurName())
157         return vars