added shopid
[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.payWay import MODULE_ID
31 from MaKaC.plugins.EPayment.payWay.webinterface.wcomponents import WTemplated
32 from MaKaC.plugins.EPayment.payWay.webinterface import urlHandlers as localUrlHandlers
33
34
35
36 class WPConfModifEPaymentPayWayBase(registrationForm.WPConfModifRegFormBase):
37
38     def _createTabCtrl( self ):
39         self._tabCtrl = wcomponents.TabControl()
40         self._tabMain = self._tabCtrl.newTab( "main", _("Main"), \
41                 localUrlHandlers.UHConfModifEPaymentPayWay.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 WPConfModifEPaymentPayWay( WPConfModifEPaymentPayWayBase ):
63
64     def _getTabContent( self, params ):
65         wc = WConfModifEPaymentPayWay(self._conf)
66         p = {
67              'dataModificationURL': quoteattr(str(localUrlHandlers.UHConfModifEPaymentPayWayDataModif.getURL( self._conf )))
68             }
69         return wc.getHTML(p)
70
71 class WConfModifEPaymentPayWay( WTemplated ):
72
73     def __init__( self, conference ):
74         self._conf = conference
75
76     def getVars( self ):
77         vars = WTemplated.getVars(self)
78         modPayWay = self._conf.getModPay().getPayModByTag(MODULE_ID)
79         vars["title"] = modPayWay.getTitle()
80         vars["url"] = modPayWay.getUrl()
81         vars["business"] =  modPayWay.getBusiness()
82         vars["shopid"] =  modPayWay.getShopID()
83         return vars
84
85 class WPConfModifEPaymentPayWayDataModif( WPConfModifEPaymentPayWayBase ):
86
87     def _getTabContent( self, params ):
88         wc = WConfModifEPaymentPayWayDataModif(self._conf)
89         p = {'postURL': quoteattr(str(localUrlHandlers.UHConfModifEPaymentPayWayPerformDataModif.getURL( self._conf )))
90             }
91         return wc.getHTML(p)
92
93 class WConfModifEPaymentPayWayDataModif( WTemplated ):
94
95     def __init__( self, conference ):
96         self._conf = conference
97
98     def getVars( self ):
99         vars = WTemplated.getVars(self)
100         modPayWay = self._conf.getModPay().getPayModByTag(MODULE_ID)
101         vars["title"] = modPayWay.getTitle()
102         vars["url"] = modPayWay.getUrl()
103         vars["business"] =  modPayWay.getBusiness()
104         vars["shopid"] =  modPayWay.getShopID()
105         return vars
106
107 class WPconfirmEPaymentPayWay( conferences.WPConferenceDefaultDisplayBase ):
108     #navigationEntry = navigation.NERegistrationFormDisplay
109
110     def __init__(self, rh, conf, reg):
111         conferences.WPConferenceDefaultDisplayBase.__init__(self, rh, conf)
112         self._registrant=reg
113
114
115     def _getBody( self, params ):
116         wc = WconfirmEPaymentPayWay(self._conf, self._registrant)
117         return wc.getHTML()
118
119     def _defineSectionMenu( self ):
120         conferences.WPConferenceDefaultDisplayBase._defineSectionMenu(self)
121         self._sectionMenu.setCurrentItem(self._regFormOpt)
122
123
124 class WconfirmEPaymentPayWay( WTemplated ):
125     def __init__( self,configuration, registrant):
126         self._registrant = registrant
127         self._conf = configuration
128
129     def getVars( self ):
130         vars = WTemplated.getVars(self)
131         vars["message"] = "Thank you for the payment!<br/> You have used PayWay"
132         vars["trinfo"]="%s:%s"%(self._registrant.getFirstName(),self._registrant.getSurName())
133         return vars
134
135 class WPCancelEPaymentPayWay( conferences.WPConferenceDefaultDisplayBase ):
136     #navigationEntry = navigation.NERegistrationFormDisplay
137
138     def __init__(self, rh, conf, reg):
139         conferences.WPConferenceDefaultDisplayBase.__init__(self, rh, conf)
140         self._registrant=reg
141
142     def _getBody( self, params ):
143         wc = WCancelEPaymentPayWay( self._conf,self._registrant )
144         return wc.getHTML()
145
146     def _defineSectionMenu( self ):
147         conferences.WPConferenceDefaultDisplayBase._defineSectionMenu(self)
148         self._sectionMenu.setCurrentItem(self._regFormOpt)
149
150 class WCancelEPaymentPayWay( WTemplated ):
151     def __init__( self, conference,reg ):
152         self._conf = conference
153         self._registrant=reg
154
155     def getVars( self ):
156         vars = WTemplated.getVars(self)
157         vars["message"] = "You have cancelled your transaction.\nPlease check your email in order to complete your PayWay transaction."
158         vars["messagedetailPayment"]="%s:%s"%(self._registrant.getFirstName(),self._registrant.getSurName())
159         return vars