Fix datepicker arrows style on hover
[cds-indico.git] / indico / MaKaC / webinterface / rh / templates.py
blobfbf413feb772ae345662e31d691dddf95dbb7c26
1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
17 import MaKaC.webinterface.rh.admins as admins
18 import MaKaC.webinterface.urlHandlers as urlHandlers
19 from indico.core.config import Config
20 from MaKaC.webinterface.pages import admins as adminPages
21 from MaKaC.webinterface.rh.base import RHModificationBaseProtected
22 from MaKaC.webinterface.rh.conferenceBase import RHConferenceBase
23 from MaKaC.webinterface.pages import conferences
24 import MaKaC.conference as conference
26 class RHTemplatesBase(admins.RHAdminBase):
27 pass
30 class RHBadgeTemplates( RHTemplatesBase ):
31 _uh = urlHandlers.UHBadgeTemplates
33 def _checkParams( self, params ):
34 admins.RHAdminBase._checkParams( self, params )
35 self._params = params
37 def _process( self ):
38 p = adminPages.WPBadgeTemplates(self)
39 return p.display()
41 class RHPosterTemplates( RHTemplatesBase ):
42 _uh = urlHandlers.UHPosterTemplates
44 def _checkParams( self, params ):
45 admins.RHAdminBase._checkParams( self, params )
46 self._params = params
48 def _process( self ):
49 p = adminPages.WPPosterTemplates(self)
50 return p.display()
52 class RHSetDefaultPDFOptions( RHTemplatesBase ):
53 _uh = urlHandlers.UHTemplatesSetDefaultPDFOptions
55 def _checkParams( self, params ):
56 admins.RHAdminBase._checkParams( self, params )
57 self.__defaultConferencePDFOptions = conference.CategoryManager().getDefaultConference().getBadgeTemplateManager().getPDFOptions()
59 try:
60 self.__marginTop = float(params.get("marginTop",''))
61 except ValueError:
62 self.__marginTop = self.__defaultConferencePDFOptions.getTopMargin()
64 try:
65 self.__marginBottom = float(params.get("marginBottom",''))
66 except ValueError:
67 self.__marginBottom = self.__defaultConferencePDFOptions.getBottomMargin()
69 try:
70 self.__marginLeft = float(params.get("marginLeft",''))
71 except ValueError:
72 self.__marginLeft = self.__defaultConferencePDFOptions.getLeftMargin()
74 try:
75 self.__marginRight = float(params.get("marginRight",''))
76 except ValueError:
77 self.__marginRight = self.__defaultConferencePDFOptions.getRightMargin()
79 try:
80 self.__marginColumns = float(params.get("marginColumns",''))
81 except ValueError:
82 self.__marginColumns = self.__defaultConferencePDFOptions.getMarginColumns()
84 try:
85 self.__marginRows = float(params.get("marginRows",''))
86 except ValueError:
87 self.__marginRows = self.__defaultConferencePDFOptions.getMarginRows()
89 self.__pagesize = params.get("pagesize",'A4')
91 self.__drawDashedRectangles = params.get("drawDashedRectangles", False) is not False
92 self.__landscape = params.get('landscape') == '1'
94 def _process( self ):
95 self.__defaultConferencePDFOptions.setTopMargin(self.__marginTop)
96 self.__defaultConferencePDFOptions.setBottomMargin(self.__marginBottom)
97 self.__defaultConferencePDFOptions.setLeftMargin(self.__marginLeft)
98 self.__defaultConferencePDFOptions.setRightMargin(self.__marginRight)
99 self.__defaultConferencePDFOptions.setMarginColumns(self.__marginColumns)
100 self.__defaultConferencePDFOptions.setMarginRows(self.__marginRows)
101 self.__defaultConferencePDFOptions.setPagesize(self.__pagesize)
102 self.__defaultConferencePDFOptions.setDrawDashedRectangles(self.__drawDashedRectangles)
103 self.__defaultConferencePDFOptions.setLandscape(self.__landscape)
105 self._redirect(urlHandlers.UHBadgeTemplates.getURL())
107 class RHTemplateModifBase( RHConferenceBase, RHModificationBaseProtected ):
109 def _checkParams( self, params ):
110 RHConferenceBase._checkParams( self, params )
112 def _checkProtection( self ):
113 RHModificationBaseProtected._checkProtection( self )
115 def _displayCustomPage( self, wf ):
116 return None
118 def _displayDefaultPage( self ):
119 return None
121 def _process( self ):
122 wf = self.getWebFactory()
123 if wf != None:
124 res = self._displayCustomPage( wf )
125 if res != None:
126 return res
127 return self._displayDefaultPage()
129 class RHConfPosterDesign(RHTemplateModifBase):
130 """ This class corresponds to the screen where templates are
131 designed. We can arrive to this screen from different scenarios:
132 -We are creating a new template (templateId = new template id, new = True)
133 -We are editing an existing template (templateId = existing template id, new = False or not set)
136 def _checkParams(self, params):
137 RHTemplateModifBase._checkParams(self, params)
138 self.__templateId = params.get("templateId",None)
139 new = params.get("new",'False')
140 if new == 'False':
141 self.__new = False
142 else:
143 self.__new = True
145 def _process(self):
147 p = adminPages.WPPosterTemplateDesign(self, self._target, self.__templateId, self.__new)
148 return p.display()
150 class RHConfBadgeDesign(RHTemplateModifBase):
151 """ This class corresponds to the screen where templates are
152 designed. We can arrive to this screen from different scenarios:
153 -We are creating a new template (templateId = new template id, new = True)
154 -We are editing an existing template (templateId = existing template id, new = False or not set)
157 def _checkParams(self, params):
158 RHTemplateModifBase._checkParams(self, params)
159 self.__templateId = params.get("templateId",None)
160 new = params.get("new",'False')
161 if new == 'False':
162 self.__new = False
163 else:
164 self.__new = True
166 def _process(self):
168 p = adminPages.WPBadgeTemplateDesign(self, self._target, self.__templateId, self.__new)
169 return p.display()