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
):
30 class RHBadgeTemplates( RHTemplatesBase
):
31 _uh
= urlHandlers
.UHBadgeTemplates
33 def _checkParams( self
, params
):
34 admins
.RHAdminBase
._checkParams
( self
, params
)
38 p
= adminPages
.WPBadgeTemplates(self
)
41 class RHPosterTemplates( RHTemplatesBase
):
42 _uh
= urlHandlers
.UHPosterTemplates
44 def _checkParams( self
, params
):
45 admins
.RHAdminBase
._checkParams
( self
, params
)
49 p
= adminPages
.WPPosterTemplates(self
)
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()
60 self
.__marginTop
= float(params
.get("marginTop",''))
62 self
.__marginTop
= self
.__defaultConferencePDFOptions
.getTopMargin()
65 self
.__marginBottom
= float(params
.get("marginBottom",''))
67 self
.__marginBottom
= self
.__defaultConferencePDFOptions
.getBottomMargin()
70 self
.__marginLeft
= float(params
.get("marginLeft",''))
72 self
.__marginLeft
= self
.__defaultConferencePDFOptions
.getLeftMargin()
75 self
.__marginRight
= float(params
.get("marginRight",''))
77 self
.__marginRight
= self
.__defaultConferencePDFOptions
.getRightMargin()
80 self
.__marginColumns
= float(params
.get("marginColumns",''))
82 self
.__marginColumns
= self
.__defaultConferencePDFOptions
.getMarginColumns()
85 self
.__marginRows
= float(params
.get("marginRows",''))
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'
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
):
118 def _displayDefaultPage( self
):
121 def _process( self
):
122 wf
= self
.getWebFactory()
124 res
= self
._displayCustomPage
( wf
)
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')
147 p
= adminPages
.WPPosterTemplateDesign(self
, self
._target
, self
.__templateId
, self
.__new
)
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')
168 p
= adminPages
.WPBadgeTemplateDesign(self
, self
._target
, self
.__templateId
, self
.__new
)