1 # -*- coding: utf-8 -*-
4 ## This file is part of CDS Indico.
5 ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
7 ## CDS 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 2 of the
10 ## License, or (at your option) any later version.
12 ## CDS 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.
17 ## You should have received a copy of the GNU General Public License
18 ## along with CDS Indico; if not, write to the Free Software Foundation, Inc.,
19 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21 from MaKaC
.plugins
import PluginsHolder
, OldObservable
23 import os
,types
,string
25 from xml
.sax
.saxutils
import escape
, quoteattr
27 from datetime
import timedelta
,datetime
,date
,time
30 from operator
import attrgetter
31 from MaKaC
.common
.db
import DBMgr
32 import MaKaC
.conference
as conference
33 import MaKaC
.user
as user
34 import MaKaC
.schedule
as schedule
35 import MaKaC
.common
.info
as info
36 import MaKaC
.domain
as domain
37 import MaKaC
.webinterface
.urlHandlers
as urlHandlers
38 import MaKaC
.common
.Configuration
as Configuration
39 from MaKaC
import webcast
41 from MaKaC
.accessControl
import AdminList
42 from MaKaC
.errors
import UserError
43 from MaKaC
.common
.url
import URL
44 from MaKaC
.common
import Config
45 from MaKaC
.webinterface
.common
.person_titles
import TitlesRegistry
46 from MaKaC
.conference
import Conference
, Category
48 from MaKaC
.webinterface
.common
.timezones
import TimezoneRegistry
, DisplayTimezoneRegistry
49 import MaKaC
.webinterface
.common
.timezones
as convertTime
50 from pytz
import timezone
51 from MaKaC
.common
.timezoneUtils
import DisplayTZ
, nowutc
52 from MaKaC
.webinterface
.common
import contribFilters
as contribFilters
53 from MaKaC
.common
import filters
, utils
54 from MaKaC
.common
.TemplateExec
import escapeHTMLForJS
55 from MaKaC
.errors
import MaKaCError
56 import MaKaC
.webinterface
.displayMgr
as displayMgr
57 import MaKaC
.common
.TemplateExec
as templateEngine
58 from MaKaC
.common
.ContextHelp
import ContextHelp
59 from MaKaC
.rb_tools
import FormMode
, overlap
61 from lxml
import etree
63 from indico
.util
.i18n
import i18nformat
, parseLocale
, getLocaleDisplayNames
65 from MaKaC
.common
.TemplateExec
import truncateTitle
66 from MaKaC
.fossils
.user
import IAvatarFossil
67 from MaKaC
.common
.fossilize
import fossilize
68 from MaKaC
.common
.contextManager
import ContextManager
70 from indico
.util
.date_time
import utc_timestamp
71 from indico
.core
.index
import Catalog
75 MIN_PRESENT_EVENTS
= 6
76 OPTIMAL_PRESENT_EVENTS
= 10
79 class WTemplated(OldObservable
):
80 """This class provides a basic implementation of a web component (an
81 object which generates HTML related to a certain feature or
82 functionality) which relies in a template file for generating the
83 HTML it's in charge of.
84 By templating file we mean that there will be a file in the file
85 system (uniquely identified) which will contain HTML code plus some
86 "variables" (dynamic values). The class will take care of opening
87 this file, parsing the HTML and replacing the variables by the
93 def forModule(cls
, module
, *args
):
96 tplobj
._dir
= os
.path
.join(module
.__path
__[0], 'tpls')
99 def __init__( self
, tpl_name
= None):
101 self
.tplId
= tpl_name
103 self
._rh
= ContextManager
.get('currentRH', None)
105 cfg
= Configuration
.Config
.getInstance()
106 self
._dir
= cfg
.getTPLDir()
108 def _getSpecificTPL(self
, dir, tplId
, extension
="tpl"):
110 Checks if there is a defined set of specific templates (i.e. CERN),
111 and if there is a specific file for this page, for this template set.
112 Returns the file that should be used.
116 if DBMgr
.getInstance().isConnected():
117 template
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance().getDefaultTemplateSet()
119 if template
!= None :
120 specTpl
= "%s.%s.%s" % (tplId
, template
, extension
)
122 if os
.path
.exists(os
.path
.join(dir,specTpl
)):
126 return "%s.%s" % (tplId
, extension
)
128 def _setTPLFile(self
):
129 """Sets the TPL (template) file for the object. It will try to get
130 from the configuration if there's a special TPL file for it and
131 if not it will look for a file called as the class name+".tpl"
132 in the configured TPL directory.
134 cfg
= Configuration
.Config
.getInstance()
136 file = cfg
.getTPLFile( self
.tplId
)
138 # because MANY classes skip the constructor...
139 if hasattr(self
, '_dir'):
142 tplDir
= cfg
.getTPLDir()
145 file = self
._getSpecificTPL
(tplDir
,self
.tplId
)
146 self
.tplFile
= os
.path
.join(tplDir
, file)
148 hfile
= self
._getSpecificTPL
(os
.path
.join(tplDir
,'chelp'),
152 self
.helpFile
= os
.path
.join(tplDir
,'chelp',hfile
)
156 """Returns a dictionary containing the TPL variables that will
157 be passed at the TPL formating time. For this class, it will
158 return the configuration user defined variables.
159 Classes inheriting from this one will have to take care of adding
160 their variables to the ones returned by this method.
162 self
._rh
= ContextManager
.get('currentRH', None)
164 cfg
= Configuration
.Config
.getInstance()
165 vars = cfg
.getTPLVars()
167 for paramName
in self
.__params
:
168 vars[ paramName
] = self
.__params
[ paramName
]
169 if len(vars.get("errorMsg", [])) > 0 :
170 vars["errorMsg"] = WErrorMessage().getHTML(vars)
172 vars["errorMsg"] = ""
174 if len(vars.get("infoMsg", [])) > 0 :
175 vars["infoMsg"] = WInfoMessage().getHTML(vars)
181 def getHTML( self
, params
=None ):
182 """Returns the HTML resulting of formating the text contained in
183 the corresponding TPL file with the variables returned by the
186 params -- additional paramters received from the caller
189 self
._rh
= ContextManager
.get('currentRH', None)
190 if self
.tplId
== None:
191 self
.tplId
= self
.__class
__.__name
__[1:]
195 self
.__params
= params
197 # include context help info, if it exists
199 if os
.path
.exists(self
.helpFile
):
201 fh
= open( self
.helpFile
, "r")
204 except exceptions
.IOError:
207 vars = self
.getVars()
209 vars['__rh__'] = self
._rh
212 tempHTML
= templateEngine
.render(self
.tplFile
, vars)
214 if self
._rh
and self
._rh
._req
.is_https():
215 imagesBaseURL
= Config
.getInstance().getImagesBaseURL()
216 imagesBaseSecureURL
= urlHandlers
.setSSLPort(Config
.getInstance().getImagesBaseSecureURL())
217 tempHTML
= tempHTML
.replace(imagesBaseURL
, imagesBaseSecureURL
)
218 tempHTML
= tempHTML
.replace(escapeHTMLForJS(imagesBaseURL
), escapeHTMLForJS(imagesBaseSecureURL
))
224 return ContextHelp().merge(self
.tplId
, tempHTML
, helpText
)
225 except etree
.LxmlError
, e
:
226 if tempHTML
.strip() == '':
227 raise MaKaCError(_("Template " + str(self
.tplId
) + " produced empty output, and it has a .wohl file. Error: " + str(e
)))
237 htmlText
= staticmethod( htmlText
)
239 def textToHTML(param
):
241 if param
.lower().find("<br>") == -1 and param
.lower().find("<p>") == -1 and param
.lower().find("<li>") == -1 and param
.lower().find("<table") == -1:
242 param
=param
.replace("\r\n", "<br>")
243 param
=param
.replace("\n","<br>")
246 textToHTML
= staticmethod( textToHTML
)
248 def _escapeChars(self
, text
):
249 # Does nothing right now - it used to replace % with %% for the old-style templates
252 class WHTMLHeader(WTemplated
):
256 def __init__(self
, tpl_name
= None):
257 WTemplated
.__init
__(self
)
260 vars = WTemplated
.getVars( self
)
262 if DBMgr
.getInstance().isConnected():
263 vars['stylesheet'] = Config
.getInstance().getCssStylesheetName()
265 vars['stylesheet'] = 'Default.css'
269 class WHeader(WTemplated
):
270 """Templating web component for generating a common HTML header for
273 def __init__(self
, aw
, locTZ
="", isFrontPage
=False, currentCategory
=None, tpl_name
=None):
274 WTemplated
.__init
__(self
, tpl_name
=tpl_name
)
275 self
._currentuser
= aw
.getUser()
278 self
._isFrontPage
= isFrontPage
279 self
.__currentCategory
= currentCategory
282 Returns the current active timezone.
284 def _getActiveTimezone(self
):
285 if self
._aw
.getSession():
286 tz
= self
._aw
.getSession().getVar("ActiveTimezone")
288 tz
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance().getTimezone()
293 Returns timezone string that is show to the user.
295 def _getTimezoneDisplay( self
, timezone
):
296 if timezone
== 'LOCAL':
300 return info
.HelperMaKaCInfo
.getMaKaCInfoInstance().getTimezone()
305 vars = WTemplated
.getVars( self
)
306 #urlHandlers.UHUserDetails.getURL(self._currentuser)
308 # TODO: Remove this after CRBS headers are fixed!
309 if self
._currentuser
:
310 vars["userInfo"] = """<font size="-1"><a class="topbar" href="%s" target="_blank">%s</a> - <a href="%s">logout</a></font>"""%(urlHandlers
.UHUserDetails
.getURL(self
._currentuser
), self
._currentuser
.getFullName(), vars["logoutURL"])
311 vars["userDetails"] = 'class="topbar" href="%s" target="_blank"'%urlHandlers
.UHUserDetails
.getURL(self
._currentuser
)
313 if self
._currentuser
.isAdmin():
314 vars["logMeAs"] = vars["loginAsURL"]
316 vars["userInfo"] = """<a href="%s">login</a>"""%(vars["loginURL"])
317 vars["userDetails"] = ""
320 vars["currentUser"] = self
._currentuser
322 imgLogo
=Configuration
.Config
.getInstance().getSystemIconURL( "logoIndico" )
323 imgLogin
=Configuration
.Config
.getInstance().getSystemIconURL( "login" )
325 vars["imgLogo"] = imgLogo
326 vars["imgLogin"] = imgLogin
327 vars["isFrontPage"] = self
._isFrontPage
328 vars["currentCategory"] = self
.__currentCategory
330 if self
._aw
.getSession():
331 selLang
= self
._aw
.getSession().getLang()
333 minfo
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance()
334 selLang
= minfo
.getLang()
336 vars["ActiveTimezone"] = self
._getActiveTimezone
();
338 Get the timezone for displaying on top of the page.
339 1. If the user has "LOCAL" timezone then show the timezone
340 of the event/category. If that's not possible just show the
342 2. If the user has a custom timezone display that one.
344 vars["ActiveTimezoneDisplay"] = self
._getTimezoneDisplay
(vars["ActiveTimezone"])
346 vars["SelectedLanguage"] = selLang
347 locale
= parseLocale(selLang
)
348 vars["SelectedLanguageName"] = locale
.languages
[locale
.language
].encode('utf-8')
349 vars["Languages"] = getLocaleDisplayNames()
351 if DBMgr
.getInstance().isConnected():
352 vars["title"] = info
.HelperMaKaCInfo
.getMaKaCInfoInstance().getTitle()
353 vars["organization"] = info
.HelperMaKaCInfo
.getMaKaCInfoInstance().getOrganisation()
355 vars["title"] = "Indico"
356 vars["organization"] = ""
359 # Search box, in case search is active
360 if Config
.getInstance().getIndicoSearchServer() != '' :
362 if self
.__currentCategory
:
363 categId
= self
.__currentCategory
.getId()
364 vars['searchBox'] = WCategorySearchBox(categId
=categId
).getHTML()
366 vars['searchBox'] = ""
368 # Check if room booking module is active
369 minfo
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance()
370 vars['roomBooking'] = minfo
.getRoomBookingModuleActive()
372 #Build a list of items for the administration menu
373 adminList
= AdminList
.getInstance()
375 if self
._currentuser
:
376 if self
._currentuser
.isAdmin() or not adminList
.getList():
377 adminItemList
.append({'url': urlHandlers
.UHAdminArea
.getURL(), 'text': _("Server admin")})
378 if PluginsHolder().hasPluginType("Collaboration"):
379 from MaKaC
.webinterface
.rh
.collaboration
import RCCollaborationAdmin
, RCCollaborationPluginAdmin
380 from MaKaC
.plugins
.Collaboration
.collaborationTools
import CollaborationTools
381 if (self
._currentuser
.isAdmin() or RCCollaborationAdmin
.hasRights(user
= self
._currentuser
) or RCCollaborationPluginAdmin
.hasRights(user
= self
._currentuser
, plugins
= "any")) and CollaborationTools
.anyPluginsAreActive():
382 adminItemList
.append({'url': urlHandlers
.UHAdminCollaboration
.getURL(), 'text': _("Video Services Overview")})
383 if webcast
.HelperWebcastManager
.getWebcastManagerInstance().isManager(self
._currentuser
):
384 adminItemList
.append({'url': urlHandlers
.UHWebcast
.getURL(), 'text': _("Webcast Admin")})
387 vars["adminItemList"] = adminItemList
392 class WStaticWebHeader( WTemplated
):
393 """Templating web component for generating the HTML header for
394 the static web interface when generating a DVD.
397 vars = WTemplated
.getVars( self
)
400 class WManagementHeader( WHeader
):
401 """Templating web component for generating the HTML header for
402 the management web interface.
406 class WHelpHeader( WHeader
):
407 """Templating web component for generating the HTML header for
408 the help web interface.
412 class WRoomBookingHeader( WHeader
):
413 """Templating web component for generating the HTML header for
414 the (standalone) room booking web interface.
418 class WConferenceHeader( WHeader
):
419 """Templating web component for generating the HTML header for
420 the conferences' web interface.
423 def __init__(self
, aw
, conf
):
426 WHeader
.__init
__(self
, self
._aw
, tpl_name
='EventHeader')
427 tzUtil
= DisplayTZ(self
._aw
,self
._conf
)
428 self
._locTZ
= tzUtil
.getDisplayTZ()
431 vars = WHeader
.getVars( self
)
432 vars["categurl"] = urlHandlers
.UHCategoryDisplay
.getURL(self
._conf
.getOwnerList()[0])
434 vars["conf"] = self
._conf
;
436 vars["imgLogo"] = Configuration
.Config
.getInstance().getSystemIconURL( "miniLogo" )
437 vars["MaKaCHomeURL"] = urlHandlers
.UHCategoryDisplay
.getURL(self
._conf
.getOwnerList()[0])
439 #moved here from WHeader in order to be able to use DisplayTZ with self._conf (in some pages WHeader has no self._conf).
440 #TODO: Is this needed?
441 #vars["Timezones"] = Config.getInstance().getTimezoneList()
444 # if self._conf.getModifKey() != '':
445 # url = urlHandlers.UHConfEnterModifKey.getURL(self._conf)
446 # url.addParam("redirectURL",urlHandlers.UHConferenceDisplay.getURL(self._conf))
447 # vars["confModif"] = """<a href=%s><img src=%s valign="middle"></a>"""%(quoteattr(str(url)), quoteattr(str(Configuration.Config.getInstance().getSystemIconURL( "modify" ))))
449 # vars["confModif"] = ""
451 # Default values to avoid NameError while executing the template
452 vars["viewoptions"] = []
453 vars["SelectedStyle"] = ""
455 vars["displayURL"] = ""
457 # Setting the buttons that will be displayed in the header menu
458 vars["showFilterButton"] = False
459 vars["showMoreButton"] = True
460 vars["showExportToICal"] = True
461 vars["showExportToPDF"] = False
462 vars["showDLMaterial"] = True
463 vars["showLayout"] = False
465 vars["usingModifKey"]=False
466 if self
._conf
.canKeyModify(self
._aw
):
467 vars["usingModifKey"]=True
468 vars["displayNavigationBar"] = displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
, False).getDisplayNavigationBar()
471 class WMenuConferenceHeader( WConferenceHeader
):
472 """Templating web component for generating the HTML header for
473 the conferences' web interface with a menu
475 def __init__(self
, aw
, conf
, modifKey
=False):
477 self
._modifKey
=modifKey
479 WConferenceHeader
.__init
__(self
, self
._aw
, conf
)
482 vars = WConferenceHeader
.getVars( self
)
483 vars["categurl"] = urlHandlers
.UHConferenceDisplay
.getURL(self
._conf
)
484 url
= urlHandlers
.UHConfEnterModifKey
.getURL(self
._conf
)
485 url
.addParam("redirectURL",urlHandlers
.UHConferenceOtherViews
.getURL(self
._conf
))
486 vars["confModif"] = i18nformat("""<a href=%s> _("manage")</a>""")%quoteattr(str(url
))
487 if self
._conf
.canKeyModify(self
._aw
):
488 url
= urlHandlers
.UHConfCloseModifKey
.getURL(self
._conf
)
489 url
.addParam("redirectURL",urlHandlers
.UHConferenceOtherViews
.getURL(self
._conf
))
490 vars["confModif"] = i18nformat("""<a href=%s>_("exit manage")</a>""")%quoteattr(str(url
))
493 tz
= DisplayTZ(self
._aw
,self
._conf
,useServerTZ
=1).getDisplayTZ()
494 sdate
= self
._conf
.getStartDate().astimezone(timezone(tz
))
495 edate
= self
._conf
.getEndDate().astimezone(timezone(tz
))
497 if sdate
.strftime("%Y-%m-%d") != edate
.strftime("%Y-%m-%d"):
499 if vars.has_key("selectedDate"):
500 selectedDate
= vars["selectedDate"]
501 if selectedDate
== "all" or selectedDate
== "":
502 selected
= "selected"
505 dates
= [ i18nformat(""" <select name="showDate" onChange="document.forms[0].submit();" style="font-size:8pt;"><option value="all" %s>- - _("all days") - -</option> """)%selected
]
506 while sdate
.strftime("%Y-%m-%d") <= edate
.strftime("%Y-%m-%d"):
508 if selectedDate
== sdate
.strftime("%d-%B-%Y"):
509 selected
= "selected"
510 d
= sdate
.strftime("%d-%B-%Y")
511 dates
.append(""" <option value="%s" %s>%s</option> """%(d
, selected
, d
))
512 sdate
= sdate
+ timedelta(days
=1)
513 dates
.append("</select>")
515 dates
.append("""<input type="hidden" name="showDate" value="all">""")
518 if len(self
._conf
.getSessionList()) != 0:
520 if vars.has_key("selectedSession"):
521 selectedSession
= vars["selectedSession"]
522 if selectedSession
== "all" or selectedSession
== "":
523 selected
= "selected"
525 selectedSession
= "all"
526 sessions
= [ i18nformat(""" <select name="showSession" onChange="document.forms[0].submit();" style="font-size:8pt;"><option value="all" %s>- - _("all sessions") - -</option> """)%selected
]
527 for session
in self
._conf
.getSessionList():
530 if id == selectedSession
:
531 selected
= "selected"
532 sessions
.append(""" <option value="%s" %s>%s</option> """%(id, selected
, session
.getTitle()))
533 sessions
.append("</select>")
535 sessions
.append("""<input type="hidden" name="showSession" value="all">""")
536 # Handle hide/show contributions option
537 hideContributions
= None;
538 if len(self
._conf
.getSessionList()) != 0:
539 if vars.has_key("detailLevel"):
540 if vars["detailLevel"] == "session":
541 hideContributions
= "checked"
543 hideContributions
= ""
545 vars["hideContributions"] = hideContributions
;
547 if self
._conf
.getType() == "meeting" and self
._conf
.getParticipation().isAllowedForApplying() and self
._conf
.getStartDate() > nowutc():
548 vars["applyForParticipation"] = i18nformat("""<a href="%s">_("Apply for participation")</a>""")%urlHandlers
.UHConfParticipantsNewPending
.getURL(self
._conf
)
550 vars["applyForParticipation"] = ""
551 evaluation
= self
._conf
.getEvaluation()
552 if self
._conf
.hasEnabledSection("evaluation") and evaluation
.isVisible() and evaluation
.inEvaluationPeriod() and evaluation
.getNbOfQuestions()>0 :
553 vars["evaluation"] = i18nformat("""<a href="%s"> _("Evaluation")</a>""")%urlHandlers
.UHConfEvaluationDisplay
.getURL(self
._conf
)
555 vars["evaluation"] = ""
557 urlCustPrint
= urlHandlers
.UHConferenceOtherViews
.getURL(self
._conf
)
558 urlCustPrint
.addParam("showDate", vars.get("selectedDate", "all"))
559 urlCustPrint
.addParam("showSession", vars.get("selectedSession", "all"))
560 urlCustPrint
.addParam("fr", "no")
561 urlCustPrint
.addParam("view", vars["currentView"])
562 vars["printURL"]=str(urlCustPrint
)
564 vars["printIMG"]=quoteattr(str(Configuration
.Config
.getInstance().getSystemIconURL( "printer" )))
565 urlCustPDF
=urlHandlers
.UHConfTimeTableCustomizePDF
.getURL(self
._conf
)
566 urlCustPDF
.addParam("showDays", vars.get("selectedDate", "all"))
567 urlCustPDF
.addParam("showSessions", vars.get("selectedSession", "all"))
568 vars["pdfURL"]=quoteattr(str(urlCustPDF
))
569 vars["pdfIMG"]=quoteattr(str(Configuration
.Config
.getInstance().getSystemIconURL( "pdf" )))
570 urlMatPack
=urlHandlers
.UHConferenceDisplayMaterialPackage
.getURL(self
._conf
)
571 vars["matPackURL"]=quoteattr(str(urlMatPack
))
572 vars["zipIMG"]=quoteattr(str(Configuration
.Config
.getInstance().getSystemIconURL( "smallzip" )))
576 class WMenuMeetingHeader( WConferenceHeader
):
577 """Templating web component for generating the HTML header for
578 the meetings web interface with a menu
580 def __init__(self
, aw
, conf
, modifKey
=False):
582 self
._modifKey
=modifKey
584 WHeader
.__init
__(self
, self
._aw
, tpl_name
='EventHeader')
585 tzUtil
= DisplayTZ(self
._aw
,self
._conf
)
586 self
._locTZ
= tzUtil
.getDisplayTZ()
590 vars = WConferenceHeader
.getVars( self
)
592 vars["categurl"] = urlHandlers
.UHCategoryDisplay
.getURL(self
._conf
.getOwnerList()[0])
593 #vars["confModif"] = i18nformat("""<a href=%s> _("manage")</a>""")%quoteattr(str(urlHandlers.UHConfEnterModifKey.getURL(self._conf)))
594 #if self._conf.canKeyModify(self._aw):
595 # vars["confModif"] = i18nformat("""<a href=%s> _("exit manage")</a>""")%quoteattr(str(urlHandlers.UHConfCloseModifKey.getURL(self._conf)))
596 #vars["confModif"] += " | "
597 #if not self._conf.canAccess(self._aw) and self._conf.getAccessKey() != "":
598 # vars["confModif"] += i18nformat("""<a href=%s>_("full agenda")</a> | """)%(quoteattr(str(urlHandlers.UHConfForceEnterAccessKey.getURL(self._conf))))
599 styleMgr
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance().getStyleManager()
600 styles
= styleMgr
.getExistingStylesForEventType(vars["type"])
604 styles
.sort(key
=styleMgr
.getStyleName
)
605 for styleId
in styles
:
606 viewoptions
.append({"id": styleId
, "name": styleMgr
.getStyleName(styleId
) })
607 vars["viewoptions"] = viewoptions
608 vars["SelectedStyle"] = styleMgr
.getStyleName(vars["currentView"])
609 vars["displayURL"] = urlHandlers
.UHConferenceDisplay
.getURL(self
._rh
._conf
)
611 # Setting the buttons that will be displayed in the header menu
612 vars["showFilterButton"] = True
613 vars["showExportToPDF"] = True
614 vars["showDLMaterial"] = True
615 vars["showLayout"] = True
619 tz
= DisplayTZ(self
._aw
,self
._conf
,useServerTZ
=1).getDisplayTZ()
620 sdate
= self
._conf
.getStartDate().astimezone(timezone(tz
))
621 edate
= self
._conf
.getEndDate().astimezone(timezone(tz
))
624 if vars.has_key("selectedDate"):
625 selectedDate
= vars["selectedDate"]
626 if selectedDate
== "all" or selectedDate
== "":
627 selected
= "selected"
630 dates
= [ i18nformat(""" <option value="all" %s>- - _("all days") - -</option> """)%selected
]
631 while sdate
.strftime("%Y-%m-%d") <= edate
.strftime("%Y-%m-%d"):
633 if selectedDate
== sdate
.strftime("%d-%B-%Y"):
634 selected
= "selected"
635 d
= sdate
.strftime("%d-%B-%Y")
636 dates
.append(""" <option value="%s" %s>%s</option> """%(d
, selected
, d
))
637 sdate
= sdate
+ timedelta(days
=1)
638 vars["datesMenu"] = "".join(dates
);
643 if vars.has_key("selectedSession"):
644 selectedSession
= vars["selectedSession"]
645 if selectedSession
== "all" or selectedSession
== "":
646 selected
= "selected"
648 selectedSession
= "all"
649 sessions
= [ i18nformat(""" <option value="all" %s>- - _("all sessions") - -</option> """)%selected
]
650 for session
in self
._conf
.getSessionList():
653 if id == selectedSession
:
654 selected
= "selected"
655 title
= session
.getTitle()
657 title
= title
[0:40] + "..."
658 sessions
.append(""" <option value="%s" %s>%s</option> """%(id, selected
, title
))
659 vars["sessionsMenu"] = "".join(sessions
);
661 # Handle hide/show contributions option
662 hideContributions
= None;
663 if len(self
._conf
.getSessionList()) != 0:
664 if vars.has_key("detailLevel"):
665 if vars["detailLevel"] == "session":
666 hideContributions
= "checked"
668 hideContributions
= ""
669 vars["hideContributions"] = hideContributions
;
671 if Config
.getInstance().getIndicoSearchServer() != '' :
672 vars["searchBox"] = WCategorySearchBox(optionsClass
='meetingHeaderSearchBox').getHTML()
674 vars["searchBox"] = ""
676 urlCustPrint
= urlHandlers
.UHConferenceOtherViews
.getURL(self
._conf
)
677 urlCustPrint
.addParam("showDate", vars.get("selectedDate", "all"))
678 urlCustPrint
.addParam("showSession", vars.get("selectedSession", "all"))
679 urlCustPrint
.addParam("detailLevel", vars.get("detailLevel", "all"))
680 urlCustPrint
.addParam("fr", "no")
681 urlCustPrint
.addParam("view", vars["currentView"])
682 vars["printURL"]=str(urlCustPrint
)
685 urlCustPDF
=urlHandlers
.UHConfTimeTableCustomizePDF
.getURL(self
._conf
)
686 urlCustPDF
.addParam("showDays", vars.get("selectedDate", "all"))
687 urlCustPDF
.addParam("showSessions", vars.get("selectedSession", "all"))
688 # Add the view as a parameter to keep track of the current layout
689 # when exporting a pdf
690 urlCustPDF
.addParam("view", vars["currentView"])
691 vars["pdfURL"]=str(urlCustPDF
)
696 class WMenuSimpleEventHeader( WMenuMeetingHeader
):
697 """Templating web component for generating the HTML header for
698 the simple event' web interface with a menu
702 vars = WMenuMeetingHeader
.getVars( self
)
703 vars["confModif"] = """<a href=%s>manage</a>"""%quoteattr(str(urlHandlers
.UHConfEnterModifKey
.getURL(self
._conf
)))
704 if self
._conf
.canKeyModify(self
._aw
):
705 vars["confModif"] = """<a href=%s>exit manage</a>"""%quoteattr(str(urlHandlers
.UHConfCloseModifKey
.getURL(self
._conf
)))
707 # Setting the buttons that will be displayed in the header menu
708 vars["showFilterButton"] = False
709 vars["showExportToPDF"] = False
711 vars["accessWrapper"] = self
._aw
716 class WFooter(WTemplated
):
717 """Templating web component for generating a common HTML footer for the
721 def __init__(self
, tpl_name
= None, isFrontPage
= False):
722 WTemplated
.__init
__(self
, tpl_name
)
723 self
._isFrontPage
= isFrontPage
726 vars = WTemplated
.getVars( self
)
728 vars["isFrontPage"] = self
._isFrontPage
;
730 if not vars.has_key("modificationDate"):
731 vars["modificationDate"] = ""
733 if not vars.has_key("shortURL"):
734 vars["shortURL"] = ""
739 class WEventFooter(WFooter
):
741 Specialization of WFooter that provides extra info for events
743 def __init__(self
, conf
, tpl_name
= None, isFrontPage
= False):
744 WFooter
.__init
__(self
, tpl_name
, isFrontPage
)
747 def _gCalDateFormat(self
, dtime
):
748 return dtime
.strftime("%Y%m%dT%H%M%SZ")
751 v
= WFooter
.getVars(self
)
752 v
['gc_params'] = urllib
.urlencode({
753 'action': 'TEMPLATE',
754 'text': self
._conf
.getTitle(),
755 'dates': "%s/%s" % (self
._gCalDateFormat
(self
._conf
.getStartDate()),
756 self
._gCalDateFormat
(self
._conf
.getEndDate())),
757 'details': self
._conf
.getDescription(),
758 'location': self
._conf
.getLocation().getName() if self
._conf
.getLocation() else '',
760 'sprop': [str(urlHandlers
.UHConferenceDisplay
.getURL(self
._conf
)),
764 cid
= self
._conf
.getUrlTag().strip() or self
._conf
.getId()
765 minfo
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance()
766 app_data
= minfo
.getSocialAppConfig()
768 v
['icalURL'] = urlHandlers
.UHConferenceToiCal
.getURL(self
._conf
)
769 v
["shortURL"] = Config
.getInstance().getShortEventURL() + cid
770 v
["app_data"] = app_data
771 v
["showSocial"] = app_data
.get('active', False) and self
._conf
.getDisplayMgr().getShowSocialApps()
775 class WNavigationDrawer(WTemplated
):
777 def __init__( self
, pars
, bgColor
= None, appendPath
= [] , type = None):
778 self
._target
= pars
["target"]
779 self
._isModif
= pars
.get("isModif", False)
780 self
._track
= pars
.get("track", None) #for abstracts viewed inside a track
781 self
._bgColor
= bgColor
782 self
._actionType
= type #type of action
785 The appendPath is an array with dictionaries: {"url": x, "title": x}.
786 Each of these links are added in the end of the breadcrumb
788 self
._appendPath
= appendPath
791 vars = WTemplated
.getVars( self
)
792 vars["target"] = self
._target
793 vars["isModif"]= self
._isModif
794 vars["track"]= self
._track
795 vars["bgColor"] = self
._bgColor
796 vars["appendPath"] = self
._appendPath
797 vars["actionType"] = self
._actionType
800 def getHTML(self
, params
=None):
801 return WTemplated
.getHTML(self
, params
)
803 class WSimpleNavigationDrawer(WTemplated
):
805 def __init__( self
, title
, handler
= None, bgColor
= None, **pars
):
806 self
._urlHandler
= handler
809 self
._bgColor
= bgColor
812 vars = WTemplated
.getVars( self
)
813 vars["urlHandler"] = self
._urlHandler
814 vars["title"] = self
._title
815 vars["pars"] = self
._pars
816 vars["bgColor"] = self
._bgColor
819 def getHTML(self
, params
=None):
820 return WTemplated
.getHTML(self
, params
)
822 class WBannerModif(WTemplated
):
824 def __init__( self
, path
= [], itemType
= "", title
= "" ):
825 WTemplated
.__init
__( self
, "BannerModif" )
828 self
._type
= itemType
831 """ Retrieves the HTML of the banner of the modification interface
832 of the given target event / category / contribution / abstract / etc.
833 'track' argument should be provided for abstracts viewed inside a track.
834 If originUrl and originPageTitle is set then this link his added to the end
835 of the breadcrumb showed in the banner.
838 return WTemplated
.getHTML(self
, {"type" : self
._type
, "path": self
._path
, "title": self
._title
})
840 class WTimetableBannerModif(WBannerModif
):
842 def __init__(self
, aw
, target
):
844 # Iterate till conference is reached
845 conf
= target
.getConference()
846 path
= self
._getOwnerBasePath
(target
)
847 scheduleModifURL
= None
849 # if user has access to top-level timetable
850 if conf
.canModify(aw
):
851 scheduleModifURL
= urlHandlers
.UHConfModifSchedule
.getURL( conf
)
852 elif target
.getSession():
853 # otherwise, let them access only the session timetable
854 scheduleModifURL
= urlHandlers
.UHSessionModifSchedule
.getURL( target
.getSession() )
856 path
.append({"url": scheduleModifURL
, "title": _("Timetable")})
858 itemType
= type(target
).__name
__
859 title
= target
.getTitle()
860 WBannerModif
.__init
__(self
, path
, itemType
, title
)
862 def _getOwnerBasePath(self
, target
):
867 if type(obj
) != Conference
and type(obj
) != conference
.Category
:
868 path
.append({"url": urlHandlers
.UHHelper
.getModifUH(type(obj
)).getURL(obj
),
869 "title": truncateTitle(obj
.getTitle(), 30),
870 "type": type(obj
).__name
__})
875 class WListOfPapersToReview(WBannerModif
):
877 def __init__(self
, target
, user
):
879 # Iterate till conference is reached
880 conf
= target
.getConference()
881 if user
== "referee":
882 path
= [{"url": urlHandlers
.UHConfModifListContribToJudge
.getURL(conf
), "title":_("Contributions list")}]
883 if user
== "reviewer":
884 path
= [{"url": urlHandlers
.UHConfModifListContribToJudgeAsReviewer
.getURL(conf
), "title":_("Contributions list")}]
886 path
= [{"url": urlHandlers
.UHConfModifListContribToJudgeAsEditor
.getURL(conf
), "title":_("Contributions list")}]
888 itemType
= type(target
).__name
__
889 title
= target
.getTitle()
890 WBannerModif
.__init
__(self
, path
, itemType
, title
)
892 class WContribListBannerModif(WTimetableBannerModif
):
894 def __init__(self
, target
):
896 # Iterate till conference is reached
897 conf
= target
.getConference()
898 path
= self
._getOwnerBasePath
(target
)
900 path
.append({"url": urlHandlers
.UHConfModifContribList
.getURL( conf
), "title": _("Contributions list")})
903 itemType
= type(target
).__name
__
904 title
= target
.getTitle()
905 WBannerModif
.__init
__(self
, path
, itemType
, title
)
908 class WNotifTplBannerModif(WBannerModif
):
910 def __init__( self
, target
):
911 path
= [{"url": urlHandlers
.UHAbstractReviewingNotifTpl
.getURL(target
), "title":_("Notification template list")}]
912 itemType
="Notification Template"
913 title
=target
.getName()
914 WBannerModif
.__init
__(self
, path
, itemType
, title
)
916 class WAbstractBannerModif(WBannerModif
):
918 def __init__( self
, target
):
919 path
= [{"url": urlHandlers
.UHConfAbstractManagment
.getURL(target
), "title":_("Abstracts list")}]
921 title
=target
.getTitle()
922 WBannerModif
.__init
__(self
, path
, itemType
, title
)
924 class WTrackBannerModif(WBannerModif
):
926 def __init__( self
, track
, abstract
=None, isManager
= False ):
930 path
.append({"url": urlHandlers
.UHTrackModifAbstracts
.getURL(track
), "title":_("Abstract list")})
932 path
.append({"url": urlHandlers
.UHConfModifProgram
.getURL(track
.getConference()), "title":_("Track list")})
933 itemType
=type(target
).__name
__
934 title
=target
.getTitle()
935 WBannerModif
.__init
__(self
, path
, itemType
, title
)
937 class WCategoryBannerModif(WBannerModif
):
939 def __init__( self
, target
):
941 title
=target
.getTitle()
942 WBannerModif
.__init
__(self
, [], itemType
, title
)
944 class WRegFormBannerModif(WBannerModif
):
946 def __init__( self
, registrant
):
947 path
=[{"url": urlHandlers
.UHConfModifRegistrantList
.getURL(registrant
.getConference()), "title":_("Registrants list")}]
949 itemType
="Registrant"
950 title
=registrant
.getFullName()
951 WBannerModif
.__init
__(self
, path
, itemType
, title
)
953 class WRegFormSectionBannerModif(WBannerModif
):
955 def __init__( self
, target
, conf
):
956 path
=[{"url": urlHandlers
.UHConfModifRegForm
.getURL(conf
), "title":_("Registration form setup")}]
958 itemType
="Registration form Section"
959 title
=target
.getTitle()
960 WBannerModif
.__init
__(self
, path
, itemType
, title
)
962 class WEpaymentBannerModif(WBannerModif
):
964 def __init__( self
, target
, conf
):
965 path
=[{"url": urlHandlers
.UHConfModifEPayment
.getURL(conf
), "title":_("Epayment setup")}]
967 itemType
="Epayment plugin"
968 title
=target
.getTitle()
969 WBannerModif
.__init
__(self
, path
, itemType
, title
)
971 class WListingsBannerModif(WBannerModif
):
973 def __init__( self
, conf
, type ):
974 path
=[{"url": urlHandlers
.UHConfModifListings
.getURL(conf
), "title":_("All listings")}]
978 WBannerModif
.__init
__(self
, path
, itemType
, title
)
980 class WParticipantsBannerModif(WBannerModif
):
982 def __init__( self
, conf
):
983 path
=[{"url": urlHandlers
.UHConfModifParticipants
.getURL(conf
), "title":_("Participants list")}]
985 itemType
="Pending participants"
987 WBannerModif
.__init
__(self
, path
, itemType
, title
)
990 class WConfLogsBannerModif(WBannerModif
):
992 def __init__( self
, conf
):
993 path
=[{"url": urlHandlers
.UHConfModifLog
.getURL(conf
), "title":_("Logs")}]
997 WBannerModif
.__init
__(self
, path
, itemType
, title
)
999 class WCategModifHeader(WTemplated
):
1001 def __init__(self
, targetConf
):
1002 self
._conf
= targetConf
1004 def _getSingleCategHTML( self
, categ
, URLGen
):
1006 return """<a href="%s">%s</a>"""%(URLGen( categ
), categ
.getName())
1008 def _getMultipleCategHTML( self
, categList
, URLGen
):
1010 for categ
in self
._conf
.getOwnerList():
1011 l
.append("""<option value="%s">%s</option>"""%(categ
.getId(),\
1013 return i18nformat("""<form action="%s" method="GET">
1014 <select name="categId">%s</select>
1015 <input type="submit" class="btn" value="_("go")">
1016 </form>""")%(URLGen(), "".join(l
))
1018 def getVars( self
):
1020 vars = WTemplated
.getVars( self
)
1021 #raise "%s"%(type(self._conf))
1023 ol
= self
._conf
.getOwnerList()
1027 URLGen
= vars.get("categDisplayURLGen", urlHandlers
.UHCategoryDisplay
.getURL
)
1031 vars["categ"] = self
._getMultipleCategHTML
(ol
, URLGen
)
1033 vars["categ"] = self
._getSingleCategHTML
( ol
[0], URLGen
)
1034 vars["viewImageURL"] = Configuration
.Config
.getInstance().getSystemIconURL( "view" )
1036 vars["categ"] = self
._getSingleCategHTML
( ol
, URLGen
)
1037 vars["viewImageURL"] = Configuration
.Config
.getInstance().getSystemIconURL( "view" )
1042 class WCategoryModificationHeader(WTemplated
):
1045 def __init__( self
, category
):
1046 self
._categ
= category
1048 def getVars( self
):
1049 vars = WTemplated
.getVars( self
)
1051 vars["confTitle"] = self
._categ
.getName()
1052 vars["title"] = self
._categ
.getName()
1053 vars["catDisplayURL"] = urlHandlers
.UHCategoryDisplay
.getURL(self
._categ
)
1054 vars["catModifURL"]= urlHandlers
.UHCategoryModification
.getURL(self
._categ
)
1055 vars["titleTabPixels"] = self
.getTitleTabPixels()
1056 #vars["intermediateVTabPixels"] = self.getIntermediateVTabPixels()
1057 vars["eventCaption"]= "Category"
1060 def getIntermediateVTabPixels( self
):
1063 def getTitleTabPixels( self
):
1066 class WConfModifHeader(WTemplated
):
1068 def __init__( self
, conf
, aw
):
1072 def getVars( self
):
1073 vars = WTemplated
.getVars( self
)
1076 vars["creator"] = self
._conf
.getCreator().getFullName()
1078 vars["creator"] = ""
1079 vars["imgGestionGrey"] = Configuration
.Config
.getInstance().getSystemIconURL( "gestionGrey" )
1080 vars["confTitle"] = escape(self
._conf
.getTitle())
1081 if self
._conf
.canModify( self
._aw
):
1082 URLGen
= vars.get("confModifURLGen", \
1083 urlHandlers
.UHConferenceModification
.getURL
)
1084 vars["confTitle"] = """<a href=%s>%s</a>"""%(quoteattr( str( URLGen( self
._conf
) ) ), escape(self
._conf
.getTitle()) )
1085 URLGen
= vars.get( "confDisplayURLGen", urlHandlers
.UHConferenceDisplay
.getURL
)
1086 vars["confDisplayURL"] = URLGen( self
._conf
)
1087 vars["titleTabPixels"] = WConferenceModifFrame(self
._conf
, self
._aw
).getTitleTabPixels()
1089 type = self
._conf
.getType()
1092 if type == "simple_event":
1094 vars["eventCaption"]=type.capitalize()#"Event"
1100 class WSessionModifHeader(WTemplated
):
1102 def __init__( self
, session
, aw
):
1103 self
._session
= session
1106 def getHTML( self
, params
):
1107 conf
= self
._session
.getConference()
1108 confHTML
= WConfModifHeader( conf
, self
._aw
).getHTML( params
)
1109 return "%s%s"%(confHTML
, WTemplated
.getHTML( self
, params
) )
1111 def getVars( self
):
1112 vars = WTemplated
.getVars( self
)
1113 vars["imgGestionGrey"] = Configuration
.Config
.getInstance().getSystemIconURL( "gestionGrey" )
1114 vars["sessionTitle"] = escape(self
._session
.getTitle())
1115 vars["sessionDisplayURL"] = vars["sessionDisplayURLGen"](self
._session
)
1116 vars["sessionModificationURL"] = vars["sessionModifURLGen"](self
._session
)
1119 class WBreakModifHeader(WTemplated
):
1121 def __init__( self
, breakSlot
, aw
):
1122 self
._break
= breakSlot
1125 def getHTML( self
, params
):
1126 return WTemplated
.getHTML( self
, params
)
1128 def getVars( self
):
1129 vars = WTemplated
.getVars( self
)
1130 vars["imgGestionGrey"] = Configuration
.Config
.getInstance().getSystemIconURL( "gestionGrey" )
1131 vars["breakTitle"] = escape(self
._break
.getTitle())
1135 class WContribModifHeader(WTemplated
):
1137 def __init__( self
, contrib
, aw
):
1138 self
._contrib
= contrib
1141 def getHTML( self
, params
):
1142 conf
= self
._contrib
.getConference()
1143 session
= self
._contrib
.getSession()
1144 if session
is not None:
1145 HTML
= WSessionModifHeader( session
, self
._aw
).getHTML( params
)
1147 HTML
= WConfModifHeader( conf
, self
._aw
).getHTML( params
)
1148 return "%s%s"%(HTML
, WTemplated
.getHTML( self
, params
) )
1150 def getVars( self
):
1151 vars = WTemplated
.getVars( self
)
1152 vars["imgGestionGrey"] = Configuration
.Config
.getInstance().getSystemIconURL( "gestionGrey" )
1153 vars["title"] = escape(self
._contrib
.getTitle())
1154 urlGen
= vars.get( "contribDisplayURLGen", urlHandlers
.UHContributionDisplay
.getURL
)
1155 vars["contribDisplayURL"] = urlGen(self
._contrib
)
1156 urlGen
= vars.get( "contribModifURLGen", urlHandlers
.UHContributionModification
.getURL
)
1157 vars["contribModificationURL"] = urlGen(self
._contrib
)
1161 class WContribModifTool(WTemplated
):
1163 def __init__( self
, contrib
):
1164 self
._contrib
= contrib
1166 def getVars( self
):
1167 vars = WTemplated
.getVars( self
)
1168 vars["deleteIconURL"] = Configuration
.Config
.getInstance().getSystemIconURL("delete")
1169 vars["moveIconURL"] = Configuration
.Config
.getInstance().getSystemIconURL("move")
1174 class WContributionDeletion(object):
1176 def __init__( self
, contribList
):
1177 self
._contribList
= contribList
1179 def getHTML( self
, actionURL
):
1181 for contrib
in self
._contribList
:
1182 l
.append("""<li><i>%s</i></li>"""%contrib
.getTitle())
1183 msg
= i18nformat("""
1184 <font size="+2"> _("Are you sure that you want to DELETE the following contributions"):<ul>%s</ul>?</font><br>
1187 <font color="red"> _("Note that the following changes will result from this deletion"):</font>
1189 <li> _("If the contribution is linked to an abstract"):</li>
1191 <li> _("The link between the abstract and the contribution will be deleted")</li>
1192 <li> _("The status of the abstract will change to 'submitted'")</li>
1193 <li> _("You'll lose the information about when and who accepted the abstract")</li>
1195 <li> _("ALL the existing sub-contributions within the above contribution(s) will also be deleted")</li>
1200 wc
= WConfirmation()
1202 for contrib
in self
._contribList
:
1203 contribIdList
.append( contrib
.getId() )
1204 return wc
.getHTML( msg
, actionURL
, {"selectedCateg": contribIdList
}, \
1205 confirmButtonCaption
="Yes", \
1206 cancelButtonCaption
="No" )
1209 for contrib
in self
._contribList
:
1214 class WContribModifSC(WTemplated
):
1216 def __init__( self
, contrib
):
1217 self
._contrib
= contrib
1218 self
._conf
= self
._contrib
.getConference()
1221 def getSubContItems(self
,SCModifURL
):
1223 scList
= self
._contrib
.getSubContributionList()
1226 selbox
= """<select name="newpos%s" onChange="this.form.oldpos.value='%s';this.form.submit();">""" % (scList
.index(sc
),scList
.index(sc
))
1227 for i
in range(1,len(scList
)+1):
1228 if i
== scList
.index(sc
)+1:
1229 selbox
+= "<option selected value='%s'>%s" % (i
-1,i
)
1231 selbox
+= "<option value='%s'>%s" % (i
-1,i
)
1237 <input type="checkbox" name="selSubContribs" value="%s">
1239 <a href="%s">%s</a>
1241 </tr>"""%(id, selbox
,SCModifURL(sc
), escape(sc
.getTitle())))
1243 <input type="hidden" name="oldpos">
1244 <table align="center">%s
1245 </table>"""%"".join( temp
)
1248 def getVars( self
):
1249 vars = WTemplated
.getVars( self
)
1250 cfg
= Configuration
.Config
.getInstance()
1251 vars["subContList"] = self
.getSubContItems(vars["subContModifURL"])
1252 vars["confId"] = self
._contrib
.getConference().getId()
1253 vars["contribId"] = self
._contrib
.getId()
1254 vars["deleteItemsURL"] = vars["moveSubContribURL"]
1257 ###ness##################################################################################
1258 # def __getSubCategoryItems( self, sl, modifURLGen ):
1261 # id = categ.getId()
1262 # selbox = """<select name="newpos%s" onChange="this.form.oldpos.value='%s';this.form.submit();">""" % (sl.index(categ),sl.index(categ))
1263 # for i in range (1,len(sl)+1):
1264 # if i==sl.index(categ)+1:
1265 # selbox += "<option selected value='%s'>%s" % (i-1,i)
1267 # selbox += "<option value='%s'>%s" % (i-1,i)
1273 # <input type="checkbox" name="selectedCateg" value="%s">
1275 # <a href="%s">%s</a>
1277 # </tr>"""%(id, selbox,modifURLGen( categ ), categ.getName()))
1279 # <input type="hidden" name="oldpos">
1280 # <table align="center">%s
1281 # </table>"""%"".join( temp )
1283 ##ness##############################################################################
1285 class WMaterialModifHeader(WTemplated
):
1287 def __init__( self
, material
, aw
):
1288 self
._mat
= material
1291 def getHTML( self
, params
):
1292 owner
= self
._mat
.getOwner()
1293 if isinstance( owner
, conference
.Contribution
):
1294 HTML
= WContribModifHeader( owner
, self
._aw
).getHTML( params
)
1295 elif isinstance( owner
, conference
.SubContribution
):
1296 HTML
= WSubContribModifHeader( owner
, self
._aw
).getHTML( params
)
1297 elif isinstance( owner
, conference
.Session
):
1298 HTML
= WSessionModifHeader( owner
, self
._aw
).getHTML( params
)
1299 elif isinstance( owner
, conference
.Conference
):
1300 HTML
= WConfModifHeader( owner
, self
._aw
).getHTML( params
)
1301 elif isinstance( owner
, conference
.Category
):
1302 HTML
= WCategoryModificationHeader( owner
).getHTML( params
)
1303 return "%s%s"%(HTML
, WTemplated
.getHTML( self
, params
))
1305 def getVars( self
):
1306 vars = WTemplated
.getVars( self
)
1307 vars["imgGestionGrey"] = Configuration
.Config
.getInstance().getSystemIconURL( "gestionGrey" )
1308 vars["title"] = escape(self
._mat
.getTitle())
1309 vars["materialDisplayURL"] = vars["materialDisplayURLGen"](self
._mat
)
1310 vars["materialModificationURL"] = vars["materialModifURLGen"](self
._mat
)
1311 vars["titleTabPixels"] = WMaterialModifFrame(self
._mat
, self
._aw
).getTitleTabPixels()
1315 class WConferenceModifFrame(WTemplated
):
1317 def __init__( self
, conference
, aw
,):
1318 self
.__conf
= conference
1321 def getHTML( self
, body
, **params
):
1322 params
["body"] = body
1323 return WTemplated
.getHTML( self
, params
)
1325 def getVars( self
):
1326 vars = WTemplated
.getVars( self
)
1328 vars["conf"] = self
.__conf
1329 vars["startDate"] = utils
.formatDateTime(self
.__conf
.getAdjustedStartDate(), format
="d MMM")
1330 vars["endDate"] = utils
.formatDateTime(self
.__conf
.getAdjustedEndDate(), format
="d MMM")
1334 class WCategoryModifFrame(WTemplated
):
1336 def __init__( self
, conference
):
1337 self
.__conf
= conference
1340 def getHTML( self
, body
, **params
):
1341 params
["body"] = body
1342 return WTemplated
.getHTML( self
, params
)
1344 def getVars( self
):
1345 vars = WTemplated
.getVars( self
)
1346 #p = {"categDisplayURLGen": vars["categDisplayURLGen"] }
1347 #vars["context"] = WCategModifHeader(self.__conf).getHTML(p)
1348 vars["creator"] = ""#self.__conf.getCreator().getFullName()
1349 vars["context"] = ""
1350 vars["imgGestionGrey"] = Configuration
.Config
.getInstance().getSystemIconURL( "gestionGrey" )
1351 vars["categDisplayURL"] = vars["categDisplayURLGen"]( self
.__conf
)
1352 vars["title"] = escape(self
.__conf
.getTitle())
1353 vars["titleTabPixels"] = self
.getTitleTabPixels()
1354 vars["intermediateVTabPixels"] = self
.getIntermediateVTabPixels()
1358 def getIntermediateVTabPixels( self
):
1361 def getTitleTabPixels( self
):
1364 def getCloseHeaderTags( self
):
1367 class WNotifTPLModifFrame(WTemplated
):
1369 def __init__(self
, notifTpl
, aw
):
1370 self
._notifTpl
= notifTpl
1373 def getHTML( self
, body
, **params
):
1374 params
["body"] = body
1375 return WTemplated
.getHTML( self
, params
)
1377 def getVars( self
):
1378 vars = WTemplated
.getVars( self
)
1379 conf
= self
._notifTpl
.getConference()
1380 vars["context"] = WConfModifHeader( conf
, self
._aw
).getHTML(vars)
1381 vars["title"] = self
._notifTpl
.getName()
1382 vars["titleTabPixels"] = self
.getTitleTabPixels()
1383 vars["intermediateVTabPixels"] = self
.getIntermediateVTabPixels()
1384 vars["closeHeaderTags"] = self
.getCloseHeaderTags()
1387 def getOwnerComponent( self
):
1388 owner
= self
._notifTpl
.getOwner()
1389 wc
= WConferenceModifFrame(owner
, self
._aw
)
1392 def getIntermediateVTabPixels( self
):
1393 wc
= self
.getOwnerComponent()
1394 return 7 + wc
.getIntermediateVTabPixels()
1396 def getTitleTabPixels( self
):
1397 wc
= self
.getOwnerComponent()
1398 return wc
.getTitleTabPixels() - 7
1400 def getCloseHeaderTags( self
):
1401 wc
= self
.getOwnerComponent()
1402 return "</table></td></tr>" + wc
.getCloseHeaderTags()
1405 class WScheduleContributionModifFrame(WTemplated
):
1407 def __init__( self
, contribution
, aw
, days
, handler
=urlHandlers
.UHContributionModification
):
1408 self
._contrib
= contribution
1409 self
._conf
= self
._contrib
.getConference()
1412 self
._handler
= handler
1414 def getHTML( self
, body
, **params
):
1416 params
["body"] = body
1418 dateList
= [d
.getDate() for d
in self
._days
]
1420 # Keep contributions that happen in the selected day(s)
1424 for c
in self
._conf
.getContributionList():
1425 assert(type(c
.getStartDate()) == datetime
),"Not all dates are present for the contributions!"
1430 for contrib
in self
._conf
.getContributionList():
1431 if contrib
.getStartDate().date() in dateList
:
1433 params
["contribList"] = l
1434 params
["handler"] = self
._handler
1436 return WTemplated
.getHTML( self
, params
)
1438 class WContributionModifFrame(WTemplated
):
1440 def __init__( self
, contribution
, aw
):
1441 self
._contrib
= contribution
1444 def getHTML( self
, body
, **params
):
1445 params
["body"] = body
1446 return WTemplated
.getHTML( self
, params
)
1448 def getVars( self
):
1449 vars = WTemplated
.getVars( self
)
1450 vars["target"] = self
._contrib
1454 class WMaterialModifFrame(WTemplated
):
1456 def __init__( self
, material
, aw
):
1457 self
._material
= material
1460 def getHTML( self
, body
, **params
):
1461 params
["body"] = body
1462 return WTemplated
.getHTML( self
, params
)
1464 def getVars( self
):
1465 closeHeaderTags
= "</table></td></tr>"
1466 vars = WTemplated
.getVars( self
)
1467 vars["imgGestionGrey"] = Config
.getInstance().getSystemIconURL( "gestionGrey" )
1468 owner
= self
._material
.getOwner()
1469 if isinstance(owner
, conference
.Contribution
):
1470 wc
= WContribModifHeader( owner
, self
._aw
)
1471 elif isinstance(owner
, conference
.Session
):
1472 wc
= WSessionModifHeader( owner
, self
._aw
)
1473 elif isinstance(owner
, conference
.SubContribution
):
1474 wc
= WSubContribModifHeader( owner
, self
._aw
)
1475 elif isinstance(owner
, conference
.Category
) :
1476 wc
= WCategoryModificationHeader(owner
)
1478 wc
= WConfModifHeader( owner
, self
._aw
)
1479 vars["context"] = wc
.getHTML( vars )
1480 vars["closeHeaderTags"] = self
.getCloseHeaderTags()
1481 vars["intermediateVTabPixels"] = self
.getIntermediateVTabPixels()
1482 vars["titleTabPixels"] = self
.getTitleTabPixels()
1483 vars["title"] = escape(self
._material
.getTitle())
1484 vars["materialDisplayURL"] = vars["materialDisplayURLGen"]( self
._material
)
1487 def getOwnerComponent( self
):
1488 owner
= self
._material
.getOwner()
1489 if isinstance(owner
, conference
.Contribution
):
1490 wc
= WContributionModifFrame(owner
, self
._aw
)
1491 elif isinstance(owner
, conference
.Session
):
1492 wc
= WSessionModifFrame(owner
, self
._aw
)
1493 elif isinstance(owner
, conference
.SubContribution
):
1494 wc
= WSubContributionModifFrame(owner
, self
._aw
)
1497 wc
= WConferenceModifFrame(owner
, self
._aw
)
1500 def getIntermediateVTabPixels( self
):
1501 wc
= self
.getOwnerComponent()
1502 return 7 + wc
.getIntermediateVTabPixels()
1504 def getTitleTabPixels( self
):
1505 wc
= self
.getOwnerComponent()
1506 return wc
.getTitleTabPixels() - 7
1508 def getCloseHeaderTags( self
):
1509 wc
= self
.getOwnerComponent()
1510 return "</table></td></tr>" + wc
.getCloseHeaderTags()
1513 class WResourceModifFrame(WTemplated
):
1515 def __init__( self
, resource
, aw
):
1516 self
._resource
= resource
1519 def getHTML( self
, body
, **params
):
1520 params
["body"] = body
1521 return WTemplated
.getHTML( self
, params
)
1523 def getVars( self
):
1524 vars = WTemplated
.getVars( self
)
1525 wc
= WMaterialModifHeader( self
._resource
.getOwner(), self
._aw
)
1526 vars["context"] = wc
.getHTML( vars )
1527 vars["name"] = self
._resource
.getName()
1528 vars["intermediateVTabPixels"] = self
.getIntermediateVTabPixels()
1529 vars["titleTabPixels"] = self
.getTitleTabPixels()
1530 vars["closeHeaderTags"] = self
.getCloseHeaderTags()
1533 def getOwnerComponent( self
):
1534 owner
= self
._resource
.getOwner()
1535 wc
= WMaterialModifFrame(owner
, self
._aw
)
1538 def getIntermediateVTabPixels( self
):
1539 wc
= self
.getOwnerComponent()
1540 return 7 + wc
.getIntermediateVTabPixels()
1542 def getTitleTabPixels( self
):
1543 wc
= self
.getOwnerComponent()
1544 return wc
.getTitleTabPixels() - 7
1546 def getCloseHeaderTags( self
):
1547 wc
= self
.getOwnerComponent()
1548 return "</table></td></tr>" + wc
.getCloseHeaderTags()
1551 class WFileModifFrame( WResourceModifFrame
):
1555 class WLinkModifFrame( WResourceModifFrame
):
1560 class ModifFrameFactory
:
1562 def getFrameClass( cls
, target
):
1563 if isinstance(target
, conference
.Conference
):
1564 return WConferenceModifFrame
1565 if isinstance( target
, conference
.Session
):
1566 return WSessionModifFrame
1567 if isinstance( target
, conference
.Contribution
):
1568 return WContributionModifFrame
1569 if isinstance( target
, conference
.SubContribution
):
1570 return WSubContributionModifFrame
1571 if isinstance(target
, conference
.Material
):
1572 return WMaterialModifFrame
1573 if isinstance(target
, conference
.LocalFile
):
1574 return WFileModifFrame
1575 if isinstance( target
, conference
.Link
):
1576 return WLinkModifFrame
1578 getFrameClass
= classmethod( getFrameClass
)
1580 def getModifFrame( target
):
1581 f
= ModifFrameFactory
.getFrameClass( target
)
1585 getModifFrame
= staticmethod( getModifFrame
)
1588 class WSubContributionDisplay
:
1590 def __init__(self
, aw
, subContrib
):
1592 self
._subContrib
= subContrib
1594 def getHTML( self
, params
):
1595 if self
._subContrib
.canAccess( self
._aw
):
1596 c
= WSubContributionDisplayFull( self
._aw
, self
._subContrib
)
1597 return c
.getHTML( params
)
1598 if self
._subContrib
.canView( self
._aw
):
1599 c
= WSubContributionDisplayMin( self
._aw
, self
._subContrib
)
1600 return c
.getHTML( params
)
1603 class WSubContributionDisplayBase(WTemplated
):
1605 def __init__(self
, aw
, subContrib
):
1607 self
._subContrib
= subContrib
1609 def __getHTMLRow( self
, title
, body
):
1610 if body
.strip() == "":
1614 <td valign="top" align="right">
1615 <font size="-1" color="#000060">%s:</font>
1617 <td width="100%%">%s</td>
1618 </tr>"""%(title
, body
)
1621 def getVars( self
):
1622 vars = WTemplated
.getVars( self
)
1623 vars["title"] = self
._subContrib
.getTitle()
1624 vars["description"] = self
._subContrib
.getDescription()
1625 vars["modifyItem"] = ""
1626 if self
._subContrib
.canModify( self
._aw
):
1627 vars["modifyItem"] = """<a href="%s"><img src="%s" alt="Jump to the modification interface"></a> """%(vars["modifyURL"], Configuration
.Config
.getInstance().getSystemIconURL( "modify" ) )
1629 for speaker
in self
._subContrib
.getSpeakerList():
1630 l
.append( """<a href="mailto:%s">%s</a>"""%(speaker
.getEmail(), \
1631 speaker
.getFullName()))
1632 l
.append(self
._subContrib
.getSpeakerText())
1633 vars["speakers"] = self
.__getHTMLRow
( _("Presenters"), "<br>".join( l
) )
1635 for material
in self
._subContrib
.getAllMaterialList():
1636 lm
.append( WMaterialDisplayItem().getHTML( self
._aw
, material
, \
1637 vars["materialURLGen"]( material
) ))
1638 vars["material"] = self
.__getHTMLRow
( "Material", "<br>".join( lm
) )
1639 vars["duration"] = (datetime(1900,1,1)+self
._subContrib
.getDuration()).strftime("%M'")
1640 if int(self
._subContrib
.getDuration().seconds
/3600)>0:
1641 vars["duration"] = (datetime(1900,1,1)+self
._subContrib
.getDuration()).strftime("%Hh%M'")
1645 class WSubContributionDisplayFull(WSubContributionDisplayBase
):
1649 class WSubContributionDisplayMin(WSubContributionDisplayBase
):
1653 class WMaterialDisplayItem(WTemplated
):
1655 def getHTML( self
, aw
, material
, URL
="", icon
=Configuration
.Config
.getInstance().getSystemIconURL( "material" ) ):
1656 if material
.canView( aw
):
1658 return """<a href=%s>%s</a>"""%(quoteattr( str( URL
) ), WTemplated
.htmlText( material
.getTitle() ) )
1662 class WBreakDataModification(WTemplated
):
1664 def __init__(self
,sch
,breakEntry
=None,targetDay
=None,conf
=None):
1665 self
._break
=breakEntry
1666 if self
._break
!=None:
1667 self
._sch
=self
._break
.getSchedule()
1670 self
._targetDay
=targetDay
1673 def getVars( self
):
1674 vars = WTemplated
.getVars( self
)
1675 defaultDefinePlace
= defaultDefineRoom
= ""
1676 defaultInheritPlace
= defaultInheritRoom
= "checked"
1677 locationName
, locationAddress
, roomName
= "", "", ""
1678 if self
._break
is not None:
1679 wpTitle
= _("Break entry data modification")
1680 title
=self
._break
.getTitle()
1681 description
=self
._break
.getDescription()
1682 tz
= self
._conf
.getTimezone()
1683 sDate
=convertTime
.convertTime(self
._break
.getStartDate(),self
._conf
.getTimezone())
1688 sMinute
=sDate
.minute
1689 durHours
=int(self
._break
.getDuration().seconds
/3600)
1690 durMinutes
=int((self
._break
.getDuration().seconds
%3600)/60)
1691 if self
._break
.getOwnLocation() is not None:
1692 defaultDefinePlace
= "checked"
1693 defaultInheritPlace
= ""
1694 locationName
= self
._break
.getLocation().getName()
1695 locationAddress
= self
._break
.getLocation().getAddress()
1696 if self
._break
.getOwnRoom() is not None:
1697 defaultDefineRoom
= "checked"
1698 defaultInheritRoom
= ""
1699 roomName
= self
._break
.getRoom().getName()
1700 bgcolor
=self
._break
.getColor()
1701 textcolor
=self
._break
.getTextColor()
1703 if self
._break
.isTextColorToLinks():
1704 textcolortolinks
="checked=\"checked\""
1705 schOptions
= i18nformat(""" <input type="checkbox" name="moveEntries" value="1"> _("reschedule entries after this time")""")
1707 wpTitle
= "Create new break"
1708 title
, description
= "break", ""
1709 refDate
=self
._sch
.getFirstFreeSlotOnDay(self
._targetDay
)
1711 month
= refDate
.month
1713 sHour
= refDate
.hour
1714 sMinute
= refDate
.minute
1715 durHours
, durMinutes
= 0, 15
1719 textcolortolinks
=False
1720 vars["defaultInheritPlace"] = defaultInheritPlace
1721 vars["defaultDefinePlace"] = defaultDefinePlace
1722 vars["ownerPlace"] = ""
1723 owner
= self
._sch
.getOwner()
1724 vars["ownerType"]="conference"
1725 if isinstance(owner
, conference
.SessionSlot
):
1726 vars["ownerType"]="session"
1727 ownerLocation
= owner
.getLocation()
1729 vars["ownerPlace"] = ownerLocation
.getName()
1730 vars["locationName"] = quoteattr(str(locationName
))
1731 vars["locationAddress"] = locationAddress
1732 vars["defaultInheritRoom"] = defaultInheritRoom
1733 vars["defaultDefineRoom"] = defaultDefineRoom
1734 vars["ownerRoom"] = ""
1735 ownerRoom
=owner
.getRoom()
1737 vars["ownerRoom"] = ownerRoom
.getName()
1738 vars["roomName"] = quoteattr(str(roomName
))
1740 vars["WPtitle"]=wpTitle
1741 vars["title"]=quoteattr(str(title
))
1742 vars["description"]=self
.htmlText(description
)
1743 vars["sDay"]=str(day
)
1744 vars["sMonth"]=str(month
)
1745 vars["sYear"]=str(year
)
1746 vars["sHour"]=str(sHour
)
1747 vars["sMinute"]=str(sMinute
)
1748 vars["durationHours"]=quoteattr(str(durHours
))
1749 vars["durationMinutes"]=quoteattr(str(durMinutes
))
1750 vars["postURL"]=quoteattr(str(vars["postURL"]))
1751 vars["colorChartIcon"]=Config
.getInstance().getSystemIconURL("colorchart")
1752 urlbg
=urlHandlers
.UHSimpleColorChart
.getURL()
1753 urlbg
.addParam("colorCodeTarget", "backgroundColor")
1754 urlbg
.addParam("colorPreviewTarget", "backgroundColorpreview")
1755 vars["bgcolorChartURL"]=urlbg
1756 vars["bgcolor"] = bgcolor
1757 urltext
=urlHandlers
.UHSimpleColorChart
.getURL()
1758 urltext
.addParam("colorCodeTarget", "textColor")
1759 urltext
.addParam("colorPreviewTarget", "textColorpreview")
1760 vars["textcolorChartURL"]=urltext
1761 vars["textcolor"] = textcolor
1762 vars["textColorToLinks"] = textcolortolinks
1763 vars["calendarIconURL"]=Config
.getInstance().getSystemIconURL( "calendar" )
1764 vars["calendarSelectURL"]=urlHandlers
.UHSimpleCalendar
.getURL()
1765 vars["schOptions"]=schOptions
1766 vars["autoUpdate"]=""
1767 import MaKaC
.webinterface
.webFactoryRegistry
as webFactoryRegistry
1768 wr
= webFactoryRegistry
.WebFactoryRegistry()
1769 wf
= wr
.getFactory(self
._conf
)
1774 if type == "conference":
1775 vars["Colors"]=WSessionModEditDataColors().getHTML(vars)
1778 vars["conference"] = self
._conf
1779 minfo
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance()
1780 vars["useRoomBookingModule"] = minfo
.getRoomBookingModuleActive()
1782 vars['rbActive'] = info
.HelperMaKaCInfo
.getMaKaCInfoInstance().getRoomBookingModuleActive()
1786 class WMaterialTable( WTemplated
):
1787 # Deprecated - used in old file management scheme
1789 def __init__(self
, matOwner
, registry
= None ):
1790 self
._owner
= matOwner
1793 def _getAdditionalMaterialItems( self
):
1795 for mat
in self
._owner
.getMaterialList():
1799 <table cellpadding="1" cellspacing="1">
1802 <input type="checkbox" name="deleteMaterial" value="%s">
1805 <img src="%s" style="vertical-align:middle" alt="">
1807 <td align="left"> </td>
1808 <td align="left" width="100%%">
1815 """%(mat
.getId(), Config
.getInstance().getSystemIconURL("material"), self
._modifyURLGen
( mat
), mat
.getTitle() ) )
1818 def _getSpecialMaterialItems( self
):
1822 for factory
in self
._fr
.getList():
1823 if factory
.canDelete( self
._owner
):
1825 if factory
.getIconURL():
1826 icon
= """<img src="%s" style="vertical-align:middle" alt="">"""%factory
.getIconURL()
1827 mat
= factory
.get( self
._owner
)
1829 <td valing="bottom">
1830 <table cellpadding="1" cellspacing="1">
1833 <input type="checkbox" name="deleteMaterial" value="%s">
1838 <td align="left"> </td>
1839 <td align="left" width="100%%">
1846 """%(factory
.getId(), icon
, factory
.getModificationURL( mat
), mat
.getTitle()))
1849 def getHTML( self
, addURL
, removeURL
, modifyURLGen
):
1850 self
._modifyURLGen
= modifyURLGen
1851 params
={"addURL": addURL
, "deleteURL": removeURL
}
1853 hiddenParams
= self
._owner
.getLocator().getWebForm()
1855 return WTemplated
.getHTML( self
, params
)
1857 def getVars( self
):
1858 vars = WTemplated
.getVars( self
)
1859 vars["items"] = "%s%s"%(self
._getSpecialMaterialItems
(), \
1860 self
._getAdditionalMaterialItems
())
1861 vars["locator"] = self
._owner
.getLocator().getWebForm()
1864 for factory
in self
._fr
.getList():
1865 if factory
.canAdd( self
._owner
):
1866 l
.append("""<option value="%s">%s</option>"""%(\
1867 factory
.getId(), factory
.getTitle()))
1868 vars["matTypesSelectItems"] = "".join(l
)
1872 class WAccessControlFrame(WTemplated
):
1874 def getHTML( self
, target
, setVisibilityURL
, type ):
1875 self
.__target
= target
1877 params
= { "setPrivacyURL": setVisibilityURL
,\
1880 return WTemplated
.getHTML( self
, params
)
1882 def getVars( self
):
1883 vars = WTemplated
.getVars( self
)
1885 if self
.__target
.getAccessProtectionLevel() == -1:
1886 vars["privacy"] = "PUBLIC"
1887 vars["statusColor"] = "#128F33"
1888 elif self
.__target
.isItselfProtected():
1889 vars["privacy"] = "PRIVATE"
1890 vars["statusColor"] = "#B02B2C"
1892 vars["privacy"] = "INHERITING"
1893 vars["statusColor"] = "#444444"
1895 vars["isFullyPublic"] = None
1897 if not isinstance(self
.__target
, Category
) :
1898 vars["isFullyPublic"] = self
.__target
.isFullyPublic()
1900 if isinstance(self
.__target
, Category
) and self
.__target
.isRoot():
1901 vars["parentName"] = vars["parentPrivacy"] = vars["parentStatusColor"] = ''
1903 vars["parentName"] = self
.__target
.getOwner().getTitle()
1905 if self
.__target
.hasProtectedOwner():
1906 vars["parentPrivacy"] = "PRIVATE"
1907 vars["parentStatusColor"] = "#B02B2C"
1909 vars["parentPrivacy"] = "PUBLIC"
1910 vars["parentStatusColor"] = "#128F33"
1912 vars["locator"] = self
.__target
.getLocator().getWebForm()
1913 vars["contactInfo"] = self
.__target
.getAccessController().getContactInfo()
1917 class WConfAccessControlFrame(WTemplated
):
1919 def getHTML( self
, target
, setVisibilityURL
, setAccessKeyURL
):
1920 self
.__target
= target
1921 params
= { "target": target
,\
1922 "setPrivacyURL": setVisibilityURL
,\
1923 "setAccessKeyURL": setAccessKeyURL
,\
1925 return WTemplated
.getHTML( self
, params
)
1927 def getVars( self
):
1928 vars = WTemplated
.getVars( self
)
1930 if self
.__target
.getAccessProtectionLevel() == -1:
1931 vars["privacy"] = "PUBLIC"
1932 vars["statusColor"] = "#128F33"
1933 elif self
.__target
.isItselfProtected():
1934 vars["privacy"] = "PRIVATE"
1935 vars["statusColor"] = "#B02B2C"
1937 vars["privacy"] = "INHERITING"
1938 vars["statusColor"] = "#444444"
1940 vars["isFullyPublic"] = self
.__target
.isFullyPublic()
1941 vars["parentName"] = self
.__target
.getOwner().getName()
1943 if self
.__target
.hasProtectedOwner():
1944 vars["parentPrivacy"] = "PRIVATE"
1945 vars["parentStatusColor"] = "#B02B2C"
1947 vars["parentPrivacy"] = "PUBLIC"
1948 vars["parentStatusColor"] = "#128F33"
1950 vars["locator"] = self
.__target
.getLocator().getWebForm()
1951 vars["accessKey"] = self
.__target
.getAccessKey()
1952 vars["contactInfo"] = self
.__target
.getAccessController().getContactInfo()
1956 class WUserTableItem(WTemplated
):
1958 def __init__(self
, multi
=True):
1961 def getHTML( self
, user
, selected
=False, selectable
=True, parentPrincipalTableId
=None ):
1963 self
._selected
= selected
1964 self
._selectable
= selectable
1965 self
._parentPrincipalTableId
= parentPrincipalTableId
1966 return WTemplated
.getHTML( self
, {} )
1968 def getVars( self
):
1969 vars = WTemplated
.getVars( self
)
1971 vars["ParentPrincipalTableId"] = self
._parentPrincipalTableId
1973 vars["avatar"] = fossilize(self
.__user
, IAvatarFossil
)
1975 vars["id"] = self
.__user
.getId()
1976 vars["email"] = self
.__user
.getEmail()
1977 vars["fullName"] = self
.__user
.getFullName()
1979 vars["selectable"] = self
._selectable
1980 vars["inputType"] = "checkbox"
1981 selectionText
= "checked"
1983 vars["inputType"] = "radio"
1984 selectionText
= "selected"
1985 vars["selected"] = ""
1987 vars["selected"] = selectionText
1989 if self
._rh
._getUser
():
1990 vars["currentUserBasket"] = self
._rh
._getUser
().getPersonalInfo().getBasket()
1992 vars["currentUserBasket"] = None
1996 class WPendingUserTableItem(WTemplated
):
1998 def getHTML( self
, email
, selectable
=True ):
2000 self
._selectable
= selectable
2001 return WTemplated
.getHTML( self
, {} )
2003 def getVars( self
):
2004 vars = WTemplated
.getVars( self
)
2005 vars["email"] = self
.email
2006 vars["selectable"] = self
._selectable
2010 class WGroupTableItem(WTemplated
):
2012 def __init__(self
, multi
=True):
2015 def getHTML( self
, group
, selected
=False, selectable
=True ):
2016 self
.__group
= group
2017 self
._selected
= selected
2018 self
._selectable
= selectable
2019 return WTemplated
.getHTML( self
, {} )
2021 def getVars( self
):
2022 vars = WTemplated
.getVars( self
)
2023 vars["groupImg"] = Configuration
.Config
.getInstance().getSystemIconURL("group")
2024 vars["id"] = self
.__group
.getId()
2025 vars["fullName"] = self
.__group
.getName()
2026 vars["type"] = "checkbox"
2027 selectionText
= "checked"
2029 vars["type"] = "radio"
2030 selectionText
= "selected"
2031 vars["selected"] = ""
2033 vars["selected"] = selectionText
2034 vars["selectable"] = self
._selectable
2037 class WGroupNICETableItem(WTemplated
):
2039 def __init__(self
, multi
=True):
2042 def getHTML( self
, group
, selected
=False, selectable
=True ):
2043 self
.__group
= group
2044 self
._selected
= selected
2045 self
._selectable
= selectable
2046 return WTemplated
.getHTML( self
, {} )
2048 def getVars( self
):
2049 vars = WTemplated
.getVars( self
)
2050 vars["id"] = self
.__group
.getId()
2051 vars["fullName"] = self
.__group
.getName()
2052 vars["type"] = "checkbox"
2053 selectionText
= "checked"
2055 vars["type"] = "radio"
2056 selectionText
= "selected"
2057 vars["selected"] = ""
2059 vars["selected"] = selectionText
2060 vars["selectable"] = self
._selectable
2063 class WAuthorTableItem(WTemplated
):
2065 def __init__(self
, multi
=False):
2068 def getHTML( self
, author
, selected
=False ):
2069 self
.__author
= author
2070 self
._selected
= selected
2071 return WTemplated
.getHTML( self
, {} )
2073 def getVars( self
):
2074 vars = WTemplated
.getVars( self
)
2075 vars["id"] = "*author*:%s"%conference
.AuthorIndex()._getKey
(self
.__author
)
2076 vars["fullName"] = self
.__author
.getFullName()
2077 vars["type"] = "checkbox"
2078 selectionText
= "checked"
2080 vars["type"] = "radio"
2081 selectionText
= "selected"
2082 vars["selected"] = ""
2084 vars["selected"] = selectionText
2088 class WPrincipalTable(WTemplated
):
2091 WTemplated
.__init
__(self
)
2092 if not "principalTableCounter" in ContextManager
.get():
2093 ContextManager
.set("principalTableCounter", 0)
2094 self
._principalTableId
= ContextManager
.get("principalTableCounter")
2095 ContextManager
.set("principalTableCounter", self
._principalTableId
+ 1)
2097 def getHTML( self
, principalList
, target
, addPrincipalsURL
, removePrincipalsURL
, pendings
=[], selectable
=True ):
2098 self
.__principalList
= principalList
[:]
2099 self
.__principalList
.sort(utils
.sortPrincipalsByName
)
2100 self
.__pendings
= pendings
2101 self
.__target
= target
2102 self
.__selectable
= selectable
;
2103 return WTemplated
.getHTML( self
, {"addPrincipalsURL": addPrincipalsURL
,\
2104 "removePrincipalsURL": removePrincipalsURL
} )
2106 def getVars( self
):
2107 vars = WTemplated
.getVars( self
)
2108 vars["locator"] = ""
2110 vars["locator"] = self
.__target
.getLocator().getWebForm()
2113 if len(self
.__principalList
) == 1:
2115 for principal
in self
.__principalList
:
2116 if isinstance(principal
, user
.Avatar
):
2117 ul
.append( WUserTableItem().getHTML( principal
, selected
, self
.__selectable
, self
._principalTableId
) )
2118 elif isinstance(principal
, user
.CERNGroup
):
2119 ul
.append( WGroupNICETableItem().getHTML( principal
, selected
, self
.__selectable
) )
2120 elif isinstance(principal
, user
.Group
):
2121 ul
.append( WGroupTableItem().getHTML( principal
, selected
, self
.__selectable
) )
2122 for email
in self
.__pendings
:
2123 ul
.append(WPendingUserTableItem().getHTML(email
, self
.__selectable
))
2124 vars["userItems"] = "".join( ul
)
2128 class WModificationControlFrame(WTemplated
):
2130 def getHTML( self
, target
, addManagersURL
, removeManagersURL
):
2131 self
.__target
= target
2132 params
= { "addManagersURL": addManagersURL
, \
2133 "removeManagersURL": removeManagersURL
}
2134 return WTemplated
.getHTML( self
, params
)
2136 def getVars( self
):
2137 vars = WTemplated
.getVars( self
)
2138 vars["locator"] = self
.__target
.getLocator().getWebForm()
2139 vars["principalTable"] = WPrincipalTable().getHTML( self
.__target
.getManagerList(),
2140 self
.__target
,vars["addManagersURL"],
2141 vars["removeManagersURL"],
2142 pendings
=self
.__target
.getAccessController().getModificationEmail(),
2148 class WConfModificationControlFrame(WTemplated
):
2150 def getHTML( self
, target
, addManagersURL
, removeManagersURL
, setModifKeyURL
):
2151 self
.__target
= target
2152 params
= { "addManagersURL": addManagersURL
, \
2153 "removeManagersURL": removeManagersURL
, \
2154 "setModifKeyURL": setModifKeyURL
,
2156 return WTemplated
.getHTML( self
, params
)
2158 def getVars( self
):
2159 vars = WTemplated
.getVars( self
)
2160 vars["locator"] = self
.__target
.getLocator().getWebForm()
2161 vars["principalTable"] = WPrincipalTable().getHTML( self
.__target
.getManagerList(),
2162 self
.__target
, vars["addManagersURL"],
2163 vars["removeManagersURL"],
2164 pendings
=self
.__target
.getAccessController().getModificationEmail(),
2166 vars["modifKey"] = self
.__target
.getModifKey()
2169 class WConfRegistrarsControlFrame(WTemplated
):
2171 def getHTML(self
, target
, addRegistrarURL
, removeRegistrarURL
):
2172 self
.__target
= target
2174 "addRegistrarURL": addRegistrarURL
,
2175 "removeRegistrarURL": removeRegistrarURL
2177 return WTemplated
.getHTML( self
, params
)
2179 def getVars( self
):
2180 vars = WTemplated
.getVars( self
)
2181 vars["principalTable"] = WPrincipalTable().getHTML( self
.__target
.getRegistrarList(), self
.__target
, vars["addRegistrarURL"], vars["removeRegistrarURL"], selectable
=False)
2185 class WConfProtectionToolsFrame(WTemplated
):
2187 def __init__( self
, target
):
2188 self
._target
= target
2190 def getVars( self
):
2191 vars = WTemplated
.getVars( self
)
2192 vars["grantSubmissionToAllSpeakersURL"] = str(urlHandlers
.UHConfGrantSubmissionToAllSpeakers
.getURL(self
._target
))
2193 vars["removeAllSubmissionRightsURL"] = str(urlHandlers
.UHConfRemoveAllSubmissionRights
.getURL(self
._target
))
2194 vars["grantModificationToAllConvenersURL"] = str(urlHandlers
.UHConfGrantModificationToAllConveners
.getURL(self
._target
))
2197 class WDomainControlFrame(WTemplated
):
2199 def __init__( self
, target
):
2200 self
._target
= target
2202 def getHTML(self
, addURL
, removeURL
):
2203 self
._addURL
= addURL
2204 self
._removeURL
= removeURL
2205 return WTemplated
.getHTML( self
)
2207 def getVars( self
):
2208 vars = WTemplated
.getVars( self
)
2210 for dom
in self
._target
.getDomainList():
2211 l
.append("""<input type="checkbox" name="selectedDomain" value="%s"> %s"""%(dom
.getId(), dom
.getName()))
2212 vars["domains"] = "<br>".join(l
)
2214 for dom
in domain
.DomainHolder().getList():
2215 if dom
not in self
._target
.getDomainList():
2216 l
.append("""<option value="%s">%s</option>"""%(dom
.getId(), dom
.getName()))
2217 vars["domainsToAdd"] = "".join(l
)
2218 vars["removeURL"] = self
._removeURL
2219 vars["addURL"] = self
._addURL
2220 vars["locator"] = self
._target
.getLocator().getWebForm()
2224 class WMaterialDataModificationBase(WTemplated
):
2226 def __init__( self
, material
):
2227 self
._material
= material
2228 self
._owner
= material
.getOwner()
2230 def _setMaterialValues( self
, material
, materialData
):
2231 material
.setTitle( materialData
["title"] )
2232 material
.setDescription( materialData
["description"] )
2233 if "type" in materialData
:
2234 material
.setType( materialData
["type"] )
2236 def _getTypesSelectItems( self
, default
= "misc" ):
2237 definedTypes
= ["misc"]
2239 for type in definedTypes
:
2243 l
.append("""<option value="%s" %s>%s</option>"""%( type, default
, type ))
2248 class WMaterialCreation(WMaterialDataModificationBase
):
2250 def __init__( self
, owner
):
2254 def getVars( self
):
2255 vars = WMaterialDataModificationBase
.getVars( self
)
2257 vars["description"] = ""
2258 vars["types"] = self
._getTypesSelectItems
()
2259 vars["locator"] = self
._owner
.getLocator().getWebForm()
2262 def create( self
, materialData
):
2263 m
= conference
.Material()
2264 self
._setMaterialValues
( m
, materialData
)
2265 self
._owner
.addMaterial( m
)
2268 class WInlineContextHelp(WTemplated
):
2270 def __init__(self
, content
):
2271 self
._content
= content
2273 def getVars( self
):
2274 vars = WTemplated
.getVars( self
)
2275 vars["helpContent"] = self
._content
2276 vars["imgSrc"] = Config
.getInstance().getSystemIconURL( "help" )
2279 #class WPaperDataModification( WMaterialDataModification ):
2282 #class WMaterialModification( WTemplated ):
2284 # def __init__( self, material ):
2285 # self._material = material
2286 # self.__conf = material.getConference()
2287 # self.__session = material.getSession()
2288 # self.__contrib = material.getContribution()
2290 # def getVars( self ):
2291 # vars = WTemplated.getVars( self )
2292 # vars["locator"] = self._material.getLocator().getWebForm()
2293 # vars["confTitle"] = self.__conf.getTitle()
2294 # vars["sessionTitle"] = ""
2295 # if self.__session != None:
2296 # vars["sessionTitle"] = self.__session.getTitle()
2297 # vars["contributionTitle"] = ""
2298 # if self.__contrib != None:
2299 # vars["contributionTitle"] = self.__contrib.getTitle()
2300 # vars["title"] = self._material.getTitle()
2301 # vars["description"] = self._material.getDescription()
2302 # vars["type"] = self._material.getType()
2304 # for res in self._material.getResourceList():
2305 # if res.__class__ is conference.LocalFile:
2306 # l.append( """<li><input type="checkbox" name="removeResources" value="%s"><small>[%s]</small> <b><a href="%s">%s</a></b> (%s) - <small>%s bytes</small></li>"""%(res.getId(), res.getFileType(), vars["modifyFileURLGen"](res), res.getName(), res.getFileName(), strfFileSize( res.getSize() )))
2307 # elif res.__class__ is conference.Link:
2308 # l.append( """<li><input type="checkbox" name="removeResources" value="%s"><b><a href="%s">%s</a></b> (%s)</li>"""%(res.getId(), vars["modifyLinkURLGen"](res), res.getName(), res.getURL()))
2309 # vars["resources"] = "<ol>%s</ol>"%"".join( l )
2310 # vars["accessControlFrame"] = WAccessControlFrame().getHTML(\
2312 # vars["setVisibilityURL"],\
2313 # vars["addAllowedURL"],\
2314 # vars["removeAllowedURL"] )
2315 # if not self._material.isProtected():
2316 # df = WDomainControlFrame( self._material )
2317 # vars["accessControlFrame"] += "<br>%s"%df.getHTML( \
2318 # vars["addDomainURL"], \
2319 # vars["removeDomainURL"] )
2323 #class WResourceSubmission(WTemplated):
2325 # def _setObjects( self, confId, sessionId, contribId, materialId ):
2326 # ch = conference.ConferenceHolder()
2327 # self._conf = ch.getById( confId )
2328 # self._session = self._contrib = self._material = None
2329 # self._matParent = self._conf
2330 # if sessionId != None and sessionId != "":
2331 # self._session = self._conf.getSessionById( sessionId )
2332 # self._matParent = self._session
2333 # if contribId != None and contribId != "":
2334 # self._contrib = self._session.getContributionById( contribId )
2335 # self._matParent = self._contrib
2336 # elif contribId != None and contribId != "":
2337 # self._contrib = self._conf.getContributionById( contribId )
2338 # self._matParent = self._contrib
2339 # if materialId != None and materialId != "":
2340 # self._material = self._matParent.getMaterialById( materialId )
2342 # def getHTML( self, confId, sessionId, contribId, materialId, params ):
2343 # self._setObjects( confId, sessionId, contribId, materialId )
2345 # <form action="%s" method="POST" enctype="multipart/form-data">
2346 # <input type="hidden" name="confId" value="%s">
2347 # <input type="hidden" name="sessionId" value="%s">
2348 # <input type="hidden" name="contribId" value="%s">
2349 # <input type="hidden" name="materialId" value="%s">
2352 # """%(params["postURL"], confId, sessionId, contribId, \
2353 # materialId, WTemplated.getHTML( self, params ) )
2357 #class WFileSubmission(WTemplated):
2359 # def __init__(self, material):
2360 # self.__material = material
2362 # def getHTML( self, params ):
2364 # <form action="%s" method="POST" enctype="multipart/form-data">
2368 # """%(params["postURL"], \
2369 # self.__material.getLocator().getWebForm(),\
2370 # WTemplated.getHTML( self, params ) )
2373 # def submit( self, params ):
2374 # f = conference.LocalFile()
2375 # f.setName( params["title"] )
2376 # f.setDescription( params["description"] )
2377 # f.setFileName( params["fileName"] )
2378 # f.setFilePath( params["filePath"] )
2379 # self.__material.addResource( f )
2383 #class WLinkSubmission(WResourceSubmission):
2385 # def __init__(self, material):
2386 # self.__material = material
2388 # def getHTML( self, params ):
2390 # <form action="%s" method="POST" enctype="multipart/form-data">
2394 # """%(params["postURL"], \
2395 # self.__material.getLocator().getWebForm(),\
2396 # WTemplated.getHTML( self, params ) )
2399 # def submit( self, params ):
2400 # l = conference.Link()
2401 # l.setName( params["title"] )
2402 # l.setDescription( params["description"] )
2403 # l.setURL( params["url"] )
2404 # self.__material.addResource( l )
2408 class WResourceModification(WTemplated
):
2410 def __init__( self
, resource
):
2411 self
._resource
= resource
2412 self
._conf
= resource
.getConference()
2413 self
._session
= resource
.getSession()
2414 self
._contrib
= resource
.getContribution()
2415 self
._material
= resource
.getOwner()
2417 def getVars( self
):
2418 vars = WTemplated
.getVars( self
)
2419 vars["confTitle"] = self
._conf
.getTitle()
2420 vars["sessionTitle"] = ""
2421 if self
._session
!= None:
2422 vars["sessionTitle"] = self
._session
.getTitle()
2423 vars["contributionTitle"] = ""
2424 if self
._contrib
!= None:
2425 vars["contributionTitle"] = self
._contrib
.getTitle()
2426 vars["materialTitle"] = self
._material
.getTitle()
2427 vars["title"] = self
._resource
.getName()
2428 vars["description"] = self
._resource
.getDescription()
2429 vars["accessControlFrame"] = WAccessControlFrame().getHTML(\
2431 vars["setVisibilityURL"],\
2432 vars["addAllowedURL"],\
2433 vars["removeAllowedURL"],\
2434 vars["setAccessKeyURL"], \
2435 vars["setModifKeyURL"] )
2439 class WResourceDataModification(WResourceModification
):
2441 def getHTML(self
, params
):
2443 <form action="%s" method="POST" enctype="multipart/form-data">
2447 """%(params
["postURL"],\
2448 self
._resource
.getLocator().getWebForm(),\
2449 WTemplated
.getHTML( self
, params
) )
2452 def getVars( self
):
2453 vars = WTemplated
.getVars( self
)
2454 vars["title"] = self
._resource
.getName()
2455 vars["description"] = self
._resource
.getDescription()
2459 class WUserRegistration(WTemplated
):
2461 def __init__( self
, av
= None ):
2464 def __defineNewUserVars( self
, vars={} ):
2465 vars["Wtitle"] = _("Creating a new Indico user")
2466 vars["name"] = quoteattr( vars.get("name","") )
2467 vars["surName"] = quoteattr( vars.get("surName","") )
2468 vars["organisation"] = quoteattr( vars.get("organisation","") )
2469 vars["address"] = vars.get("address","")
2470 vars["email"] = quoteattr( vars.get("email","") )
2471 vars["telephone"] = quoteattr( vars.get("telephone","") )
2472 vars["fax"] = quoteattr( vars.get("fax","") )
2473 vars["login"] = quoteattr( vars.get("login","") )
2476 def __defineExistingUserVars( self
, vars={} ):
2478 vars["Wtitle"] = _("Modifying an Indico user")
2479 vars["name"] = quoteattr( u
.getName() )
2480 vars["surName"] = quoteattr( u
.getSurName() )
2481 vars["title"] = quoteattr( u
.getTitle() )
2482 vars["organisation"] = quoteattr( u
.getOrganisations()[0] )
2483 vars["address"] = u
.getAddresses()[0]
2484 vars["email"] = quoteattr( u
.getEmails()[0] )
2485 vars["telephone"] = quoteattr( u
.getTelephones()[0] )
2486 vars["fax"] = quoteattr( u
.getFaxes()[0] )
2489 def getVars( self
):
2490 vars = WTemplated
.getVars( self
)
2491 minfo
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance()
2492 vars["after"] = _("After the submission of your personal data, an email will be sent to you")+".<br>"+ _("You will able to use your account only after you activate it by clicking on the link inside the email.")
2493 if minfo
.getModerateAccountCreation():
2494 vars["after"] = _("The site manager has to accept your account creation request. You will be informed of the decision by email.")+"<br>"
2495 vars["postURL"] = quoteattr( str( vars["postURL"] ) )
2496 if not self
._avatar
:
2497 vars = self
.__defineNewUserVars
( vars )
2498 vars["locator"] = ""
2500 vars = self
.__defineExistingUserVars
( vars )
2501 vars["locator"] = self
._avatar
.getLocator().getWebForm()
2503 #note: there's a reason this line is TitlesRegistry() and not just TitlesRegistry
2504 #methods in TitlesRegistry cannot be classmethods because _items cannot be a class
2505 #attribute because the i18n '_' function doesn't work for class attributes
2506 vars["titleOptions"]=TitlesRegistry().getSelectItemsHTML(vars.get("title",""))
2507 tz
= minfo
.getTimezone()
2508 if vars.get("defaultTZ","") != "":
2509 tz
= vars.get("defaultTZ")
2510 tzmode
= "Event Timezone"
2511 if vars.get("displayTZMode","") != "":
2512 tzmode
= vars.get("displayTZMode")
2513 vars["timezoneOptions"]=TimezoneRegistry
.getShortSelectItemsHTML(tz
)
2514 vars["displayTZModeOptions"]=DisplayTimezoneRegistry
.getSelectItemsHTML(tzmode
)
2515 minfo
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance()
2516 if vars.get("defaultLang","") == "":
2517 vars["defaultLang"] = minfo
.getLang()
2521 class WUserCreated(WTemplated
):
2523 def __init__( self
, av
= None ):
2526 def getVars( self
):
2527 vars = WTemplated
.getVars( self
)
2528 minfo
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance()
2529 vars["however"] = _("However, you will not be able to log into the system until you have activated your new account. To do this please follow the instructions in the mail that we have already sent you")+".<br>"
2530 if minfo
.getModerateAccountCreation():
2531 vars["however"] = _("However, you will not be able to log into the system until the site administrator has accepted your account creation request. You will be notified of the decision by email")+".<br>"
2532 vars["signInURL"] = quoteattr( str( vars["signInURL"] ) )
2533 vars["supportAddr"] = Config
.getInstance().getSupportEmail()
2537 class WUserSendIdentity(WTemplated
):
2539 def __init__( self
, av
= None ):
2542 def getVars( self
):
2543 vars = WTemplated
.getVars( self
)
2544 vars["locator"] = self
._avatar
.getLocator().getWebForm()
2545 vars["name"] = self
._avatar
.getName()
2546 vars["surName"] = self
._avatar
.getSurName()
2547 vars["email"] = self
._avatar
.getEmail()
2548 vars["org"] = self
._avatar
.getOrganisation()
2549 vars["title"] = self
._avatar
.getTitle()
2550 vars["address"] = self
._avatar
.getAddresses()[0]
2551 vars["contactEmail"] = Config
.getInstance().getSupportEmail()
2555 class WUserSearchResultsTable( WTemplated
):
2557 def __init__(self
, multi
=True):
2560 def __getItemClass( self
, principal
):
2561 if principal
.__class
__.__name
__ == "Avatar":
2562 return WUserTableItem
2563 elif isinstance(principal
, user
.CERNGroup
):
2564 return WGroupNICETableItem
2565 elif isinstance(principal
, user
.Group
):
2566 return WGroupTableItem
2567 elif isinstance(principal
,conference
.ContributionParticipation
):
2568 return WAuthorTableItem
2571 def getHTML( self
, resultList
):
2572 self
.__resultList
= resultList
2573 self
.__resultList
.sort(utils
.sortPrincipalsByName
)
2574 return WTemplated
.getHTML( self
, {} )
2576 def getVars( self
):
2577 vars = WTemplated
.getVars( self
)
2580 if len(self
.__resultList
) == 1:
2582 for principal
in self
.__resultList
:
2583 l
.append( self
.__getItemClass
(principal
)(self
._multi
).getHTML( principal
, selected
) )
2585 vars["usersFound"] = "".join( l
)
2587 vars["usersFound"] = i18nformat(""""<br><span class=\"blacktext\"> _("No results for this search")</span>""")
2588 vars["nbResults"] = len(self
.__resultList
)
2592 class WSignIn(WTemplated
):
2594 def getVars( self
):
2595 vars = WTemplated
.getVars( self
)
2596 minfo
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance()
2597 vars["postURL"] = quoteattr( str( vars.get( "postURL", "" ) ) )
2598 vars["returnURL"] = quoteattr( str( vars.get( "returnURL", "" ) ) )
2599 vars["forgotPasswordURL"] = quoteattr( str( vars.get( "forgotPassordURL", "" ) ) )
2600 vars["login"] = quoteattr( vars.get( "login", "" ) )
2601 vars["msg"] = self
.htmlText( vars.get( "msg" ) )
2602 imgIcon
=Configuration
.Config
.getInstance().getSystemIconURL("currentMenuItem")
2603 if Configuration
.Config
.getInstance().getAuthenticatedEnforceSecure():
2604 imgIcon
=imgIcon
.replace("http://", "https://")
2605 imgIcon
= urlHandlers
.setSSLPort( imgIcon
)
2606 vars["itemIcon"] = imgIcon
2607 vars["createAccount"] = ""
2608 if minfo
.getAuthorisedAccountCreation():
2609 vars["createAccount"] = i18nformat("""_("If you don't have an account, you can create one")<a href="%s"> _("here")</a>
2610 """) % (vars["createAccountURL"])
2612 if "Nice" in Configuration
.Config
.getInstance().getAuthenticatorList():
2613 vars["NiceMsg"]= _("Please note you can use your NICE (CERN) account")
2616 class WConfirmation(WTemplated
):
2618 def getHTML( self
, message
, postURL
, passingArgs
, **opts
):
2620 params
["message"] = message
2621 params
["postURL"] = postURL
2623 for arg
in passingArgs
.keys():
2624 if not type( passingArgs
[arg
] ) == types
.ListType
:
2625 passingArgs
[arg
] = [passingArgs
[arg
]]
2626 for value
in passingArgs
[arg
]:
2627 pa
.append("""<input type="hidden" name="%s" value="%s">"""%( arg
, value
))
2628 params
["passingArgs"] = "".join(pa
)
2629 params
["confirmButtonCaption"]=opts
.get("confirmButtonCaption", _("OK"))
2630 params
["cancelButtonCaption"]=opts
.get("cancelButtonCaption", _("Cancel"))
2631 params
["systemIconWarning"] = Configuration
.Config
.getInstance().getSystemIconURL( "warning" )
2632 return WTemplated
.getHTML( self
, params
)
2634 class WDisplayConfirmation(WTemplated
):
2636 def getHTML( self
, message
, postURL
, passingArgs
, **opts
):
2638 params
["message"] = message
2639 params
["postURL"] = postURL
2641 for arg
in passingArgs
.keys():
2642 if not type( passingArgs
[arg
] ) == types
.ListType
:
2643 passingArgs
[arg
] = [passingArgs
[arg
]]
2644 for value
in passingArgs
[arg
]:
2645 pa
.append("""<input type="hidden" name="%s" value="%s">"""%( arg
, value
))
2646 params
["passingArgs"] = "".join(pa
)
2647 params
["confirmButtonCaption"]=opts
.get("confirmButtonCaption", _("OK"))
2648 params
["cancelButtonCaption"]=opts
.get("cancelButtonCaption", _("Cancel"))
2649 params
["systemIconWarning"] = Configuration
.Config
.getInstance().getSystemIconURL( "warning" )
2650 return WTemplated
.getHTML( self
, params
)
2652 class SideMenu(object):
2653 def __init__(self
, userStatus
=False):
2655 userStatus: a boolean that is True if the user is logged in, False otherwise
2658 self
._userStatus
= userStatus
2660 def addSection(self
, section
, top
=False):
2662 self
._sections
.insert(0, section
)
2664 self
._sections
.append(section
)
2666 def getSections(self
):
2667 return self
._sections
2669 class ManagementSideMenu(SideMenu
):
2672 return WSideMenu(self
, self
._userStatus
, type="management").getHTML()
2674 class BasicSideMenu(SideMenu
):
2677 return WSideMenu(self
, self
._userStatus
, type="basic").getHTML()
2679 class SideMenuSection
:
2683 def __init__(self
, title
=None, active
=False, currentPage
= None, visible
=True):
2684 """ -title is the words that will be displayed int he side menu.
2685 -active is True if ...
2686 -currentPage stores information about in which page we are seeing the Side Menu. For example,
2687 its values can be "category" or "admin".
2690 self
._active
= active
2691 self
._currentPage
= currentPage
2693 self
._visible
= visible
2701 def addItem(self
, item
):
2702 self
._items
.append(item
)
2703 item
.setSection(self
)
2708 def setActive(self
, val
):
2711 def checkActive(self
):
2713 self
._active
= False
2715 for item
in self
._items
:
2720 def getCurrentPage(self
):
2721 return self
._currentPage
2723 def setCurrentPage(self
, currentPage
):
2724 self
._currentPage
= currentPage
2726 def isVisible(self
):
2727 return self
._visible
2729 def setVisible(self
, visible
):
2730 self
._visible
= visible
2732 def hasVisibleItems(self
):
2733 for item
in self
._items
:
2734 if item
.isVisible():
2740 def __init__(self
, title
, url
, active
=False, enabled
=True, errorMessage
= "msgNoPermissions", visible
=True):
2741 """ errorMessage: one of the error messages in SideMenu.wohl
2745 self
._active
= active
2746 self
._enabled
= enabled
2747 self
._errorMessage
= errorMessage
2748 self
._visible
= visible
2753 def setSection(self
, section
):
2754 self
._section
= section
2759 def setURL(self
, url
):
2765 def isEnabled(self
):
2766 return self
._enabled
2768 def getErrorMessage(self
):
2769 return self
._errorMessage
2771 def setActive(self
, val
=True):
2773 self
._section
.checkActive()
2775 def setEnabled(self
, val
):
2778 def setErrorMessage(self
, val
):
2779 self
._errorMessage
= val
2781 def isVisible(self
):
2782 return self
._visible
2784 def setVisible(self
, visible
):
2785 self
._visible
= visible
2787 class WSideMenu(WTemplated
):
2789 def __init__(self
, menu
, loggedIn
, type="basic"):
2791 type can be: basic (display interface) or management (management interface).
2796 # is the user logged in? used for changing some tooltips
2797 self
._loggedIn
= loggedIn
2800 vars = WTemplated
.getVars(self
)
2802 vars['menu'] = self
._menu
2803 vars['loggedIn'] = self
._loggedIn
2804 vars['sideMenuType'] = self
._type
2807 class WebToolBar(object):
2809 def __init__( self
, caption
="" ):
2810 self
.caption
= caption
2812 self
.currentItem
= None
2814 def getCaption( self
):
2817 def addItem( self
, newItem
):
2818 if newItem
not in self
.items
:
2819 self
.items
.append( newItem
)
2820 newItem
.setOwner( self
)
2822 def removeItem( self
, item
):
2823 if item
in self
.items
:
2824 if self
.isCurrent( item
):
2825 self
.setCurrentItem( None )
2826 self
.items
.remove( item
)
2828 def getItemList( self
):
2831 def isCurrent( self
, item
):
2832 return self
.currentItem
== item
2834 def setCurrentItem( self
, item
):
2835 self
.currentItem
= item
2837 def isFirstItem( self
, item
):
2838 return self
.items
[0] == item
2840 def isLastItem( self
, item
):
2841 return self
.items
[len(self
.items
)-1] == item
2843 def getHTML( self
):
2844 return WTBDrawer(self
).getHTML()
2849 def __init__( self
, caption
, **args
):
2851 self
.caption
= caption
2852 self
.icon
= args
.get("icon", "")
2853 self
.actionURL
= args
.get("actionURL", "")
2854 self
.enabled
= args
.get("enabled", 1)
2857 def getCaption(self
):
2860 def getIcon( self
):
2863 def getActionURL( self
):
2864 return self
.actionURL
2866 def setActionURL( self
, URL
):
2867 self
.actionURL
= URL
2868 #self.actionURL = URL.strip()
2870 def setCurrent( self
):
2871 self
.owner
.setCurrentItem( self
)
2873 def isCurrent( self
):
2874 return self
.owner
.isCurrent( self
)
2879 def disable( self
):
2882 def isEnabled( self
):
2885 def hasIcon( self
):
2886 return self
.icon
!= ""
2888 def addItem( self
, newItem
):
2889 if newItem
not in self
.subItems
:
2890 self
.subItems
.append( newItem
)
2891 newItem
.setOwner( self
.owner
)
2893 def removeItem( self
, item
):
2894 if item
in self
.subItems
:
2895 self
.subItems
.remove( item
)
2897 def getItemList( self
):
2898 return self
.subItems
2900 def isFirstItem( self
, item
):
2901 return self
.subItems
[0] == item
2903 def isLastItem( self
, item
):
2904 i
= len(self
.subItems
)-1
2905 while not self
.subItems
[i
].isEnabled():
2907 return self
.subItems
[i
] == item
2909 def setOwner( self
, owner
):
2911 for item
in self
.getItemList():
2912 item
.setOwner( self
.owner
)
2915 class WTBSeparator(WTBItem
):
2917 def __init__( self
):
2918 WTBItem
.__init
__(self
, "")
2920 def setCurrent( self
):
2923 class WTBGroup( WTBItem
):
2925 def __init__( self
, caption
, **args
):
2926 WTBItem
.__init
__( self
, caption
, **args
)
2929 def addItem( self
, newItem
):
2930 if newItem
not in self
.items
:
2931 self
.items
.append( newItem
)
2932 newItem
.setOwner( self
.owner
)
2934 def removeItem( self
, item
):
2935 if item
in self
.items
:
2936 self
.items
.remove( item
)
2938 def getItemList( self
):
2941 def isFirstItem( self
, item
):
2942 return self
.items
[0] == item
2944 def isLastItem( self
, item
):
2945 i
= len(self
.items
)-1
2946 while not self
.items
[i
].isEnabled():
2948 return self
.items
[i
] == item
2950 def setOwner( self
, owner
):
2952 for item
in self
.getItemList():
2953 item
.setOwner( self
.owner
)
2955 class WTBSection( WTBItem
):
2957 def __init__( self
, caption
, **args
):
2958 WTBItem
.__init
__( self
, caption
, **args
)
2962 def addItem( self
, newItem
):
2963 if newItem
not in self
.items
:
2964 self
.items
.append( newItem
)
2965 newItem
.setOwner( self
.owner
)
2967 def removeItem( self
, item
):
2968 if item
in self
.items
:
2969 self
.items
.remove( item
)
2971 def getItemList( self
):
2974 def isFirstItem( self
, item
):
2975 return self
.items
[0] == item
2977 def isLastItem( self
, item
):
2978 i
= len(self
.items
)-1
2979 while not self
.items
[i
].isEnabled():
2981 return self
.items
[i
] == item
2983 def setOwner( self
, owner
):
2985 for item
in self
.getItemList():
2986 item
.setOwner( self
.owner
)
2988 def setDrawer( self
, d
):
2989 self
.drawer
= d(self
)
2991 def getDrawer( self
):
2994 def hasDrawer( self
):
2995 return self
.drawer
!= None
2998 def __init__( self
, toolbar
):
2999 self
.toolbar
= toolbar
3001 def getHTML( self
):
3003 for item
in self
.toolbar
.getItemList():
3004 if not item
.isEnabled():
3006 if isinstance(item
, WTBSection
) and item
.hasDrawer():
3007 drawer
= item
.getDrawer()
3008 elif isinstance(item
, WTBSection
) and not item
.hasDrawer():
3009 drawer
= WStdSectionDrawer(item
)
3011 drawer
= WStdTBDrawer(item
)
3012 l
.append(drawer
.getHTML())
3015 class WStdTBDrawer(WTemplated
):
3017 def __init__( self
, item
):
3020 def _getTBItemCaption( self
, item
):
3022 <td colspan="2" class="menutitle">%s</td>
3023 </tr>"""%item
.getCaption()
3025 def _getTBItemHTML( self
, item
):
3026 str = """%s"""%(item
.getCaption() )
3027 if item
.getActionURL() != "":
3028 str = """<a href="%s">%s</a>"""%(item
.getActionURL(), \
3032 def _getCurrentIconHTML( self
, style
):
3033 return """<td class="%s"> <img src="%s"\
3034 style="vertical-align:middle" alt=""></td>"""%(style
,\
3035 Configuration
.Config
.getInstance().getSystemIconURL("arrowLeft"))
3037 def _getIconHTML( self
, item
, style
):
3038 return """<td class="%s"> <img src="%s" alt="" hspace="3" vspace="2">
3039 </td>"""%(style
, item
.getIcon())
3041 def _getSectionItemsHTML( self
, group
):
3043 for gItem
in section
.getItemList():
3044 if not gItem
.isEnabled():
3046 style
= self
._getStyleForItem
(gItem
, section
)
3048 <td><table cellspacing="0" cellpadding="0" width="100%%">
3049 <tr>%s<td class="%s" width="100%%">%s</td>
3051 </tr>"""%(self
._getCurrentIconForItem
(gItem
, style
),\
3053 self
._getTBItemHTML
(gItem
)))
3054 return """<table cellspacing="0" cellpadding="0" width="100%%">
3056 </table>"""%("".join(lg
))
3058 def _getCurrentIconForItem( self
, item
, style
):
3059 if item
.isCurrent():
3060 return self
._getCurrentIconHTML
(style
)
3061 elif item
.hasIcon():
3062 return self
._getIconHTML
(item
, style
)
3065 def _getStyleForItem( self
, item
, list ):
3066 if item
.isCurrent():
3067 return "menuselectedcell"
3068 elif list.isFirstItem(item
):
3069 return "menutopcell"
3070 elif item
.getItemList():
3071 return "menumiddlecell"
3072 elif list.isLastItem(item
):
3073 return "menubottomcell"
3075 return "menumiddlecell"
3078 def getVars( self
):
3079 vars = WTemplated
.getVars( self
)
3082 if self
.item
!= None:
3083 for tbItem
in self
.item
.getItemList():
3084 if not tbItem
.isEnabled():
3088 if tbItem
.__class
__ == WTBSeparator
:
3090 elif tbItem
.__class
__ == WTBSection
:
3091 sectionItemsHTML
= self
._getSectionItemsHTML
( tbItem
)
3092 l
.append(self
._getTBItemCaption
())
3093 l
.append("""<tr><td colspan="2">%s</td>
3094 </tr>"""%(sectionItemsHTML) )
3096 itemHTML
= self
._getTBItemHTML
( tbItem
)
3097 style
= self
._getStyleForItem
(tbItem
, self
.item
)
3098 l
.append( """<tr><td colspan="2">
3099 <table cellspacing="0" cellpadding="0" width="100%%">
3100 <tr>%s<td class="%s" width="100%%">%s</td></tr></table>
3101 </td></tr>"""%(self
._getCurrentIconForItem
(tbItem
,style
),\
3103 vars["items"] = "".join(l
)
3107 class WStdSectionDrawer(WStdTBDrawer
):
3109 def __init__( self
, item
):
3112 def getVars( self
):
3113 vars = WTemplated
.getVars( self
)
3115 l
.append(self
._getTBItemCaption
(self
.section
))
3116 if self
.section
!= None:
3117 for tbItem
in self
.section
.getItemList():
3118 if not tbItem
.isEnabled():
3121 if tbItem
.__class
__ == WTBSeparator
:
3124 itemHTML
= self
._getTBItemHTML
( tbItem
)
3125 style
= self
._getStyleForItem
(tbItem
, self
.section
)
3126 l
.append( """<tr><td colspan="2">
3127 <table cellspacing="0" cellpadding="0" width="100%%">
3128 <tr>%s<td class="%s" width="100%%">%s</td></tr></table>
3129 </td></tr>"""%(self
._getCurrentIconForItem
(tbItem
,style
),\
3131 for subitem
in tbItem
.getItemList():
3132 if not subitem
.isEnabled():
3134 styleSubitem
= self
._getStyleForItem
(subitem
, self
.section
)
3135 if subitem
.isCurrent():
3136 subitemHTML
= self
._getTBItemHTML
( subitem
)
3137 l
.append("""<tr><td colspan="2">
3138 <table cellspacing="0" cellpadding="0" width="100%%">
3139 <tr><td class="%s"> </td>%s<td class="%s" width="100%%">\
3140 <span style="font-size:11px">%s</span></td></tr></table></td></tr>"""%(styleSubitem
,\
3141 self
._getCurrentIconForItem
(subitem
,styleSubitem
),styleSubitem
, subitemHTML
))
3143 styleSubitem
= "menuConfMiddleCell"
3144 if self
.section
.isLastItem(tbItem
) and tbItem
.isLastItem(subitem
):
3145 styleSubitem
= "menuConfBottomCell"
3146 l
.append( """<tr><td class="%s" nowrap> <a class="confSubSection" href="%s">\
3147 <img src="%s" alt=""> %s</a></td></tr>\
3148 """%(styleSubitem
, subitem
.getActionURL(), subitem
.getIcon(), subitem
.getCaption()))
3149 vars["items"] = "".join(l
)
3153 class WAddEventSectionDrawer(WStdSectionDrawer
):
3155 def __init__( self
, item
):
3158 def _getTBItemHTML( self
, item
):
3159 str = """<span class="menuadd">%s</span>"""%(item
.getCaption() )
3160 if item
.getActionURL() != "":
3161 str = """<a class="menuaddlink" href="%s">%s
3162 </a>"""%(item
.getActionURL(), \
3166 def _getCurrentIconForItem( self
, item
, style
):
3168 return self
._getIconHTML
(item
, style
)
3171 def _getStyleForItem( self
):
3174 def getVars( self
):
3175 vars = WTemplated
.getVars( self
)
3177 l
.append(self
._getTBItemCaption
(self
.section
))
3178 if self
.section
!= None:
3179 for tbItem
in self
.section
.getItemList():
3180 if not tbItem
.isEnabled():
3183 if tbItem
.__class
__ == WTBSeparator
:
3186 itemHTML
= self
._getTBItemHTML
( tbItem
)
3187 style
= self
._getStyleForItem
()
3188 l
.append( """<tr><td class="%s" colspan="2">
3189 <table cellspacing="0" cellpadding="0" width="100%%">
3190 <tr>%s<td class="%s" width="100%%">%s</td></tr></table>
3191 </td></tr>"""%(WStdSectionDrawer
._getStyleForItem
(self
,tbItem
, self
.section
),self
._getCurrentIconForItem
(tbItem
,style
), style
, itemHTML
))
3192 vars["items"] = "".join(l
)
3196 class WConferenceListEvents(WTemplated
):
3198 def __init__( self
, items
, aw
):
3202 def getVars( self
):
3203 vars = WTemplated
.getVars( self
)
3204 vars["items"] = self
._items
3205 vars["conferenceDisplayURLGen"] = urlHandlers
.UHConferenceDisplay
.getURL
3206 vars["aw"] = self
._aw
3209 class WConferenceListItem(WTemplated
):
3210 def __init__(self
, event
, aw
):
3214 def getVars( self
):
3215 vars = WTemplated
.getVars( self
)
3216 vars["lItem"] = self
._event
3217 vars["conferenceDisplayURLGen"] = urlHandlers
.UHConferenceDisplay
.getURL
3218 vars["aw"] = self
._aw
3221 class WEmptyCategory(WTemplated
):
3223 def __init__(self
, materialList
):
3224 self
._materialList
= materialList
3228 vars["material"] = self
._materialList
3232 class WConferenceList(WTemplated
):
3234 def __init__( self
, category
, wfRegm
, showPastEvents
):
3235 self
._categ
= category
3236 self
._showPastEvents
= showPastEvents
3238 def getHTML( self
, aw
, params
):
3240 return WTemplated
.getHTML( self
, params
)
3242 def getEventTimeline(self
, tz
):
3243 index
= Catalog
.getIdx('categ_conf_sd').getCategory(self
._categ
.getId())
3244 today
= nowutc().astimezone(timezone(tz
)).replace(hour
=0, minute
=0, second
=0)
3245 thisMonth
= nowutc().astimezone(timezone(tz
)).replace(hour
=0, minute
=0, second
=0, day
=1)
3246 thisMonthTS
= utc_timestamp(thisMonth
)
3247 nextMonthTS
= utc_timestamp(thisMonth
.replace(month
= (thisMonth
.month
% 12) + 1))
3248 todayTS
= utc_timestamp(thisMonth
)
3249 oneMonthTS
= utc_timestamp((today
- timedelta(days
=30)).replace(day
=1))
3253 for ts
, conf
in index
.iteritems(thisMonthTS
):
3254 if ts
< nextMonthTS
or len(present
) < OPTIMAL_PRESENT_EVENTS
:
3255 present
.append(conf
)
3259 if len(present
) < MIN_PRESENT_EVENTS
:
3260 present
= list(index
.values(oneMonthTS
, thisMonthTS
)) + present
3263 maxDT
= timezone('UTC').localize(datetime
.utcfromtimestamp(index
.maxKey())).astimezone(timezone(tz
))
3264 prevMonthTS
= utc_timestamp(maxDT
.replace(day
=1))
3265 present
= index
.values(prevMonthTS
)
3266 numPast
= self
._categ
.getNumConferences() - len(present
) - len(future
)
3267 return present
, future
, len(future
), numPast
3269 def getVars( self
):
3270 vars = WTemplated
.getVars( self
)
3271 displayTZ
= DisplayTZ(self
._aw
, self
._categ
, useServerTZ
=1).getDisplayTZ()
3272 vars["ActiveTimezone"] = displayTZ
3273 vars["presentItems"], vars["futureItems"], vars["numOfEventsInTheFuture"], vars["numOfEventsInThePast"] = self
.getEventTimeline(displayTZ
)
3274 vars["categ"] = self
._categ
3276 vars["showPastEvents"] = self
._showPastEvents
3281 class WCategoryList(WTemplated
):
3283 def __init__( self
, categ
):
3285 self
._list
= categ
.getSubCategoryList()
3287 def getHTML( self
, aw
, params
):
3289 return WTemplated
.getHTML( self
, params
)
3291 def getVars( self
):
3293 vars = WTemplated
.getVars( self
)
3294 vars["items"] = self
._list
3295 vars["categ"] = self
._categ
;
3299 class WCategoryStatisticsListRow(WTemplated
):
3301 def __init__( self
, year
, percent
, number
):
3303 self
._percent
= percent
3304 self
._number
= number
3306 def getHTML( self
, aw
):
3308 return WTemplated
.getHTML( self
)
3310 def getVars( self
):
3311 vars = WTemplated
.getVars( self
)
3312 vars["year"] = self
._year
3313 vars["percent"] = self
._percent
3314 vars["percentCompl"] = 100-self
._percent
3315 vars["number"] = self
._number
3319 class WCategoryStatisticsList(WTemplated
):
3321 def __init__( self
, statsName
, stats
):
3323 self
._statsName
= statsName
3325 def getHTML( self
, aw
):
3327 return WTemplated
.getHTML( self
)
3329 def getVars( self
):
3330 vars = WTemplated
.getVars( self
)
3331 # Construction of the tables from the dictionary (stats).
3336 years
= self
._stats
.keys()
3338 for y
in range(years
[0], min(datetime
.now().year
+ 4, years
[-1] + 1)):
3339 stats
[y
] = self
._stats
.get(y
,0)
3340 maximum
= max(stats
.values())
3341 years
= stats
.keys()
3345 percent
= (nb
*100)/maximum
3346 if nb
> 0 and percent
== 0:
3348 wcslr
= WCategoryStatisticsListRow( y
, percent
, stats
[y
] )
3349 tmp
.append(wcslr
.getHTML( self
._aw
))
3350 vars["statsName"] = self
._statsName
3351 vars["statsRows"] = "".join( tmp
)
3352 vars["total"] = sum(stats
.values())
3355 class WConfCreationControlFrame(WTemplated
):
3357 def __init__( self
, categ
):
3360 def getVars( self
):
3361 vars = WTemplated
.getVars( self
)
3362 vars["locator"] = self
._categ
.getLocator().getWebForm()
3363 vars["status"] = _("OPENED")
3364 vars["changeStatus"] = i18nformat("""( <input type="submit" class="btn" name="RESTRICT" value="_("RESTRICT it")"> )""")
3365 if self
._categ
.isConferenceCreationRestricted():
3366 vars["status"] = _("RESTRICTED")
3367 vars["changeStatus"] = i18nformat("""( <input type="submit" class="btn" name="OPEN" value="_("OPEN it")"> )""")
3368 vars["principalTable"] = WPrincipalTable().getHTML( self
._categ
.getConferenceCreatorList(), self
._categ
, vars["addCreatorsURL"], vars["removeCreatorsURL"], selectable
=False )
3369 vars["notifyCreationList"] = quoteattr(self
._categ
.getNotifyCreationList())
3370 vars["setNotifyCreationURL"] = urlHandlers
.UHCategorySetNotifyCreation
.getURL(self
._categ
)
3373 class WMinutesDisplay(WTemplated
):
3375 def __init__( self
, target
):
3376 self
._target
= target
3378 def getVars( self
):
3379 vars = WTemplated
.getVars( self
)
3380 vars["text"] = self
.textToHTML(self
._target
.readBin())
3385 def __init__( self
, parent
=None, child
=None ):
3388 self
._default
= None
3389 # Parent element (another tabcontrol),
3390 # in case there is nesting
3391 self
._parent
= parent
3394 parent
.setChild(self
);
3397 def _addTab( self
, tab
):
3398 self
._tabs
.append( tab
)
3399 if len( self
._tabs
) == 1:
3403 def newTab( self
, id, caption
, url
, hidden
=False ):
3404 tab
= Tab( self
, id, caption
, url
, hidden
=hidden
)
3408 def setDefaultTab( self
, tab
):
3409 if tab
in self
._tabs
:
3412 def getDefaultTab( self
):
3413 return self
._default
3415 def setActiveTab( self
, tab
):
3416 if tab
in self
._tabs
:
3419 def getActiveTab( self
):
3422 def getTabList( self
):
3425 def getTabById( self
, id ):
3426 for tab
in self
.getTabList():
3427 if tab
.getId() == id:
3431 def getParent( self
):
3432 # retrieve parent TabControl
3435 def setChild( self
, child
):
3438 def getChild( self
):
3439 # retrieve child TabControl
3442 def getLevel( self
):
3443 tmp
= self
.getParent()
3447 tmp
= tmp
.getParent()
3452 def __init__( self
, owner
, id, caption
, URL
, hidden
= False ):
3454 self
._id
= id.strip()
3455 self
._caption
= caption
.strip()
3457 self
._enabled
= True
3458 self
._subtabControl
=None
3459 self
._hidden
= hidden
3464 def getCaption( self
):
3465 return self
._caption
3467 def setCaption( self
, cp
):
3473 def setDefault( self
):
3474 self
._owner
.setDefaultTab( self
)
3476 def isDefault( self
):
3477 return self
._owner
.getDefaultTab() == self
3479 def isActive( self
):
3480 return self
._owner
.getActiveTab() == self
3482 def setActive( self
):
3483 self
._owner
.setActiveTab( self
)
3486 self
._enabled
= True
3488 def disable( self
):
3489 self
._enabled
= False
3491 def setEnabled(self
,value
):
3494 def isEnabled( self
):
3495 return self
._enabled
3497 def setHidden(self
, value
):
3498 self
._hidden
= value
3500 def isHidden( self
):
3503 def getSubTabControl(self
):
3504 return self
._subtabControl
3506 def newSubTab( self
, id, caption
, url
):
3507 # guarantee that a subtabControl exists
3508 if not self
._subtabControl
:
3509 self
._subtabControl
= TabControl(parent
=self
._owner
)
3511 tab
=self
._subtabControl
.newTab( id, caption
, url
)
3514 def hasChildren(self
):
3515 return self
._subtabControl
is not None
3518 #class WTrackModifSubTrack( WTemplated ):
3520 # def __init__( self, track ):
3521 # self.__track = track
3522 # self.__conf = track.getConference()
3524 # def getVars( self ):
3525 # vars = WTemplated.getVars(self)
3526 # if len(self.__track.getSubTrackList()) == 0:
3527 # ht = "No sub track defined"
3529 # ht = "<table width=\"100%%\">\n"
3530 # for subTrack in self.__track.getSubTrackList():
3531 # ht += "<tr bgcolor=\"#AAFFAA\"><td><input type=\"checkbox\" name=\"selSubTracks\" value=\"%s\"></td><td><a href=\"%s\">%s</a></td><td>%s</td></tr>\n"%(subTrack.getId(), vars["dataModificationURLGen"](subTrack) , subTrack.getTitle(), subTrack.getDescription())
3532 # ht += "</table>\n"
3533 # vars["listSubTrack"] = ht
3537 #class WSubTrackDataModification(WTemplated):
3539 # def __init__( self, subTrack ):
3540 # self.__subTrack = subTrack
3541 # self.__track = subTrack.getTrack()
3543 # def getVars( self ):
3544 # vars = WTemplated.getVars(self)
3546 # vars["title"] = self.__subTrack.getTitle()
3547 # vars["description"] = self.__subTrack.getDescription()
3549 # vars["locator"] = self.__subTrack.getLocator().getWebForm()
3553 #class WCFAModifFrame(WTemplated):
3555 # def __init__( self, conf, aw):
3556 # self.__conf = conf
3559 # def getHTML( self, body, **params):
3560 # params["body"] = body
3561 # return WTemplated.getHTML( self, params )
3563 # def getVars( self ):
3564 # vars = WTemplated.getVars( self )
3566 # vars["context"] = WConfModifHeader( self.__conf, self._aw ).getHTML(vars)
3571 #class WCFAModifMain(WTemplated):
3573 # def __init__( self, conf ):
3574 # self.__conf = conf
3576 # def getVars( self ):
3577 # vars = WTemplated.getVars( self )
3578 # abMgr = self.__conf.getAbstractMgr()
3580 # vars["startDate"] = abMgr.getStartSubmissionDate().strftime("%A %d %B %Y")
3581 # vars["endDate"] = abMgr.getEndSubmissionDate().strftime("%A %d %B %Y")
3584 # for type in self._conf.getContribTypeList():
3585 # typeList += "<input type=\"checkbox\" name=\"types\" value=\"%s\">%s<br>\n"%(type.getId(), type.getName())
3586 # vars["typeList"] = typeList
3590 #class WCFARefereeList(WTemplated):
3592 # def __init__( self, conf ):
3593 # self.__conf = conf
3595 # def getVars( self ):
3596 # vars = WTemplated.getVars(self)
3597 # vars["refereeTable"] = "%s"%WPrincipalTable().getHTML( self.__conf.getAbstractMgr().getRefereeList(), self.__conf, vars["addRefereeURL"], vars["removeRefereeURL"] )
3600 class WTabControl(WTemplated
):
3601 def __init__(self
, ctrl
, accessWrapper
, **params
):
3602 self
._tabCtrl
= ctrl
3603 self
._aw
= accessWrapper
3607 for tab
in self
._tabCtrl
.getTabList():
3608 if not tab
.isEnabled() or tab
.isHidden():
3610 tabs
.append((tab
.getCaption(), tab
.getURL(), tab
.isActive()))
3613 def _getActiveTabId(self
):
3615 for i
, tab
in enumerate(self
._tabCtrl
.getTabList()):
3616 if not tab
.isEnabled() or tab
.isHidden():
3622 def _getActiveTab(self
):
3623 for tab
in self
._tabCtrl
.getTabList():
3628 tab
= self
._getActiveTab
()
3631 sub
= tab
.getSubTabControl()
3634 return WTabControl(sub
, self
._aw
).getHTML(self
._body
)
3636 def getHTML(self
, body
):
3638 return WTemplated
.getHTML(self
)
3640 def getVars( self
):
3641 vars = WTemplated
.getVars(self
)
3642 vars['body'] = self
._getBody
()
3643 vars['tabs'] = self
._getTabs
()
3644 vars['activeTab'] = self
._getActiveTabId
()
3645 vars['tabControlId'] = id(self
)
3649 #class WAbstractFilterCtrl( WTemplated ):
3651 # def __init__(self, conf, filter, sorter):
3652 # self._filter = filter
3654 # self._sorter = sorter
3656 # def getVars( self ):
3657 # vars = WTemplated.getVars(self)
3658 # abMgr = self._conf.getAbstractMgr()
3660 # trackFilter = "<option value=\"\">No filter</option>\n"
3661 # for track in self._conf.getTrackList():
3663 # if track.getId() == self._filter["track"]:
3664 # selected = "selected"
3665 # trackFilter += "<option value=\"%s\" %s>%s</option>\n"%(track.getId(), selected, track.getTitle())
3666 # vars["trackFilter"] = trackFilter
3668 # typeFilter = "<option value=\"\">No filter</option>\n"
3669 # for type in self._conf.getContribTypeList():
3671 # if type.getId() == self._filter["type"]:
3672 # selected = "selected"
3673 # typeFilter += "<option value=\"%s\" %s>%s</option>\n"%(type.getId(), selected, type)
3674 # vars["typeFilter"] = typeFilter
3676 # statusFilter = "<option value=\"\">No filter</option>\n"
3677 # for name in StatusName().getNameList():
3679 # if name == self._filter["status"]:
3680 # selected = "selected"
3681 # statusFilter += "<option value=\"%s\" %s>%s</option>\n"%(name, selected, name)
3682 # vars["statusFilter"] = statusFilter
3684 # fDay = "<option value=\"\"> </option>\n"
3685 # for i in range(1,32):
3687 # if self._filter["fromDate"] != None:
3688 # if i == self._filter["fromDate"].day:
3689 # selected = "selected"
3690 # fDay += "<option value=\"%s\" %s>%s</option>\n"%(i, selected, i)
3691 # vars["fDay"] = fDay
3693 # fMonth = "<option value=\"\"> </option>\n"
3694 # month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
3695 # for i in range(1,13):
3697 # if self._filter["fromDate"] != None:
3698 # if i == self._filter["fromDate"].month:
3699 # selected = "selected"
3700 # fMonth += "<option value=\"%s\" %s>%s</option>\n"%(i, selected, month[i-1])
3701 # vars["fMonth"] = fMonth
3703 # fYear = "<option value=\"\"> </option>\n"
3704 # for i in range(2000,2011):
3706 # if self._filter["fromDate"] != None:
3707 # if i == self._filter["fromDate"].year:
3708 # selected = "selected"
3709 # fYear += "<option value=\"%s\" %s>%s</option>\n"%(i, selected, i)
3710 # vars["fYear"] = fYear
3714 # tDay = "<option value=\"\"> </option>\n"
3715 # for i in range(1,32):
3717 # if self._filter["toDate"] != None:
3718 # if i == self._filter["toDate"].day:
3719 # selected = "selected"
3720 # tDay += "<option value=\"%s\" %s>%s</option>\n"%(i, selected, i)
3721 # vars["tDay"] = tDay
3723 # tMonth = "<option value=\"\"> </option>\n"
3724 # for i in range(1,13):
3726 # if self._filter["toDate"] != None:
3727 # if i == self._filter["toDate"].month:
3728 # selected = "selected"
3729 # tMonth += "<option value=\"%s\" %s>%s</option>\n"%(i, selected, month[i-1])
3730 # vars["tMonth"] = tMonth
3732 # tYear = "<option value=\"\"> </option>\n"
3733 # for i in range(2000,2011):
3735 # if self._filter["toDate"] != None:
3736 # if i == self._filter["toDate"].year:
3737 # selected = "selected"
3738 # tYear += "<option value=\"%s\" %s>%s</option>\n"%(i, selected, i)
3739 # vars["tYear"] = tYear
3743 # #sortList = ["title", "type", "modification date"]
3745 # if self._sorter["field"] == "title":
3746 # selected = "selected"
3747 # sortBy = "<option value=\"title\" %s>Title</option>\n"%selected
3749 # if self._sorter["field"] == "type":
3750 # selected = "selected"
3751 # sortBy += "<option value=\"type\" %s>Type</option>\n"%selected
3753 # if self._sorter["field"] == "modification date":
3754 # selected = "selected"
3755 # sortBy += "<option value=\"modification date\" %s>Modification date</option>\n"%selected
3757 # if self._sorter["field"] == "status":
3758 # selected = "selected"
3759 # sortBy += "<option value=\"status\" %s>Status</option>\n"%selected
3762 # if self._sorter["direction"] == "desc":
3763 # vars["ascChecked"] = ""
3764 # vars["descChecked"] = "checked"
3766 # vars["ascChecked"] = "checked"
3767 # vars["descChecked"] = ""
3769 # vars["sortBy"] = sortBy
3774 #class WSubTrackCreation( WTemplated ):
3776 # def __init__( self, track ):
3777 # self.__track = track
3779 # def getVars( self ):
3780 # vars = WTemplated.getVars(self)
3781 # vars["title"], vars["description"] = "", ""
3782 # vars["locator"] = self.__track.getLocator().getWebForm()
3785 #class WSetLogo( WTemplated ):
3787 # def __init__( self, conference ):
3788 # self.__conf = conference
3790 # def getVars( self ):
3791 # vars = WTemplated.getVars( self )
3792 # vars["confTitle"] = self.__conf.getTitle()
3796 class WSelectionBox(WTemplated
):
3799 vars=WTemplated
.getVars(self
)
3800 if not vars.has_key("description"):
3801 vars["description"]=""
3802 if not vars.has_key("options"):
3804 if not vars.has_key("table_width"):
3805 vars["table_width"]=""
3808 class WSelectionBoxAuthors
:
3813 "description": _("Please make your selection if you want to add the submitter/s directly to any of the following roles:"),\
3814 "options": i18nformat("""<input type="radio" name="submitterRole" value="primaryAuthor"> _("Primary author")<br>
3815 <input type="radio" name="submitterRole" value="coAuthor"> _("Co-author")<br><hr>
3816 <input type="checkbox" name="submitterRole" value="speaker"> _("Speaker")
3819 return wc
.getHTML(p
)
3821 class WMSelectionBoxAuthors
:
3826 "description": _("Please make your selection if you want to add the submitter/s directly to:"),\
3827 "options": i18nformat("""<input type="checkbox" name="submitterRole" value="speaker"> _("Speaker")
3829 "table_width": "180px" \
3831 return wc
.getHTML(p
)
3833 class WSelectionBoxSubmitter
:
3838 "description": i18nformat(""" _("Please check the box if you want to add them as submitters"):<br><br><i><font color=\"black\"><b> _("Note"): </b></font> _("If this person is not already a user they will be sent an email asking them to create an account. After their registration the user will automatically be given submission rights").</i><br>"""),\
3839 "options": i18nformat("""<input type="checkbox" name="submissionControl" value="speaker" checked> _("Add as submitter")
3842 return wc
.getHTML(p
)
3844 class WSelectionBoxConveners
:
3849 "description": _("Please make your selection if you want to add the result/s directly to the role of session Convener:"),\
3850 "options": i18nformat("""<input type="checkbox" name="userRole" value="convener"> _("Add as convener")
3853 return wc
.getHTML(p
)
3855 class WSelectionBoxConvToManagerCoordinator
:
3860 "description": i18nformat(""" _("Please check the box if you want to add them as managers/coordinators"):"""),\
3861 "options": i18nformat("""<input type="checkbox" name="managerControl"> _("Add as session manager")<br>
3862 <input type="checkbox" name="coordinatorControl"> _("Add as session coordinator")
3865 return wc
.getHTML(p
)
3868 class WSelectionBoxCloneLecture
:
3873 "description": _("Please check the boxes indicating which elements of the lecture you want to clone"),\
3874 "options": i18nformat("""<input type="checkbox" name="cloneDetails" id="cloneDetails" checked="1" disabled="1" value="1"> _("Event details")
3875 <input type="checkbox" name="cloneMaterials" id="cloneMaterials" value="1" > _("Attached materials")
3876 <input type="checkbox" name="cloneAccess" id="cloneAccess" value="1" > _("Access and management privileges")
3879 return wc
.getHTML(p
)
3882 class WUserSelection(WTemplated
):
3885 def __init__( self
, searchURL
, multi
=True, addTo
=0, forceWithoutExtAuth
=False):
3886 self
._title
= _("Search for users")
3887 self
._searchURL
= searchURL
3888 self
._forceWithoutExtAuth
= forceWithoutExtAuth
3889 self
._multi
= multi
# for multiple selection
3890 #addTo=0: do not show any selection box.
3891 #addTo=1: show selection box to add submitter as primary author, coauthor or speaker.
3892 #addTo=2: show selection box to add primary author, coauthor or speaker as submitter.
3893 #addTo=3: show selection box to add session managers as session conveners
3894 #addTo=4: show selection box to add submitter as speaker. This is just for meetings
3895 #addTo=5: show selection box to add submitter and/or manager rights for convener.
3898 def _performSearch( self
, criteria
, exact
=0 ):
3899 ah
= user
.AvatarHolder()
3900 res
= ah
.match(criteria
, exact
=exact
, forceWithoutExtAuth
=self
._forceWithoutExtAuth
)
3903 def setTitle( self
, newTitle
):
3904 self
._title
= newTitle
.strip()
3906 def _getPassingParams( self
, params
):
3908 for p
in params
.keys():
3909 if p
in ["firstname", "surname", "organisation", "email", "groupname","exact","searchExt", 'selectedPrincipals']:
3911 l
.append( """<input type="hidden" name="%s" value="%s">\n"""%(p
, \
3913 return "\n".join( l
)
3915 def _filterParams( self
, params
):
3916 pars
= copy( params
)
3917 self
._action
= "show"
3918 if pars
.has_key("action"):
3919 self
._action
= pars
["action"].strip()
3923 def _create( self
, params
):
3926 #a.setName( params["firstname"] )
3927 #a.setSurName( params["surname"] )
3928 #a.setEmail( params["email"] )
3929 #a.setOrganisation( params["organisation"] )
3930 #user.AvatarHolder().add( a )
3932 def _normaliseListParam( self
, param
):
3933 if not isinstance(param
, list):
3937 def getHTML( self
, params
):
3938 self
._cancelURL
= params
.get("addURL","")
3939 pars
= self
._filterParams
( params
)
3940 self
._passingParams
= self
._getPassingParams
( pars
)
3942 if self
._action
== _("create"):
3944 self
._create
( pars
)
3946 self
._msg
= str(e
)#"User not created. The email address is already used."
3947 self
._action
= _("search")
3948 return WTemplated
.getHTML( self
, pars
)
3950 def getVars( self
):
3951 vars = WTemplated
.getVars( self
)
3952 vars["usericon"]=quoteattr(str(Config
.getInstance().getSystemIconURL("user" )))
3953 vars["firstName"] = vars.get("firstname", "")
3954 vars["surName"] = vars.get("surname", "")
3955 vars["email"] = vars.get("email", "")
3956 vars["organisation"] = vars.get("organisation", "")
3957 if "WPtitle" not in vars or vars["WPtitle"].strip() == "":
3958 vars["WPtitle"] = self
._title
3959 vars["params"] = self
._passingParams
3960 vars["addURL"] = urlHandlers
.UHUserSearchCreateExternalUser
.getURL()
3961 #vars["createURL"] = urlHandlers.UHUserSearchCreateExternalUser.getURL()
3962 vars["postURL"] = self
._searchURL
3963 vars["cancelURL"] = self
._cancelURL
3964 vars["searchResultsTable"] = ""
3967 if self
._action
== _("search").strip():
3968 criteria
= { "name": vars["firstName"], \
3969 "surName": vars["surName"], \
3970 "email" : vars["email"], \
3971 "organisation": vars["organisation"] \
3973 if vars.has_key("groupname"):
3974 criteria
["groupname"] = vars["groupname"]
3976 if vars.get("exact",0) != 0:
3978 res
= self
._performSearch
( criteria
, exact
=exact
)
3979 vars["searchResultsTable"] = WUserSearchResultsTable(self
._multi
).getHTML( res
)
3982 vars["msg"] = """<tr>
3983 <td bgcolor="white" colspan="3" align="center">
3984 <font color="red">%s</font>
3990 sb
=WSelectionBoxAuthors().getHTML()
3991 elif self
._addTo
==2:
3992 sb
=WSelectionBoxSubmitter().getHTML()
3993 elif self
._addTo
==3:
3994 sb
=WSelectionBoxConveners().getHTML()
3995 elif self
._addTo
==4:
3996 sb
=WMSelectionBoxAuthors().getHTML()
3997 elif self
._addTo
==5:
3998 sb
=WSelectionBoxConvToManagerCoordinator().getHTML()
3999 vars["selectionBox"]=sb
4000 vars["searchOptions"]=""
4001 authenticators
= Config
.getInstance().getAuthenticatorList()
4002 searchList
= self
._normaliseListParam
(vars.get("searchExt",""))
4003 for auth
in authenticators
:
4004 if auth
.lower() != "local":
4006 if auth
in searchList
:
4007 selected
= "checked"
4008 vars["searchOptions"]+= i18nformat("""<input type="checkbox" name="searchExt" value="%s" %s> _("search %s database")<br>""") % (auth
, selected
, auth
.upper())
4010 if vars.get("exact","") != "":
4011 selected
= "checked"
4012 vars["searchOptions"]+= i18nformat("""<input type="checkbox" name="exact" value="1" %s> _("exact match")<br>""") % selected
4015 class WAuthorSearch(WUserSelection
):
4017 def __init__(self
, conf
, searchURL
, multi
=True, addTo
=0, forceWithoutExtAuth
=False):
4018 _title
= _("Search Users and Authors")
4019 WUserSelection
.__init
__(self
, searchURL
, multi
, addTo
, forceWithoutExtAuth
=forceWithoutExtAuth
)
4023 def _performSearch( self
, criteria
, exact
=0 ):
4024 #this should go in the PrincipalHolder match method
4025 ah
= user
.AvatarHolder()
4026 resUsers
= ah
.match(criteria
, exact
=exact
, forceWithoutExtAuth
=self
._forceWithoutExtAuth
)
4027 auths
= self
._conf
.getAuthorIndex()
4028 resAuths
= auths
.match(criteria
, exact
=exact
)
4029 #crear una lista y devolver el resultado
4032 for usr
in resUsers
:
4034 emails
.append(usr
.getEmail())
4035 for author
in resAuths
:
4036 if author
.getEmail() not in emails
:
4040 class WPrincipalSelection(WUserSelection
):
4043 def _performSearch( self
, criteria
, exact
=0 ):
4044 #this should go in the PrincipalHolder match method
4045 _title
= _("Search for users and groups")
4046 ah
= user
.AvatarHolder()
4047 resUsers
= ah
.match(criteria
,exact
=exact
,forceWithoutExtAuth
=self
._forceWithoutExtAuth
)
4048 resGroups
= [ group
for group
in user
.GroupHolder().match(criteria
, forceWithoutExtAuth
=self
._forceWithoutExtAuth
) if not group
.isObsolete()]
4050 for item
in resUsers
:
4052 for item
in resGroups
:
4056 def getVars( self
):
4057 vars=WUserSelection
.getVars(self
)
4058 vars["usericon"]=quoteattr(str(Config
.getInstance().getSystemIconURL("user" )))
4059 vars["groupicon"]=quoteattr(str(Config
.getInstance().getSystemIconURL("group" )))
4060 vars["groupNICEicon"]=quoteattr(str(Config
.getInstance().getSystemIconURL("groupNICE" )))
4061 vars["groupname"] = vars.get("groupname", "")
4065 class WComplexSelection(WUserSelection
):
4068 def __init__(self
, target
, searchAction
, addTo
= 0, forceWithoutExtAuth
=False):
4069 _title
= _("Search for users")
4070 WUserSelection
.__init
__(self
, searchAction
, addTo
= addTo
, forceWithoutExtAuth
=forceWithoutExtAuth
)
4072 self
._conf
= target
.getConference()
4075 self
._target
= target
4077 def _performSearch( self
, criteria
, exact
=0 ):
4078 #this should go in the PrincipalHolder match method
4079 ah
= user
.AvatarHolder()
4080 resUsers
= ah
.match(criteria
, exact
=exact
, forceWithoutExtAuth
=self
._forceWithoutExtAuth
)
4082 auths
= self
._conf
.getAuthorIndex()
4083 resAuths
= auths
.match(criteria
, exact
=exact
)
4088 for usr
in resUsers
:
4090 emails
.append(usr
.getEmail())
4091 for author
in resAuths
:
4092 if author
.getEmail() not in emails
:
4097 vars = WUserSelection
.getVars( self
)
4098 vars["usericon"]=quoteattr(str(Config
.getInstance().getSystemIconURL("user" )))
4101 class WCategoryComplexSelection(WComplexSelection
):
4104 def __init__(self
, category
, searchAction
, forceWithoutExtAuth
=False):
4105 WComplexSelection
.__init
__(self
, None, searchAction
,forceWithoutExtAuth
=forceWithoutExtAuth
)
4106 self
._category
= category
4108 def _performSearch( self
, criteria
, exact
=0 ):
4109 #this should go in the PrincipalHolder match method
4110 ah
= user
.AvatarHolder()
4111 resUsers
= ah
.match(criteria
, exact
=exact
, forceWithoutExtAuth
=self
._forceWithoutExtAuth
)
4115 class WNewPerson(WTemplated
):
4117 def getVars( self
):
4118 vars = WTemplated
.getVars( self
)
4119 options
= [" ", _("Mr."), _("Ms."), _("Dr."), _("Prof.")]
4121 titleValue
= vars.get("titleValue", " ")
4125 if titleValue
== o
:
4126 selected
= "selected"
4127 text
= """<option value="%s" %s>%s</option>"""%(o
, selected
, o
)
4129 vars["titles"] = """
4132 if vars.get("disabledTitle", False) :
4133 vars["titles"] = """<input type="hidden" name="title" value="%s"></input>%s"""%(titleValue
,titleValue
)
4135 vars["titles"] = """
4136 <select name="title">
4141 if vars.get("disabledSurName", False) :
4142 vars["surName"] = """<input type="hidden" name="surName" value="%s"></input>%s"""%(vars["surNameValue"],vars["surNameValue"])
4144 vars["surName"] = """<input type="text" size="50" name="surName" value="%s" >"""%vars["surNameValue"]
4146 if vars.get("disabledName", False) :
4147 vars["name"] = """<input type="hidden" name="name" value="%s"></input>%s"""%(vars["nameValue"],vars["nameValue"])
4149 vars["name"] = """<input type="text" size="50" name="name" value="%s" >"""%vars["nameValue"]
4151 if vars.get("disabledAffiliation", False) :
4152 vars["affiliation"] = """<input type="hidden" name="affiliation" value="%s"></input>%s"""%(vars["affiliationValue"],vars["affiliationValue"])
4154 vars["affiliation"] = """<input type="text" size="50" name="affiliation" value="%s" >"""%vars["affiliationValue"]
4156 if vars.get("disabledEmail", False) :
4157 vars["email"] = """<input type="hidden" name="email" value="%s"></input>%s"""%(vars["emailValue"],vars["emailValue"])
4160 if not vars.get("disabledRole", True) and vars["roleDescription"] == "Submitter":
4161 js
="""onkeyup="if (!this.form.submissionControl.checked || this.value.length != 0) {this.form.warning_email.type='hidden';}else{this.form.warning_email.type='text';}">
4162 <input type="text" size="50" value="Warning: if email is empty, submission rights will not be given" style="border: 0px none ; color: red;" id="warning_email"/"""
4163 vars["email"] = """<input type="text" size="50" name="email" value="%s" %s>"""%(vars["emailValue"],js
)
4164 if vars.get("disabledAddress", False) :
4165 vars["address"] = """<input type="hidden" name="address" value="%s"></input>%s"""%(vars["addressValue"],vars["addressValue"])
4167 vars["address"] = """<textarea name="address" rows="5" cols="38">%s</textarea>"""%vars["addressValue"]
4169 if vars.get("disabledPhone", False) :
4170 vars["phone"] = """<input type="hidden" name="phone" value="%s"></input>%s"""%(vars["phoneValue"],vars["phoneValue"])
4172 vars["phone"] = """<input type="text" size="50" name="phone" value="%s" >"""%vars["phoneValue"]
4174 if vars.get("disabledPhone", False) :
4175 vars["phone"] = """<input type="hidden" name="phone" value="%s"></input>%s"""%(vars["phoneValue"],vars["phoneValue"])
4177 vars["phone"] = """<input type="text" size="50" name="phone" value="%s" >"""%vars["phoneValue"]
4179 if vars.get("disabledFax", False) :
4180 vars["fax"] = """<input type="hidden" name="fax" value="%s"></input>%s"""%(vars["faxValue"],vars["faxValue"])
4182 vars["fax"] = """<input type="text" size="50" name="fax" value="%s" >"""%vars["faxValue"]
4183 if vars.get("disabledRole", True) :
4188 <td nowrap class="titleCellTD"><span class="titleCellFormat">%s</span></td>
4189 <td bgcolor="white" width="100%%" valign="top" class="blacktext">%s</td>
4190 </tr>"""%(vars["roleDescription"], vars["roleValue"])
4192 if vars.get("disabledNotice", True) :
4195 vars["notice"] = """
4197 <td nowrap class="titleCellTD"></td>
4198 <td bgcolor="white" width="100%%" valign="top" class="blacktext">%s</td>
4199 </tr>"""%vars["noticeValue"]
4201 if vars.get("msg","")!="":
4202 vars["msg"]= i18nformat("""<table bgcolor="gray"><tr><td bgcolor="white">
4203 <font size="+1" color="red"><b> _("You must enter a valid email address.")</b></font>
4205 </td></tr></table>""")
4207 else: vars["msg"]=""
4211 class WAddPersonModule(WTemplated
):
4213 def __addBasketPeople(self
, peopleList
):
4215 user
= self
._rh
._getUser
()
4217 # add extra options if the user is logged in
4219 basket
= user
.getPersonalInfo().getBasket().getUsers()
4221 peopleList
+= """<option value=""></option>"""
4223 for userId
in basket
:
4224 peopleList
+= """<option class="favoriteItem" value="%s">%s</option>"""%(userId
,basket
[userId
].getStraightFullName())
4227 # just add nothing if the user is not logged in
4231 def __init__(self
,personType
, displayName
=""):
4232 self
._personType
= personType
4233 self
._displayName
= displayName
4235 def getVars( self
):
4236 vars = WTemplated
.getVars( self
)
4237 if self
._personType
is None or self
._personType
== "" :
4238 raise MaKaCError( _("'personType' must be set to use the Add Person Module"))
4241 if self
._displayName
!= "":
4242 vars["personName"] = self
._displayName
4244 vars["personName"] = string
.capwords("%s"%self
._personType
)
4246 # Add people from the users basket
4247 vars["personOptions"] = self
.__addBasketPeople
("")
4249 vars["personOptions"] += vars["%sOptions"%self
._personType
]
4251 vars["personChosen"] = "%sChosen"%self
._personType
4253 vars["personDefined"] = vars["%sDefined"%self
._personType
]
4255 if vars["personOptions"] == """<option value=""> </option>""":
4256 vars["disabledAdd"] = "disabled"
4258 vars["disabledAdd"] = ""
4260 vars["personType"] = self
._personType
4262 if vars.get("submission",None) is not None :
4263 vars["submissionButtons"] = i18nformat("""
4265 <td colspan="4"><input type="submit" class="btn" value="_("Grant submission")" onClick="setAction(this.form,'Grant submission');"></td>
4268 <td colspan="4"><input type="submit" class="btn" value="_("Withdraw submission")" onClick="setAction(this.form,'Withdraw submission');"></td>
4271 vars["submissionButtons"] = ""
4275 class WAccountAlreadyActivated(WTemplated
):
4277 def __init__(self
, av
):
4280 def getVars( self
):
4281 vars = WTemplated
.getVars( self
)
4285 class WAccountActivated(WTemplated
):
4287 def __init__(self
, av
):
4290 def getVars( self
):
4291 vars = WTemplated
.getVars( self
)
4295 class WAccountDisabled(WTemplated
):
4297 def __init__(self
, av
):
4300 def getVars( self
):
4301 vars = WTemplated
.getVars( self
)
4305 class WUnactivatedAccount(WTemplated
):
4307 def __init__(self
, av
):
4310 def getVars( self
):
4311 vars = WTemplated
.getVars( self
)
4312 minfo
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance()
4313 vars["moderated"]=minfo
.getModerateAccountCreation()
4317 class WAbstractModIntCommentEdit(WTemplated
):
4319 def __init__(self
,comment
):
4320 self
._comment
=comment
4323 vars=WTemplated
.getVars(self
)
4324 vars["content"]=self
.htmlText(self
._comment
.getContent())
4328 class WAbstractModNewIntComment(WTemplated
):
4330 def __init__(self
,aw
,abstract
):
4332 self
._abstract
=abstract
4335 vars=WTemplated
.getVars(self
)
4339 class WSessionModifComm(WTemplated
):
4340 def __init__(self
, aw
,session
):
4342 self
._session
= session
4343 self
._conf
= session
.getConference()
4345 def _getHTML(self
,editCommentsURLGen
):
4347 comment
=self
._session
.getComments()
4349 comment
= _("No Session Comment Entered")
4351 comment
= _("No Session Comment Entered")
4352 self
._session
.setComments("")
4355 if self
._conf
.canModify(self
._aw
):
4357 modifButton
= i18nformat("""<form action=%s method="POST">
4359 <input type="submit" class="btn" value="_("modify")">
4362 """)%quoteattr(str(editCommentsURLGen(self
._session
)))
4363 return ( i18nformat("""
4364 <table width="50%%" align="center" style="border-left: 1px solid #777777">
4366 <td class="groupTitle"> _("Session comment")</td>
4376 </table> """)%(comment
,modifButton
))
4379 vars=WTemplated
.getVars(self
)
4380 vars["comment"]=self
._getHTML
(vars["editCommentsURLGen"])
4385 class WSessionModifCommEdit(WTemplated
):
4387 def __init__(self
,comment
):
4388 self
._comment
=comment
4391 vars=WTemplated
.getVars(self
)
4392 vars["comment"]=self
.htmlText(self
._comment
)
4395 class WAbstractModIntComments(WTemplated
):
4397 def __init__(self
,aw
,abstract
):
4399 self
._abstract
=abstract
4401 def _getCommentsHTML(self
,commentEditURLGen
,commentRemURLGen
):
4403 commentList
= self
._abstract
.getIntCommentList()
4404 for c
in commentList
:
4405 mailtoSubject
="[Indico] Abstract %s: %s"%(self
._abstract
.getId(), self
._abstract
.getTitle())
4406 mailtoURL
=URL("mailto:%s"%c.getResponsible().getEmail())
4407 mailtoURL
.addParam("subject", mailtoSubject
)
4408 responsible
="""<a href=%s>%s</a>"""%(quoteattr(str(mailtoURL
)),self
.htmlText(c
.getResponsible().getFullName()))
4409 date
=self
.htmlText(c
.getCreationDate().strftime("%Y-%m-%d %H:%M"))
4410 buttonMod
,buttonRem
="",""
4411 if self
._aw
.getUser()==c
.getResponsible():
4412 buttonMod
= i18nformat("""
4413 <form action=%s method="POST">
4414 <td valign="bottom">
4415 <input type="submit" class="btn" value="_("modify")">
4418 """)%quoteattr(str(commentEditURLGen(c
)))
4419 buttonRem
= i18nformat("""
4420 <form action=%s method="POST">
4421 <td valign="bottom">
4422 <input type="submit" class="btn" value="_("remove")">
4425 """)%quoteattr(str(commentRemURLGen(c
)))
4428 <td bgcolor="white" style="border-top:1px solid #777777;border-bottom:1px solid #777777;">
4431 <td width="100%%">%s on %s</td>
4440 </tr>"""%(responsible
,date
,c
.getContent(),buttonMod
,buttonRem
))
4442 res
.append( i18nformat("""<tr><td align=\"center\" style=\"color:black\"><br>--_("no internal comments")--<br><br></td></tr>"""))
4446 vars=WTemplated
.getVars(self
)
4447 vars["comments"]=self
._getCommentsHTML
(vars["commentEditURLGen"],vars["commentRemURLGen"])
4448 vars["newCommentURL"]=quoteattr(str(vars["newCommentURL"]))
4452 class WAbstractModMarkAsDup(WTemplated
):
4454 def __init__(self
,abstract
):
4455 self
._abstract
=abstract
4458 vars=WTemplated
.getVars(self
)
4459 vars["duplicateURL"]=quoteattr(str(vars["duplicateURL"]))
4460 vars["cancelURL"]=quoteattr(str(vars["cancelURL"]))
4461 vars["error"] = vars.get("errorMsg","")
4465 class WAbstractModUnMarkAsDup(WTemplated
):
4467 def __init__(self
,abstract
):
4468 self
._abstract
=abstract
4472 vars=WTemplated
.getVars(self
)
4473 vars["unduplicateURL"]=quoteattr(str(vars["unduplicateURL"]))
4474 vars["cancelURL"]=quoteattr(str(vars["cancelURL"]))
4478 class WScheduleAddContributions(WTemplated
):
4480 def __init__(self
,selectList
,targetDay
=None):
4481 self
._contribList
=selectList
4482 self
._targetDay
=targetDay
4484 def _getContribListHTML(self
):
4486 contribList
=filters
.SimpleFilter(None,contribFilters
.SortingCriteria(["number"])).apply(self
._contribList
)
4487 for contrib
in self
._contribList
:
4489 if contrib
.getType() is not None:
4490 typeCaption
=contrib
.getType().getName()
4492 for spk
in contrib
.getSpeakerList():
4493 l
.append("""%s"""%(self
.htmlText(spk
.getFullName())))
4494 spksCaption
="<br>".join(l
)
4498 <input type="checkbox" name="manSelContribs" value=%s>
4500 <td valign="top">%s</td>
4501 <td valign="top">[%s]</td>
4502 <td valign="top"><i>%s</i></td>
4503 <td valign="top">%s</td>
4505 """%(quoteattr(str(contrib
.getId())),
4506 self
.htmlText(contrib
.getId()),
4507 self
.htmlText(typeCaption
),
4508 self
.htmlText(contrib
.getTitle()),
4514 vars=WTemplated
.getVars(self
)
4515 vars["contribs"]="".join(self
._getContribListHTML
())
4516 vars["targetDay"]=""
4517 if self
._targetDay
is not None:
4518 vars["targetDay"]="""<input type="hidden" name="targetDay" value=%s>"""%(quoteattr(str(self
._targetDay
.strftime("%Y-%m-%d"))))
4522 class WSchEditContrib(WTemplated
):
4524 def __init__(self
,contrib
):
4525 self
._contrib
=contrib
4528 vars=WTemplated
.getVars(self
)
4529 vars["postURL"]=quoteattr(str(vars["postURL"]))
4530 vars["title"]=self
.htmlText(self
._contrib
.getTitle())
4531 confTZ
= self
._contrib
.getConference().getTimezone()
4532 sDate
=self
._contrib
.getStartDate().astimezone(timezone(confTZ
))
4533 vars["sYear"]=quoteattr(str(sDate
.year
))
4534 vars["sMonth"]=quoteattr(str(sDate
.month
))
4535 vars["sDay"]=quoteattr(str(sDate
.day
))
4536 vars["sHour"]=quoteattr(str(sDate
.hour
))
4537 vars["sMinute"]=quoteattr(str(sDate
.minute
))
4538 vars["durHours"]=quoteattr(str(int(self
._contrib
.getDuration().seconds
/3600)))
4539 vars["durMins"]=quoteattr(str(int((self
._contrib
.getDuration().seconds
%3600)/60)))
4540 defaultDefinePlace
=defaultDefineRoom
=""
4541 defaultInheritPlace
=defaultInheritRoom
="checked"
4542 locationName
,locationAddress
,roomName
="","",""
4543 if self
._contrib
.getOwnLocation():
4544 defaultDefinePlace
,defaultInheritPlace
="checked",""
4545 locationName
=self
._contrib
.getLocation().getName()
4546 locationAddress
=self
._contrib
.getLocation().getAddress()
4547 if self
._contrib
.getOwnRoom():
4548 defaultDefineRoom
,defaultInheritRoom
="checked",""
4549 roomName
=self
._contrib
.getRoom().getName()
4550 vars["defaultInheritPlace"]=defaultInheritPlace
4551 vars["defaultDefinePlace"]=defaultDefinePlace
4552 vars["confPlace"]=""
4553 confLocation
=self
._contrib
.getOwner().getLocation()
4554 if self
._contrib
.isScheduled():
4555 confLocation
=self
._contrib
.getSchEntry().getSchedule().getOwner().getLocation()
4557 vars["confPlace"]=confLocation
.getName()
4558 vars["locationName"]=locationName
4559 vars["locationAddress"]=locationAddress
4560 vars["defaultInheritRoom"]=defaultInheritRoom
4561 vars["defaultDefineRoom"]=defaultDefineRoom
4563 confRoom
=self
._contrib
.getOwner().getRoom()
4564 if self
._contrib
.isScheduled():
4565 confRoom
=self
._contrib
.getSchEntry().getSchedule().getOwner().getRoom()
4567 vars["confRoom"]=confRoom
.getName()
4568 vars["roomName"]=quoteattr(roomName
)
4569 vars["parentType"]="conference"
4570 if self
._contrib
.getSession() is not None:
4571 vars["parentType"]="session"
4572 if self
._contrib
.isScheduled():
4573 vars["parentType"]="session slot"
4574 vars["boardNumber"]=quoteattr(str(self
._contrib
.getBoardNumber()))
4575 vars["autoUpdate"] = ""
4579 class WConfModParticipEdit(WTemplated
):
4581 def __init__(self
,title
="",part
=None):
4586 vars=WTemplated
.getVars(self
)
4587 vars["postURL"]=quoteattr(str(vars["postURL"]))
4588 vars["caption"]=self
.htmlText(self
._ctitle
)
4589 title
,firstName
,familyName
="","",""
4590 affiliation
,email
,address
,phone
,fax
="","","","",""
4591 if self
._part
is not None:
4592 title
=self
._part
.getTitle()
4593 firstName
=self
._part
.getFirstName()
4594 familyName
=self
._part
.getFamilyName()
4595 affiliation
=self
._part
.getAffiliation()
4596 email
=self
._part
.getEmail()
4597 address
=self
._part
.getAddress()
4598 phone
=self
._part
.getPhone()
4599 fax
=self
._part
.getFax()
4600 vars["titles"]=TitlesRegistry().getSelectItemsHTML(title
)
4601 vars["surName"]=quoteattr(familyName
)
4602 vars["name"]=quoteattr(firstName
)
4603 vars["affiliation"]=quoteattr(affiliation
)
4604 vars["email"]=quoteattr(email
)
4605 vars["address"]=address
4606 vars["phone"]=quoteattr(phone
)
4607 vars["fax"]=quoteattr(fax
)
4608 if not vars.has_key("addToManagersList"):
4609 vars["addToManagersList"]=""
4612 class WSessionModEditDataCode(WTemplated
):
4617 def getVars( self
):
4618 vars=WTemplated
.getVars(self
)
4619 vars["code"]=quoteattr(str(vars.get("code","")))
4622 class WSessionModEditDataType(WTemplated
):
4627 def getVars( self
):
4628 vars=WTemplated
.getVars(self
)
4630 currentTTType
=vars.get("tt_type",conference
.SlotSchTypeFactory
.getDefaultId())
4631 for i
in conference
.SlotSchTypeFactory
.getIdList():
4633 if i
==currentTTType
:
4635 l
.append("""<option value=%s%s>%s</option>"""%(quoteattr(str(i
)),
4636 sel
,self
.htmlText(i
)))
4637 vars["tt_types"]="".join(l
)
4640 class WSessionModEditDataColors(WTemplated
):
4645 def getVars( self
):
4646 vars=WTemplated
.getVars(self
)
4649 class WSessionModEditData(WTemplated
):
4651 def __init__(self
,targetConf
,aw
,pageTitle
="",targetDay
=None):
4652 self
._conf
=targetConf
4653 self
._title
=pageTitle
4654 self
._targetDay
=targetDay
4657 def _getErrorHTML(self
,l
):
4661 <td colspan="2" align="center">
4663 <table bgcolor="red" cellpadding="6">
4665 <td bgcolor="white" style="color: red">%s</td>
4675 def getVars( self
):
4676 vars=WTemplated
.getVars(self
)
4677 vars["conference"] = self
._conf
4678 vars["eventId"] = "s" + vars["sessionId"]
4679 minfo
= info
.HelperMaKaCInfo
.getMaKaCInfoInstance()
4680 vars["useRoomBookingModule"] = minfo
.getRoomBookingModuleActive()
4681 vars["calendarIconURL"]=Config
.getInstance().getSystemIconURL( "calendar" )
4682 vars["calendarSelectURL"]=urlHandlers
.UHSimpleCalendar
.getURL()
4683 vars["pageTitle"]=self
.htmlText(self
._title
)
4684 vars["errors"]=self
._getErrorHTML
(vars.get("errors",[]))
4685 vars["postURL"]=quoteattr(str(vars["postURL"]))
4686 vars["title"]=quoteattr(str(vars.get("title","")))
4687 vars["description"]=self
.htmlText(vars.get("description",""))
4688 if self
._targetDay
== None:
4689 sessionId
= vars["sessionId"]
4690 session
= self
._conf
.getSessionById(sessionId
)
4691 refDate
= session
.getAdjustedStartDate()
4693 refDate
=self
._conf
.getSchedule().getFirstFreeSlotOnDay(self
._targetDay
)
4695 if refDate
.hour
== 23:
4696 refDate
= refDate
- timedelta(minutes
=refDate
.minute
)
4697 endDate
= refDate
+ timedelta(minutes
=59)
4698 vars["sDay"]=str(vars.get("sDay",refDate
.day
))
4699 vars["sMonth"]=str(vars.get("sMonth",refDate
.month
))
4700 vars["sYear"]=str(vars.get("sYear",refDate
.year
))
4701 vars["sHour"]=str(vars.get("sHour",refDate
.hour
))
4702 vars["sMinute"]=str(vars.get("sMinute",refDate
.minute
))
4704 endDate
=refDate
+timedelta(hours
=1)
4705 vars["eDay"]=str(vars.get("eDay",endDate
.day
))
4706 vars["eMonth"]=str(vars.get("eMonth",endDate
.month
))
4707 vars["eYear"]=str(vars.get("eYear",endDate
.year
))
4708 vars["eHour"]=str(vars.get("eHour",endDate
.hour
))
4709 vars["eMinute"]=str(vars.get("eMinute",endDate
.minute
))
4710 vars["durHour"]=quoteattr(str(vars.get("durHour",0)))
4711 vars["durMin"]=quoteattr(str(vars.get("durMin",20)))
4712 vars["defaultInheritPlace"]="checked"
4713 vars["defaultDefinePlace"]=""
4715 if vars.get("convenerDefined",None) is None :
4716 sessionId
= vars["sessionId"]
4717 session
= self
._conf
.getSessionById(sessionId
)
4719 for convener
in session
.getConvenerList() :
4722 <td width="5%%"><input type="checkbox" name="%ss" value="%s"></td>
4724 </tr>"""%("convener",convener
.getId(),convener
.getFullName())
4726 vars["definedConveners"] = """
4728 if vars.get("locationAction","")=="define":
4729 vars["defaultInheritPlace"]=""
4730 vars["defaultDefinePlace"]="checked"
4731 vars["confPlace"]=""
4732 confLocation
=self
._conf
.getConference().getLocation()
4734 vars["confPlace"]=self
.htmlText(confLocation
.getName())
4735 vars["locationName"]=quoteattr(str(vars.get("locationName","")))
4736 vars["locationAddress"]=self
.htmlText(vars.get("locationAddress",""))
4737 vars["defaultInheritRoom"]=""
4738 vars["defaultDefineRoom"]=""
4739 vars["defaultExistRoom"]=""
4740 if vars.get("roomAction","")=="inherit":
4741 vars["defaultInheritRoom"]="checked"
4743 elif vars.get("roomAction","")=="define":
4744 vars["defaultDefineRoom"]="checked"
4745 roomName
= vars.get( "bookedRoomName" ) or vars.get("roomName","")
4746 elif vars.get("roomAction","")=="exist":
4747 vars["defaultExistRoom"]="checked"
4748 roomName
= vars.get("exists", "") or vars.get("roomName","")
4750 vars["defaultInheritRoom"]="checked"
4756 roomsexist
= self
._conf
.getRoomList()
4758 for room
in roomsexist
:
4761 sel
="selected=\"selected\""
4762 rx
.append("""<option value=%s %s>%s</option>"""%(quoteattr(str(room
)),
4763 sel
,self
.htmlText(room
)))
4764 vars ["roomsexist"] = "".join(rx
)
4765 confRoom
=self
._conf
.getConference().getRoom()
4767 vars["confRoom"]=self
.htmlText(confRoom
.getName())
4768 vars["roomName"]=quoteattr(str(roomName
))
4770 vars["autoUpdate"]=""
4771 if not self
._conf
.getEnableSessionSlots():
4772 vars["disabled"] = "disabled"
4774 vars["disabled"] = ""
4775 if self
._title
.find("Ed") != -1 and self
._conf
.getEnableSessionSlots():
4776 vars["adjustSlots"]= i18nformat("""<input type="checkbox" name="slmove" value="1"> _("Also move timetable entries")""")
4778 vars["adjustSlots"]="""<input type="hidden" name="slmove" value="1">"""
4779 import MaKaC
.webinterface
.webFactoryRegistry
as webFactoryRegistry
4780 wr
= webFactoryRegistry
.WebFactoryRegistry()
4781 wf
= wr
.getFactory(self
._conf
)
4786 if type == "conference":
4787 vars["Type"]=WSessionModEditDataType().getHTML(vars)
4788 vars["Colors"]=WSessionModEditDataColors().getHTML(vars)
4789 vars["code"]=WSessionModEditDataCode().getHTML(vars)
4796 #--------------------------------------------------------------------------------------
4798 class WConfModMoveContribsToSessionConfirmation(WTemplated
):
4800 def __init__(self
,conf
,contribIdList
=[],targetSession
=None):
4802 self
._contribIdList
=contribIdList
4803 self
._targetSession
=targetSession
4805 def _getWarningsHTML(self
):
4807 for id in self
._contribIdList
:
4808 contrib
=self
._conf
.getContributionById(id)
4812 for spk
in contrib
.getSpeakerList():
4813 spkList
.append(self
.htmlText(spk
.getFullName()))
4816 spkCaption
=" by %s"%"; ".join(spkList
)
4817 if (contrib
.getSession() is not None and \
4818 contrib
.getSession()!=self
._targetSession
):
4820 if contrib
.isScheduled():
4821 scheduled
= i18nformat(""" _("and scheduled") (%s)""")%self
.htmlText(contrib
.getStartDate().strftime("%Y-%b-%d %H:%M"))
4822 wl
.append( i18nformat("""
4823 <li>%s-<i>%s</i>%s: is <font color="red"> _("already in session") <b>%s</b>%s</font></li>
4824 """)%(self
.htmlText(contrib
.getId()),
4825 self
.htmlText(contrib
.getTitle()),
4827 self
.htmlText(contrib
.getSession().getTitle()),
4829 if (contrib
.getSession() is None and \
4830 self
._targetSession
is not None and \
4831 contrib
.isScheduled()):
4832 wl
.append( i18nformat("""
4833 <li>%s-<i>%s</i>%s: is <font color="red"> _("scheduled") (%s)</font></li>
4834 """)%(self
.htmlText(contrib
.getId()),
4835 self
.htmlText(contrib
.getTitle()),
4837 self
.htmlText(contrib
.getStartDate().strftime("%Y-%b-%d %H:%M"))))
4838 return "<ul>%s</ul>"%"".join(wl
)
4841 vars=WTemplated
.getVars(self
)
4842 vars["postURL"]=quoteattr(str(vars["postURL"]))
4843 vars["systemIconWarning"]=Config
.getInstance().getSystemIconURL("warning")
4844 vars["contribIdList"]=", ".join(self
._contribIdList
)
4845 vars["targetSession"]="--none--"
4846 if self
._targetSession
is not None:
4847 vars["targetSession"]=self
.htmlText("%s"%self
._targetSession
.getTitle())
4848 vars["warnings"]=self
._getWarningsHTML
()
4849 vars["targetSessionId"]=quoteattr("--none--")
4850 if self
._targetSession
is not None:
4851 vars["targetSessionId"]=quoteattr(str(self
._targetSession
.getId()))
4853 for id in self
._contribIdList
:
4854 l
.append("""<input type="hidden" name="contributions" value=%s">"""%quoteattr(str(id)))
4855 vars["contributions"]="\n".join(l
)
4859 class WConfTBDrawer
:
4861 def __init__(self
,tb
):
4865 if self
._tb
is None:
4868 for item
in self
._tb
.getItemList():
4869 if not item
.isEnabled():
4872 <td align="right" nowrap><a href=%s><img src=%s alt=%s></a></td>
4873 """%(quoteattr(str(item
.getActionURL())),
4874 quoteattr(str(item
.getIcon())),
4875 quoteattr(item
.getCaption())))
4878 <table cellpadding="0" cellspacing="1">
4886 class WErrorMessage
:
4888 def getHTML( self
, vars ):
4890 if vars.get("errorMsg", None) is None :
4892 if type(vars["errorMsg"]) != list:
4893 vars["errorMsg"]=[vars["errorMsg"]]
4894 for i
in range(0,len(vars["errorMsg"])) :
4895 vars["errorMsg"][i
] = """<span style="color: red;">"""+vars["errorMsg"][i
]+"""</span>"""
4898 """.join(vars["errorMsg"])
4901 <div class="errorMsgBox">
4908 class WInfoMessage
:
4910 def getHTML( self
, vars ):
4911 if vars.get("infoMsg", None) is None :
4913 if type(vars["infoMsg"]) != list:
4914 vars["infoMsg"]=[vars["infoMsg"]]
4915 for i
in range(0,len(vars["infoMsg"])) :
4916 vars["infoMsg"][i
] = """<span style="color: green;">"""+vars["infoMsg"][i
]+"""</span>"""
4919 """.join(vars["infoMsg"])
4922 <div class="errorMsgBox">
4929 class WConfTickerTapeDrawer(WTemplated
):
4931 def __init__(self
,conf
, tz
=None):
4934 dm
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
, False)
4935 self
._tickerTape
= dm
.getTickerTape()
4937 def getNowHappeningHTML( self
, params
=None ):
4938 if not self
._tickerTape
.isActive():
4941 html
= WTemplated
.getHTML( self
, params
)
4948 def getSimpleText( self
):
4949 if not self
._tickerTape
.isSimpleTextEnabled() or \
4950 self
._tickerTape
.getText().strip() == "":
4953 return self
._tickerTape
.getText()
4956 vars = WTemplated
.getVars( self
)
4958 vars["nowHappeningArray"] = None
4959 if self
._tickerTape
.isNowHappeningEnabled():
4960 vars["nowHappeningArray"] = self
._getNowHappening
()
4964 def _getNowHappening( self
):
4965 # This will contain a string formated for use in the template
4967 nowHappeningArray
= None
4969 # currently happening:
4971 entries
= self
._conf
.getSchedule().getEntriesOnDate(n
)
4973 for entry
in entries
:
4974 if isinstance(entry
, schedule
.LinkedTimeSchEntry
) and \
4975 isinstance(entry
.getOwner(), conference
.SessionSlot
):
4977 ssEntries
=ss
.getSchedule().getEntriesOnDate(n
)
4978 if isinstance(ss
.getSchedule(), conference
.PosterSlotSchedule
):
4979 ssEntries
=ss
.getSchedule().getEntries()
4980 for ssEntry
in ssEntries
:
4981 title
=ssEntry
.getTitle()
4982 if isinstance(ssEntry
.getOwner(), conference
.Contribution
):
4983 title
="""<a href=%s>%s</a>"""%( \
4984 quoteattr(str(urlHandlers
.UHContributionDisplay
.getURL(ssEntry
.getOwner()))), title
)
4986 title
="""<a href=%s>%s</a>"""%( \
4987 quoteattr(str(urlHandlers
.UHSessionDisplay
.getURL(ssEntry
.getOwner()))), title
)
4988 if ssEntry
.getOwnRoom() is not None:
4989 if self
._conf
.getRoom() is None or \
4990 ssEntry
.getOwnRoom().getName().strip().lower() != self
._conf
.getRoom().getName().strip().lower():
4991 title
="%s (%s)"%(title
, ssEntry
.getOwnRoom().getName().strip())
4992 entryCaptions
.append("%s <em>%s-%s</em>" %(title
,
4993 entry
.getAdjustedStartDate(self
._tz
).strftime("%H:%M"), \
4994 entry
.getAdjustedEndDate(self
._tz
).strftime("%H:%M")))
4996 title
=entry
.getTitle()
4997 if isinstance(entry
.getOwner(), conference
.Contribution
):
4998 title
="""<a href=%s>%s</a>"""%(quoteattr(str(urlHandlers
.UHContributionDisplay
.getURL(entry
.getOwner()))), title
)
5000 url
=urlHandlers
.UHConferenceTimeTable
.getURL(self
._conf
)
5001 url
.addParam("showDate",entry
.getStartDate().strftime("%d-%B-%Y"))
5002 title
="""<a href=%s>%s</a>"""%(quoteattr(str(url
)), title
)
5003 if entry
.getOwnRoom() is not None:
5004 if self
._conf
.getRoom() is None or \
5005 entry
.getOwnRoom().getName().strip().lower() != self
._conf
.getRoom().getName().strip().lower():
5006 title
="%s (%s)"%(title
, entry
.getOwnRoom().getName().strip())
5007 entryCaptions
.append("%s <em>%s-%s</em>" %(title
,
5008 entry
.getAdjustedStartDate(self
._tz
).strftime("%H:%M"), \
5009 entry
.getAdjustedEndDate(self
._tz
).strftime("%H:%M")))
5010 if entryCaptions
!=[]:
5011 nowHappeningArray
= """['%s']""" %("', '".join(entryCaptions
))
5013 return nowHappeningArray
5015 class WSubmitMaterialLink(WTemplated
):
5017 def __init__(self
, filenb
, availMF
):
5019 self
._availMF
=availMF
5022 vars=WTemplated
.getVars(self
)
5023 vars["itemNumber"]=self
._filenb
5024 vars["materialTypeSelectFieldName"]="LinkType%s"%self
._filenb
5025 vars["materialTypeInputFieldName"]="LinkTypeFT%s"%self
._filenb
5026 vars["urlFieldName"]="link%s"%self
._filenb
5027 l
=[ i18nformat("""<option value="notype">--_("Select a type")--</option>""")]
5028 selMatType
=vars.get("LinkType%s" % self
._filenb
,"")
5029 for mf
in self
._availMF
:
5032 title
= mf
.getTitle()
5035 title
= mf
.capitalize()
5038 selected
=" selected"
5039 l
.append("""<option value=%s%s>%s</option>"""%(\
5040 quoteattr(str(id)),selected
,
5041 self
.htmlText(title
)))
5042 vars["matTypeItems"]="".join(l
)
5043 if vars.get("LinkTypeFT%s" % self
._filenb
, "") != "":
5044 vars["materialTypeInputFieldValue"] = vars.get("LinkTypeFT%s" % self
._filenb
, "")
5046 vars["materialTypeInputFieldValue"] = ""
5047 if vars.get("link%s" % self
._filenb
, "") != "":
5048 vars["linkValue"] = vars.get("link%s" % self
._filenb
, "")
5050 vars["linkValue"] = ""
5053 class WSubmitMaterialFile(WTemplated
):
5055 def __init__(self
, filenb
, availMF
):
5057 self
._availMF
=availMF
5060 vars=WTemplated
.getVars(self
)
5061 vars["itemNumber"]=self
._filenb
5062 vars["materialTypeSelectFieldName"]="FileType%s"%self
._filenb
5063 vars["materialTypeInputFieldName"]="FileTypeFT%s"%self
._filenb
5064 vars["fileFieldName"]="file%s"%self
._filenb
5065 l
=[ i18nformat("""<option value="notype">--_("Select a type")--</option>""")]
5066 selMatType
=vars.get("FileType%s" % self
._filenb
,"")
5067 for mf
in self
._availMF
:
5070 title
= mf
.getTitle()
5073 title
= mf
.capitalize()
5076 selected
=" selected"
5077 l
.append("""<option value=%s%s>%s</option>"""%(\
5078 quoteattr(str(id)),selected
,
5079 self
.htmlText(title
)))
5080 vars["matTypeItems"]="".join(l
)
5081 if vars.get("FileTypeFT%s" % self
._filenb
, "") != "":
5082 vars["materialTypeInputFieldValue"] = vars.get("FileTypeFT%s" % self
._filenb
, "")
5084 vars["materialTypeInputFieldValue"] = ""
5085 if vars.get("FileNewName%s" % self
._filenb
, "") != "":
5086 vars["fileName"] = vars.get("FileNewName%s" % self
._filenb
)
5088 vars["fileName"] = ""
5089 vars["fileNewName"] = "FileNewName%s" % self
._filenb
5092 class WMaterialListFile(WTemplated
):
5094 def __init__(self
, target
):
5098 vars=WTemplated
.getVars(self
)
5100 name
=self
._target
.getFileName()
5102 name
=self
._target
.getURL()
5103 vars["fileName"]=name
5104 if self
._target
.getName()!="" and name
!=self
._target
.getName():
5105 vars["fileName"]+=" (%s)" % self
._target
.getName()
5106 vars["fileActions"] = ""
5107 if isinstance(self
._target
, conference
.Link
):
5108 if vars["resourcesLinkModifHandler"]:
5109 vars["fileActions"] += """<a href="%s"><img src="%s" alt="Edit" style="margin-left: 5px; vertical-align:middle" /></a>"""%(vars["resourcesLinkModifHandler"].getURL(self
._target
), Config
.getInstance().getSystemIconURL("file_edit"))
5110 if vars["resourcesLinkProtectHandler"]:
5111 vars["fileActions"] += """<a href="%s"><img src="%s" alt="Protect" style="margin-left: 5px; vertical-align:middle" /></a>"""%(vars["resourcesLinkProtectHandler"].getURL(self
._target
), Config
.getInstance().getSystemIconURL("file_protect"))
5112 elif isinstance(self
._target
, conference
.LocalFile
):
5113 if vars["resourcesFileModifHandler"]:
5114 vars["fileActions"] += """<a href="%s"><img src="%s" alt="Edit" style="margin-left: 5px; vertical-align:middle" /></a>"""%(vars["resourcesFileModifHandler"].getURL(self
._target
), Config
.getInstance().getSystemIconURL("file_edit"))
5115 if vars["resourcesFileProtectHandler"]:
5116 vars["fileActions"] += """<a href="%s"><img alt="Protected" src="%s" style="margin-left: 5px; vertical-align:middle"/></a>"""%(vars["resourcesFileProtectHandler"].getURL(self
._target
), Config
.getInstance().getSystemIconURL("file_protect"))
5117 vars["deleteIconURL"]=Configuration
.Config
.getInstance().getSystemIconURL("smallDelete")
5118 vars["delName"]="delete-%s-%s"% (self
._target
.getOwner().getId(),self
._target
.getId())
5120 vars["fileInfo"]="[%s bytes - %s]" % (self
._target
.getSize(),self
._target
.getCreationDate().strftime("%d.%m.%Y %H:%M:%S"))
5122 vars["fileInfo"]="[link]"
5123 if self
._target
.isProtected():
5124 vars["fileActions"] += """<img src="%s" alt="Protected" style="vertical-align: middle; border: 0;">""" % Config
.getInstance().getSystemIconURL("protected")
5125 if isinstance(self
._target
, conference
.Link
):
5126 vars["fileAccessURL"]=quoteattr(str(self
._target
.getURL()))
5128 vars["fileAccessURL"]=quoteattr(str(urlHandlers
.UHFileAccess
.getURL(self
._target
)))
5131 class WMaterialListItem(WTemplated
):
5133 def __init__(self
, target
, returnURL
=""):
5135 self
._returnURL
= returnURL
.strip('"')
5138 vars=WTemplated
.getVars(self
)
5141 from MaKaC
.webinterface
.materialFactories
import ConfMFRegistry
,SessionMFRegistry
,ContribMFRegistry
5142 if isinstance(self
._target
.getOwner(),conference
.Conference
):
5143 mf
=ConfMFRegistry().get(self
._target
)
5144 deleteURL
= urlHandlers
.UHConferenceRemoveMaterials
.getURL(self
._target
)
5145 elif isinstance(self
._target
.getOwner(),conference
.Session
):
5146 mf
=SessionMFRegistry().get(self
._target
)
5147 deleteURL
= urlHandlers
.UHSessionRemoveMaterials
.getURL(self
._target
)
5148 elif isinstance(self
._target
.getOwner(),conference
.Contribution
):
5149 mf
=ContribMFRegistry().get(self
._target
)
5150 contrib
=self
._target
.getOwner()
5151 deleteURL
= urlHandlers
.UHContributionRemoveMaterials
.getURL(self
._target
)
5152 elif isinstance(self
._target
.getOwner(),conference
.SubContribution
):
5153 mf
=ContribMFRegistry().get(self
._target
)
5154 deleteURL
= urlHandlers
.UHSubContributionRemoveMaterials
.getURL(self
._target
)
5155 elif isinstance(self
._target
.getOwner(),conference
.Category
):
5156 deleteURL
= urlHandlers
.UHCategoryRemoveMaterial
.getURL(self
._target
)
5158 deleteURL
.addParam("returnURL",self
._returnURL
)
5159 vars["materialName"] = self
._target
.getTitle()
5160 vars["materialActions"] = ""
5161 vars["materialActions"] += """<a href="%s" onClick="return confirm('Are you sure you want to delete all files of this type?');"><img src="%s" alt="Delete" style="margin-left: 5px; vertical-align:middle;"></a>""" % (str(deleteURL
),Config
.getInstance().getSystemIconURL("smallDelete"))
5162 if vars["materialModifHandler"]:
5163 vars["materialActions"] += """<a href="%s"><img src="%s" alt="Edit" style="margin-left: 5px; vertical-align:middle;"></a>""" % (urlHandlers
.UHMaterialModification
.getURL(self
._target
),Config
.getInstance().getSystemIconURL("file_edit"))
5164 if vars["materialProtectHandler"]:
5165 vars["materialActions"] += """<a href="%s"><img src="%s" alt="Protect" style="margin-left: 5px; vertical-align:middle;" /></a>""" % (vars["materialProtectHandler"].getURL(self
._target
),Config
.getInstance().getSystemIconURL("file_protect"))
5166 if self
._target
.isProtected():
5167 vars["materialActions"] += """<img src="%s" alt="Protected" style="margin-left: 5px; vertical-align: middle; border: 0;" />""" % Config
.getInstance().getSystemIconURL("protected")
5169 for resource
in self
._target
.getResourceList():
5170 vars["fileList"] += WMaterialListFile(resource
).getHTML(vars)
5172 vars["materialIcon"]=quoteattr(str(Config
.getInstance().getSystemIconURL("material")))
5174 vars["materialIcon"]=quoteattr(str(mf
.getIconURL()))
5178 class WShowExistingMaterial(WTemplated
):
5180 def __init__(self
,target
, mode
='display', showTitle
=True):
5182 mode should be 'display' or 'management'
5186 self
._showTitle
= showTitle
5190 vars=WTemplated
.getVars(self
)
5192 # yes, this may look a bit redundant, but materialRegistry isn't
5193 # bound to a particular target
5194 materialRegistry
= self
._target
.getMaterialRegistry()
5195 vars["materialList"] = materialRegistry
.getMaterialList(self
._target
)
5199 vars["existingMaterialsTitle"] = """ <div class="groupTitle" id="title">%s</div>""" % _("Existing material")
5201 vars["existingMaterialsTitle"] = " "
5202 vars["materialModifHandler"] = vars.get("materialModifHandler", None)
5203 vars["materialProtectHandler"] = vars.get("materialProtectHandler", None)
5204 vars["resourcesFileModifHandler"] = vars.get("resourcesFileModifHandler", None)
5205 vars["resourcesFileProtectHandler"] = vars.get("resourcesFileProtectHandler", None)
5206 vars["resourcesLinkModifHandler"] = vars.get("resourcesLinkModifHandler", None)
5207 vars["resourcesLinkProtectHandler"] = vars.get("resourcesLinkProtectHandler", None)
5208 vars['mode'] = self
._mode
5212 class WShowExistingReviewingMaterial(WTemplated
):
5214 def __init__(self
,target
,showTitle
=True, showSendButton
=False):
5216 self
._showTitle
=showTitle
5217 self
._showSendButton
= showSendButton
5221 vars=WTemplated
.getVars(self
)
5224 vars["existingMaterialsTitle"] = """ <div class="groupTitle" id="title">%s</div>""" % _("Existing Reviewing material")
5226 vars["existingMaterialsTitle"] = " "
5227 vars["materialModifHandler"] = vars.get("materialModifHandler", None)
5228 vars["materialProtectHandler"] = vars.get("materialProtectHandler", None)
5229 vars["resourcesFileModifHandler"] = vars.get("resourcesFileModifHandler", None)
5230 vars["resourcesFileProtectHandler"] = vars.get("resourcesFileProtectHandler", None)
5231 vars["resourcesLinkModifHandler"] = vars.get("resourcesLinkModifHandler", None)
5232 vars["resourcesLinkProtectHandler"] = vars.get("resourcesLinkProtectHandler", None)
5233 # This var shows you if you are requesting the template from the contribution display (True)
5234 # or from the paper reviewing tab in the contribution (False), as consequence you will have (or not)
5236 vars["showSendButton"] = self
._showSendButton
5240 class WAddNewMaterial(WTemplated
):
5242 def __init__(self
,target
,availMF
):
5244 self
._availMF
=availMF
5246 def _getErrorHTML(self
,errorList
):
5247 if len(errorList
)==0:
5254 <td colspan="2" align="center">
5255 <table bgcolor="red">
5257 <td bgcolor="white">
5258 <font color="red">%s</font>
5267 """%("<br>".join(errorList
))
5269 def _getTargetName(self
):
5270 if isinstance(self
._target
, conference
.Contribution
):
5271 return "Contribution"
5272 elif isinstance(self
._target
, conference
.SubContribution
):
5273 return "Subcontribution"
5274 elif isinstance(self
._target
, conference
.Conference
):
5279 vars=WTemplated
.getVars(self
)
5280 nbFiles
=int(vars.get("nbFiles",1))
5281 nbLinks
=int(vars.get("nbLinks",1))
5282 vars["targetName"]=self
._getTargetName
()
5283 vars["targetId"]=self
.htmlText(self
._target
.getId())
5284 vars["targetTitle"]=self
.htmlText(self
._target
.getTitle())
5286 vars["selectNumberOfFiles"] = ""
5287 for i
in range(1,10):
5289 vars["selectNumberOfFiles"] += "<option selected>%s" % i
5291 vars["selectNumberOfFiles"] += "<option>%s" % i
5292 vars["fileSubmitForms"] = ""
5293 for i
in range(1,nbFiles
+1):
5294 vars["fileSubmitForms"] += WSubmitMaterialFile(i
,self
._availMF
).getHTML(vars)
5295 vars["selectNumberOfLinks"] = ""
5296 for i
in range(1,10):
5298 vars["selectNumberOfLinks"] += "<option selected>%s" % i
5300 vars["selectNumberOfLinks"] += "<option>%s" % i
5301 vars["linkSubmitForms"] = ""
5302 for i
in range(1,nbLinks
+1):
5303 vars["linkSubmitForms"] += WSubmitMaterialLink(i
,self
._availMF
).getHTML(vars)
5304 vars["conversion"]=""
5305 if Configuration
.Config
.getInstance().hasFileConverter():
5306 vars["conversion"]="""
5308 <td class="titleCellTD"><span class="titleCellFormat">To PDF</span></td>
5309 <td><input type="checkbox" name="topdf" checked="checked">Automatic conversion to pdf (when applicable)? (PPT, DOC)</td>
5312 vars["errors"]=self
._getErrorHTML
(vars.get("errorList",[]))
5314 vars["CancelButton"] = """<input type="submit" name="CANCEL" value="cancel" class="btn">"""
5316 vars["CancelButton"] = ""
5319 class WSubmitMaterial(WTemplated
):
5321 def __init__(self
,target
,availMF
):
5323 self
._availMF
=availMF
5325 def _getErrorHTML(self
,errorList
):
5326 if len(errorList
)==0:
5333 <td colspan="2" align="center">
5334 <table bgcolor="red">
5336 <td bgcolor="white">
5337 <font color="red">%s</font>
5346 """%("<br>".join(errorList
))
5348 def _getTargetName(self
):
5349 if isinstance(self
._target
, conference
.Contribution
):
5350 return "Contribution"
5351 elif isinstance(self
._target
, conference
.SubContribution
):
5352 return "Subcontribution"
5353 elif isinstance(self
._target
, conference
.Conference
):
5358 vars=WTemplated
.getVars(self
)
5359 nbFiles
=int(vars.get("nbFiles",1))
5360 nbLinks
=int(vars.get("nbLinks",1))
5361 vars["targetName"]=self
._getTargetName
()
5362 vars["targetId"]=self
.htmlText(self
._target
.getId())
5363 vars["targetTitle"]=self
.htmlText(self
._target
.getTitle())
5364 vars["materialModifHandler"] = vars.get("materialModifHandler", None)
5365 vars["materialProtectHandler"] = vars.get("materialProtectHandler", None)
5366 vars["resourcesFileModifHandler"] = vars.get("resourcesFileModifHandler", None)
5367 vars["resourcesFileProtectHandler"] = vars.get("resourcesFileProtectHandler", None)
5368 vars["resourcesLinkModifHandler"] = vars.get("resourcesLinkModifHandler", None)
5369 vars["resourcesLinkProtectHandler"] = vars.get("resourcesLinkProtectHandler", None)
5370 vars["iconProtected"] = Config
.getInstance().getSystemIconURL("protected")
5371 vars["iconDelete"] = Config
.getInstance().getSystemIconURL("smallDelete")
5372 vars["iconKey"] = ""
5373 if vars["materialModifHandler"] or vars["resourcesFileModifHandler"] or vars["resourcesLinkModifHandler"]:
5374 vars["iconKey"] += i18nformat(""" <img src=%s style="vertical-align:middle; margin: 1px;"> _("edit")""") % Config
.getInstance().getSystemIconURL("file_edit")
5375 if vars["materialProtectHandler"] or vars["resourcesFileProtectHandler"] or vars["resourcesLinkProtectHandler"]:
5376 vars["iconKey"] += i18nformat(""" <img src=%s style="vertical-align:middle; margin: 1px;"> _("protect")""") % Config
.getInstance().getSystemIconURL("file_protect")
5377 vars["materialList"] = "<table>"
5378 materialList
= self
._target
.getAllMaterialList()
5379 for material
in materialList
:
5380 vars["materialList"] += WMaterialListItem(material
,vars["postURL"]).getHTML(vars)
5381 vars["materialList"] += "</table>"
5382 vars["selectNumberOfFiles"] = ""
5383 for i
in range(1,10):
5385 vars["selectNumberOfFiles"] += "<option selected>%s" % i
5387 vars["selectNumberOfFiles"] += "<option>%s" % i
5388 vars["fileSubmitForms"] = ""
5389 for i
in range(1,nbFiles
+1):
5390 vars["fileSubmitForms"] += WSubmitMaterialFile(i
,self
._availMF
).getHTML(vars)
5391 vars["selectNumberOfLinks"] = ""
5392 for i
in range(1,10):
5394 vars["selectNumberOfLinks"] += "<option selected>%s" % i
5396 vars["selectNumberOfLinks"] += "<option>%s" % i
5397 vars["linkSubmitForms"] = ""
5398 for i
in range(1,nbLinks
+1):
5399 vars["linkSubmitForms"] += WSubmitMaterialLink(i
,self
._availMF
).getHTML(vars)
5400 vars["conversion"]=""
5401 if Configuration
.Config
.getInstance().hasFileConverter():
5402 vars["conversion"]= i18nformat("""
5404 <td nowrap class="titleCellTD"><span class="titleCellFormat">To PDF</span></td>
5405 <td align="left"><input type="checkbox" name="topdf" checked="checked"> _("Automatic conversion to pdf (when applicable)? (PPT, DOC)")</td>
5408 vars["errors"]=self
._getErrorHTML
(vars.get("errorList",[]))
5410 vars["CancelButton"] = i18nformat("""<input type="submit" name="CANCEL" value="_("cancel")" class="btn">""")
5412 vars["CancelButton"] = ""
5416 class WSchRelocateTime(WTemplated
):
5419 vars = WTemplated
.getVars(self
)
5423 class WSchRelocate(WTemplated
):
5425 def __init__(self
, entry
):
5427 if isinstance(self
._entry
, conference
.Contribution
):
5428 self
._conf
= self
._entry
.getConference()
5431 self
._conf
= self
._entry
.getSchedule().getOwner().getConference()
5433 def _getTargetPlaceHTML(self
):
5435 html
.append( i18nformat("""
5436 <tr><td><input type="radio" name="targetId" value="conf"></td><td colspan="3" width="100%%"><b> _("Top timetable (within no session)")</b></td></tr>
5437 <tr><td colspan="4"><hr></td></tr>
5439 sessionList
=self
._conf
.getSessionList()
5440 sessionList
.sort(conference
.Session
._cmpTitle
)
5441 for session
in sessionList
:
5442 if len(session
.getSlotList())==1:
5444 <tr><td><input type="radio" name="targetId" value="%s:%s"></td><td colspan="3" style="background-color:%s;color:%s" width="100%%"> %s <b>%s</b></td></tr>
5445 """%(session
.getId(), session
.getSlotList()[0].getId(), session
.getColor(), session
.getTextColor(), session
.getStartDate().strftime("%d-%m-%Y"),session
.getTitle()) )
5448 <tr><td></td><td colspan="3" style="background-color:%s;" width="100%%">
5450 <tr><td colspan="2" width="100%%" style="color:%s"><b>%s:</b></td></tr>
5451 """%(session
.getColor(), session
.getTextColor(), session
.getTitle()) )
5452 for slotEntry
in session
.getSchedule().getEntries():
5453 slot
=slotEntry
.getOwner()
5455 <tr><td><input type="radio" name="targetId" value="%s:%s"></td><td width="100%%" style="color:%s">%s <small>(%s %s-%s)</small></td></tr>
5456 """%(session
.getId(), slot
.getId(), session
.getTextColor(), slot
.getTitle() or "[slot %s]"%slot
.getId(), slot
.getAdjustedStartDate().strftime("%d-%m-%Y"),\
5457 slot
.getAdjustedStartDate().strftime("%H:%M"), slot
.getAdjustedEndDate().strftime("%H:%M")) )
5458 html
.append("</table></td></tr>")
5459 return "".join(html
)
5463 vars = WTemplated
.getVars(self
)
5464 if isinstance(self
._entry
, conference
.Contribution
):
5465 vars["entryType"]="Contribution"
5467 vars["entryType"]=""
5468 vars["entryTitle"]=self
._entry
.getTitle()
5469 vars["targetPlace"]=self
._getTargetPlaceHTML
()
5470 vars["autoUpdate"]=""
5473 class WReportNumbersTable(WTemplated
):
5475 def __init__(self
, target
, type="event"):
5479 def _getCurrentItems(self
):
5481 rns
= self
._target
.getReportNumberHolder().listReportNumbers()
5490 if key
in Configuration
.Config
.getInstance().getReportNumberSystems().keys():
5491 name
=Configuration
.Config
.getInstance().getReportNumberSystems()[key
]["name"]
5492 reportCodes
.append((id, number
, name
))
5496 def _getSystems(self
):
5498 rnsystems
=Configuration
.Config
.getInstance().getReportNumberSystems()
5499 keys
=rnsystems
.keys()
5503 <option value="%s">%s</option>
5504 """%(system
, rnsystems
[system
]["name"] ) )
5505 return "".join(html
)
5508 vars = WTemplated
.getVars(self
)
5509 if self
._type
== "event":
5510 vars["deleteURL"]=quoteattr(str(urlHandlers
.UHConfModifReportNumberRemove
.getURL(self
._target
)))
5511 vars["addURL"]=quoteattr(str(urlHandlers
.UHConfModifReportNumberEdit
.getURL(self
._target
)))
5512 elif self
._type
== "contribution":
5513 vars["deleteURL"]=quoteattr(str(urlHandlers
.UHContributionReportNumberRemove
.getURL(self
._target
)))
5514 vars["addURL"]=quoteattr(str(urlHandlers
.UHContributionReportNumberEdit
.getURL(self
._target
)))
5516 vars["deleteURL"]=quoteattr(str(urlHandlers
.UHSubContributionReportNumberRemove
.getURL(self
._target
)))
5517 vars["addURL"]=quoteattr(str(urlHandlers
.UHSubContributionReportNumberEdit
.getURL(self
._target
)))
5518 vars["items"]=self
._getCurrentItems
()
5519 vars["repTypesSelectItems"]=self
._getSystems
()
5522 class WModifReportNumberEdit(WTemplated
):
5524 def __init__(self
, target
, rns
, type="event"):
5530 vars=WTemplated
.getVars(self
)
5531 vars["reportNumber"]=""
5532 vars["reportNumberSystem"]=self
._rnSystem
5534 if self
._rnSystem
in Config
.getInstance().getReportNumberSystems().keys():
5535 name
=Config
.getInstance().getReportNumberSystems()[self
._rnSystem
]["name"]
5537 if self
._type
== "event":
5538 vars["postURL"]=quoteattr(str(urlHandlers
.UHConfModifReportNumberPerformEdit
.getURL(self
._target
)))
5539 elif self
._type
== "contribution":
5540 vars["postURL"]=quoteattr(str(urlHandlers
.UHContributionReportNumberPerformEdit
.getURL(self
._target
)))
5542 vars["postURL"]=quoteattr(str(urlHandlers
.UHSubContributionReportNumberPerformEdit
.getURL(self
._target
)))
5546 # ============================================================================
5547 # === ROOM BOOKING RELATED ===================================================
5548 # ============================================================================
5550 # 2. In the context of an event
5552 from MaKaC
.rb_reservation
import ReservationBase
, Collision
, RepeatabilityEnum
5553 from MaKaC
.rb_factory
import Factory
5554 from MaKaC
.plugins
.RoomBooking
.default
.room
import Room
5555 from MaKaC
.rb_tools
import iterdays
5556 from calendar
import day_name
5557 from MaKaC
.rb_location
import Location
, CrossLocationFactory
5558 from indico
.util
.fossilize
import Fossilizable
, fossilizes
5559 from MaKaC
.fossils
.roomBooking
import IRoomBarFossil
, IBarFossil
5561 class Bar( Fossilizable
):
5563 Keeps data necessary for graphical bar on calendar.
5565 fossilizes(IBarFossil
)
5566 PREBOOKED
, PRECONCURRENT
, UNAVAILABLE
, CANDIDATE
, PRECONFLICT
, CONFLICT
= xrange( 0, 6 )
5567 # I know this names are not wisely choosed; it's due to unexpected additions
5568 # without refactoring
5569 # UNAVAILABLE : represents confirmed reservation (bright-red)
5570 # CANDIDATE: represents new reservation (green)
5571 # CONFLICT: overlap between candidate and confirmed resv. (dark red)
5572 # PREBOOKED: represents pre-reservation (yellow)
5573 # PRECONFLICT: represents conflict with pre-reservation (orange)
5574 # PRECONCURRENT: conflicting pre-reservations
5576 def __init__( self
, c
, barType
):
5577 self
.startDT
= c
.startDT
5578 self
.endDT
= c
.endDT
5579 self
.forReservation
= c
.withReservation
5582 def __cmp__( self
, obj
):
5583 return cmp( self
.type, obj
.type )
5585 class RoomBars( Fossilizable
):
5587 fossilizes(IRoomBarFossil
)
5592 def __init__( self
, room
, bars
):
5595 def __cmp__( self
, obj
):
5596 return cmp( self
.room
, obj
.room
)
5598 # ============================================================================
5599 # == FREESTANDING ==== (Room Booking Related) ================================
5600 # ============================================================================
5602 class WRoomBookingWelcome( WTemplated
):
5605 self
.__adminList
= AdminList
.getInstance()
5607 def getVars( self
):
5608 vars = WTemplated
.getVars( self
)
5611 class WRoomBookingRoomSelectList( WTemplated
):
5613 def __init__( self
, rh
):
5616 def getVars( self
):
5617 vars = WTemplated
.getVars( self
)
5619 vars['roomList'] = self
._rh
._roomList
5620 vars['locationRoom'] = self
._rh
._locationRoom
5624 class WRoomBookingRoomSelectList4SubEvents( WTemplated
):
5626 def __init__( self
, rh
):
5629 def getVars( self
):
5630 vars = WTemplated
.getVars( self
)
5632 vars['roomList'] = self
._rh
._roomList
5633 vars['locationRoom'] = self
._rh
._locationRoom
5637 # ============================================================================
5638 # == EVENT CONTEXT ==== (Room Booking Related) ===============================
5639 # ============================================================================
5642 # 0. Choosing an "event" (conference / session / contribution)...
5644 class WRoomBookingChooseEvent( WTemplated
):
5646 def __init__( self
, rh
):
5649 def getVars( self
):
5650 vars = WTemplated
.getVars( self
)
5652 vars["conference"] = self
._rh
._conf
5653 vars["contributions"] = list( [ c
for c
in self
._rh
._conf
.getContributionList() if c
.getStartDate() ] )
5659 class WRoomBookingSearch4Rooms( WTemplated
):
5661 def __init__( self
, rh
, standalone
= False ):
5662 self
._standalone
= standalone
5665 def getVars( self
):
5666 vars = WTemplated
.getVars( self
)
5668 websession
= self
._rh
._websession
5670 vars["standalone"] = self
._standalone
5672 vars["Location"] = Location
5673 vars["rooms"] = self
._rh
._rooms
5674 vars["possibleEquipment"] = self
._rh
._equipment
5675 vars["forNewBooking"] = self
._rh
._forNewBooking
5676 vars["eventRoomName"] = self
._rh
._eventRoomName
5677 vars["isResponsibleForRooms"] = Room
.isAvatarResponsibleForRooms(self
._rh
.getAW().getUser())
5679 vars["preview"] = False
5681 vars["startDT"] = websession
.getVar( "defaultStartDT" )
5682 vars["endDT"] = websession
.getVar( "defaultEndDT" )
5683 vars["startT"] = websession
.getVar( "defaultStartDT" ).time().strftime( "%H:%M" )
5684 vars["endT"] = websession
.getVar( "defaultEndDT" ).time().strftime( "%H:%M" )
5685 vars["repeatability"] = websession
.getVar( "defaultRepeatability" )
5687 if self
._standalone
:
5688 # URLs for standalone room booking
5689 vars["roomBookingRoomListURL"] = urlHandlers
.UHRoomBookingRoomList
.getURL( None )
5690 vars["detailsUH"] = urlHandlers
.UHRoomBookingRoomDetails
5691 vars["bookingFormUH"] = urlHandlers
.UHRoomBookingBookingForm
5693 # URLs for room booking in the event context
5694 vars["roomBookingRoomListURL"] = urlHandlers
.UHConfModifRoomBookingRoomList
.getURL( self
._rh
._conf
)
5695 vars["detailsUH"] = urlHandlers
.UHConfModifRoomBookingRoomDetails
5696 vars["bookingFormUH"] = urlHandlers
.UHConfModifRoomBookingBookingForm
5700 class WRoomBookingSearch4Bookings( WTemplated
):
5702 def __init__( self
, rh
):
5705 def getVars( self
):
5706 vars = WTemplated
.getVars( self
)
5708 vars["today"] = datetime
.now()
5709 vars["weekLater"] = datetime
.now() + timedelta( 7 )
5710 vars["Location"] = Location
5711 vars["rooms"] = self
._rh
._rooms
5712 vars["repeatability"] = None
5713 vars["isResponsibleForRooms"] = Room
.isAvatarResponsibleForRooms(self
._rh
.getAW().getUser())
5714 vars["roomBookingBookingListURL"] = urlHandlers
.UHRoomBookingBookingList
.getURL( None )
5718 class WRoomBookingMapOfRooms(WTemplated
):
5720 def __init__(self
, **params
):
5721 if params
is not None:
5722 self
._params
= params
5725 WTemplated
.__init
__(self
)
5728 vars = WTemplated
.getVars(self
)
5729 vars["mapOfRoomsWidgetURL"] = urlHandlers
.UHRoomBookingMapOfRoomsWidget
.getURL(None, **self
._params
)
5733 class WRoomBookingMapOfRoomsWidget(WTemplated
):
5735 def __init__(self
, aspects
, buildings
, defaultLocation
, forVideoConference
, roomID
):
5736 self
._aspects
= aspects
5737 self
._buildings
= buildings
5738 self
._defaultLocation
= defaultLocation
5739 self
._forVideoConference
= forVideoConference
5740 self
._roomID
= roomID
5743 vars = WTemplated
.getVars(self
)
5744 websession
= self
._rh
._websession
5746 vars["aspects"] = self
._aspects
5747 vars["buildings"] = self
._buildings
5748 vars["defaultLocation"] = self
._defaultLocation
5749 vars["forVideoConference"] = self
._forVideoConference
5750 vars["roomID"] = self
._roomID
5752 vars["roomBookingRoomListURL"] = urlHandlers
.UHRoomBookingRoomList
.getURL( None )
5753 vars["startDT"] = websession
.getVar( "defaultStartDT" )
5754 vars["endDT"] = websession
.getVar( "defaultEndDT" )
5755 vars["startT"] = websession
.getVar( "defaultStartDT" ).time().strftime( "%H:%M" )
5756 vars["endT"] = websession
.getVar( "defaultEndDT" ).time().strftime( "%H:%M" )
5757 vars["repeatability"] = websession
.getVar( "defaultRepeatability" )
5763 class WRoomBookingRoomList( WTemplated
):
5765 def __init__( self
, rh
, standalone
= False ):
5767 self
._standalone
= standalone
5769 try: self
._title
= self
._rh
._title
;
5772 def getVars( self
):
5773 vars=WTemplated
.getVars( self
)
5775 vars["rooms"] = self
._rh
._rooms
5776 vars["mapAvailable"] = self
._rh
._mapAvailable
5777 #vars["roomPhotoUH"] = urlHandlers.UHSendRoomPhoto
5778 vars["standalone"] = self
._standalone
5779 vars["title"] = self
._title
5781 if self
._standalone
:
5782 vars["detailsUH"] = urlHandlers
.UHRoomBookingRoomDetails
5783 vars["bookingFormUH"] = urlHandlers
.UHRoomBookingBookingForm
5785 vars["conference"] = self
._rh
._conf
5786 vars["detailsUH"] = urlHandlers
.UHConfModifRoomBookingRoomDetails
5787 vars["bookingFormUH"] = urlHandlers
.UHConfModifRoomBookingBookingForm
5791 class WRoomBookingList( WTemplated
):
5793 def __init__( self
, rh
, standalone
= False ):
5794 self
._standalone
= standalone
5797 self
._conf
= rh
._conf
5799 def getVars( self
):
5800 vars=WTemplated
.getVars( self
)
5802 vars["reservations"] = self
._rh
._resvs
5803 vars["standalone"] = self
._standalone
5804 dm
= datetime
.now() - timedelta( 1 )
5805 vars["yesterday"] = dm
#datetime( dm.year, dm.month, dm.day, 0, 0, 1 )
5807 if self
._standalone
:
5808 vars["bookingDetailsUH"] = urlHandlers
.UHRoomBookingBookingDetails
5810 vars["conference"] = self
._conf
5811 vars["bookingDetailsUH"] = urlHandlers
.UHConfModifRoomBookingDetails
5815 class WRoomBookingBookingList( WTemplated
): # Standalone version
5817 def __init__( self
, rh
):
5820 try: self
._title
= self
._rh
._title
;
5823 def _isOn(self
, boolVal
):
5829 def getVars( self
):
5830 vars = WTemplated
.getVars( self
)
5833 #vars["smallPhotoUH"] = urlHandlers.UHSendRoomPhoto
5834 vars["bookingDetailsUH"] = urlHandlers
.UHRoomBookingBookingDetails
5835 vars["withPhoto"] = False
5836 vars["title"] = self
._title
5837 vars["search"] = rh
._search
5838 vars["showRejectAllButton"] = rh
._showRejectAllButton
5840 vars["prebookingsRejected"] = rh
._prebookingsRejected
5841 vars["subtitle"] = rh
._subtitle
5842 vars["description"] = rh
._description
5843 yesterday
= datetime
.now() - timedelta( 1 )
5844 vars["yesterday"] = yesterday
#datetime( dm.year, dm.month, dm.day, 0, 0, 1 )
5847 sd
= rh
._resvEx
.startDT
.date()
5848 if rh
._resvEx
.endDT
:
5849 ed
= rh
._resvEx
.endDT
.date()
5851 # autoCriteria - dates are calculated based on the next reservation
5852 if rh
._autoCriteria
:
5853 tmp
= ReservationBase
.findSoonest( rh
._resvs
, afterDT
= yesterday
)
5855 tmp
= tmp
.getNextRepeating( afterDT
= yesterday
)
5856 if tmp
and tmp
.startDT
.date() > sd
:
5859 # one month of time span
5860 ed
= sd
+ timedelta( 30 )
5862 # set the calendar dates as calculated
5863 calendarStartDT
= datetime( sd
.year
, sd
.month
, sd
.day
, 0, 0, 1 )
5864 calendarEndDT
= datetime( ed
.year
, ed
.month
, ed
.day
, 23, 59 )
5866 from MaKaC
.rb_tools
import formatDate
5868 if calendarStartDT
.date() == calendarEndDT
.date():
5869 vars["periodName"] = "day"
5871 vars["periodName"] = "period"
5872 vars["startD"] = formatDate(calendarStartDT
)
5873 vars["endD"] = formatDate(calendarEndDT
)
5875 # Data for previous/next URLs (it's about periods, not paging)
5876 newParams4Previous
= rh
._reqParams
.copy()
5877 newParams4Next
= rh
._reqParams
.copy()
5878 if rh
._reqParams
.has_key( 'autoCriteria' ):
5879 del newParams4Previous
['autoCriteria']
5880 del newParams4Next
['autoCriteria']
5881 if rh
._reqParams
.has_key( 'day' ):
5882 del newParams4Previous
['day']
5883 del newParams4Next
['day']
5886 startD
= calendarStartDT
.date()
5887 endD
= calendarEndDT
.date()
5890 period
= endD
- startD
5892 prevStartD
= startD
- period
- timedelta(1)
5893 prevEndD
= startD
- timedelta(1)
5895 nextStartD
= endD
+ timedelta(1)
5896 nextEndD
= endD
+ period
+ timedelta(1)
5898 prevStartD
= prevEndD
= startD
- timedelta(1)
5899 nextStartD
= nextEndD
= endD
+ timedelta(1)
5901 newParams4Previous
['sDay'] = prevStartD
.day
5902 newParams4Previous
['sMonth'] = prevStartD
.month
5903 newParams4Previous
['sYear'] = prevStartD
.year
5904 newParams4Previous
['eDay'] = prevEndD
.day
5905 newParams4Previous
['eMonth'] = prevEndD
.month
5906 newParams4Previous
['eYear'] = prevEndD
.year
5908 newParams4Next
['sDay'] = nextStartD
.day
5909 newParams4Next
['sMonth'] = nextStartD
.month
5910 newParams4Next
['sYear'] = nextStartD
.year
5911 newParams4Next
['eDay'] = nextEndD
.day
5912 newParams4Next
['eMonth'] = nextEndD
.month
5913 newParams4Next
['eYear'] = nextEndD
.year
5915 vars["attributes"] = { }
5916 vars["withPrevNext"] = True
5917 vars["prevURL"] = urlHandlers
.UHRoomBookingBookingList
.getURL( newParams
= newParams4Previous
)
5918 vars["nextURL"] = urlHandlers
.UHRoomBookingBookingList
.getURL( newParams
= newParams4Next
)
5920 vars['overload'] = self
._rh
._overload
5922 # empty days are shown for "User bookings" and "User pre-bookings"
5923 # and for the calendar as well
5924 # but not for the booking search
5925 #showEmptyDays = ( self._rh._ofMyRooms or \
5926 # (not self._rh._ofMyRooms and not self._rh._onlyMy) ) and \
5927 # not self._rh._search
5928 #showEmptyRooms = showEmptyDays
5929 # Always show empty rooms/days
5930 showEmptyDays
= showEmptyRooms
= not self
._rh
._search
5933 # Calendar related stuff ==========
5936 collisionsOfResvs
= []
5938 # there's at least one reservation
5939 if len( rh
._resvs
) > 0:
5941 # Prepare the list of Collisions
5942 # (collision is just a helper object, it's not the best notion here)
5945 for p
in r
.splitToPeriods(endDT
=calendarEndDT
, startDT
=calendarStartDT
):
5946 if p
.startDT
>= calendarStartDT
and p
.endDT
<= calendarEndDT
:
5947 collisionsOfResvs
.append( Collision( ( p
.startDT
, p
.endDT
), r
) )
5949 # Translate collisions to Bars
5950 for c
in collisionsOfResvs
:
5951 if c
.withReservation
.isConfirmed
:
5952 bars
.append( Bar( c
, Bar
.UNAVAILABLE
) )
5954 bars
.append( Bar( c
, Bar
.PREBOOKED
) )
5956 bars
= barsList2Dictionary( bars
)
5957 bars
= addOverlappingPrebookings( bars
)
5958 bars
= sortBarsByImportance( bars
, calendarStartDT
, calendarEndDT
)
5960 rooms
= set(r
.room
for r
in rh
._resvs
)
5962 #CrossLocationQueries.getRooms( location = self.location )
5963 if not self
._rh
._onlyMy
:
5964 rooms
= self
._rh
._rooms
5966 bars
= introduceRooms( rooms
, bars
, calendarStartDT
, calendarEndDT
, showEmptyDays
= showEmptyDays
, showEmptyRooms
= showEmptyRooms
, user
= rh
._aw
.getUser() )
5970 self
.__sortUsingCriterion
(rh
._order
, collisionsOfResvs
)
5972 # we want to display every room, with or without reservation
5974 # initialize collision bars
5976 bars
= sortBarsByImportance( bars
, calendarStartDT
, calendarEndDT
)
5979 if not self
._rh
._onlyMy
:
5980 rooms
= self
._rh
._rooms
5984 bars
= introduceRooms( rooms
, bars
, calendarStartDT
, calendarEndDT
, showEmptyDays
= showEmptyDays
, showEmptyRooms
= showEmptyRooms
, user
= rh
._aw
.getUser() )
5988 cachedDayBars
= self
._rh
._dayBars
.get(str(key
))
5989 if not cachedDayBars
:
5990 fossilizedBars
[str(key
)] = [fossilize(bar
, IRoomBarFossil
) for bar
in bars
[key
]]
5992 fossilizedBars
[str(key
)] = cachedDayBars
5993 if self
._rh
._updateCache
:
5994 self
._rh
._cache
.set_multi(fossilizedBars
, 7200)
5996 for dayBars
in fossilizedBars
.itervalues():
5997 for roomBars
in dayBars
:
5998 for bar
in roomBars
['bars']:
5999 resvIds
.add(bar
['forReservation']['id'])
6000 numResvs
= len(resvIds
)
6001 vars["barsFossil"] = fossilizedBars
6002 vars["numResvs"] = numResvs
6003 vars["dayAttrs"] = fossilize({})
6004 vars["showEmptyRooms"] = showEmptyRooms
6005 vars["manyRooms"] = not self
._rh
._rooms
or len(self
._rh
._rooms
) > 1
6006 vars["calendarParams"] = {}
6007 if self
._title
and rh
._ofMyRooms
:
6008 vars["calendarParams"]["ofMyRooms"] ="on"
6010 vars["calendarParams"]["onlyMy"] = "on"
6012 vars["calendarParams"]["roomGUID"] = "allRooms"
6014 for room
in rh
._roomGUIDs
:
6015 vars["calendarParams"]["roomGUID"]= room
6016 if rh
._onlyPrebookings
:
6017 vars["calendarParams"]["onlyPrebookings"] = "on"
6018 if rh
._onlyBookings
:
6019 vars["calendarParams"]["onlyBookings"] ="on"
6021 vars["calendarFormUrl"] = urlHandlers
.UHRoomBookingBookingList
.getURL()
6026 def __sortUsingCriterion(self
, order
, uresvs
):
6028 if order
== "" or order
=="room":
6029 # standard sorting order (by room, and then date)
6030 uresvs
.sort(lambda r1
,r2
: cmp(r1
.withReservation
.room
.name
,r2
.withReservation
.room
.name
))
6033 uresvs
.sort(lambda r1
, r2
: cmp(r1
.startDT
, r2
.startDT
))
6034 elif order
== 'reason':
6035 uresvs
.sort(lambda r1
, r2
: cmp(r1
.withReservation
.reason
.lower(), r2
.withReservation
.reason
.lower()))
6036 elif order
== 'for':
6037 uresvs
.sort(lambda r1
, r2
: cmp(r1
.withReservation
.bookedForName
.lower(), r2
.withReservation
.bookedForName
.lower()))
6038 elif order
== 'hours':
6039 uresvs
.sort(lambda r1
, r2
: cmp(r1
.startDT
.time(), r2
.startDT
.time()))
6044 def barsList2Dictionary( bars
):
6047 list of bars => dictionary of bars, key = datetime, value = list of bars
6051 d
= bar
.startDT
.date()
6058 def addOverlappingPrebookings( bars
):
6060 Adds bars representing overlapping pre-bookings.
6061 Returns new bars dictionary.
6065 for dt
in bars
.keys():
6068 # For each (prebooked) bar i
6069 for i
in xrange( 0, len( dayBars
) ):
6071 if bar
.type == Bar
.PREBOOKED
:
6073 # For each (prebooked) bar j
6074 for j
in xrange( i
+1, len( dayBars
) ):
6075 collCand
= dayBars
[j
]
6076 if collCand
.type == Bar
.PREBOOKED
:
6078 # If there is an overlap, add PRECONCURRENT bar
6079 over
= overlap( bar
.startDT
, bar
.endDT
, collCand
.startDT
, collCand
.endDT
)
6080 if over
and bar
.forReservation
.room
== collCand
.forReservation
.room
and collCand
.forReservation
!= bar
.forReservation
:
6081 collision
= Collision( over
, collCand
.forReservation
)
6082 dayBars
.append( Bar( collision
, Bar
.PRECONCURRENT
) )
6084 bars
[dt
] = dayBars
# With added concurrent prebooking bars
6088 def sortBarsByImportance( bars
, calendarStartDT
, calendarEndDT
):
6090 Moves conflict bars to the end of the list,
6091 so they will be drawn last and therefore be visible.
6093 Returns sorted bars.
6095 for dt
in bars
.keys():
6100 for day
in iterdays( calendarStartDT
, calendarEndDT
):
6101 if not bars
.has_key( day
.date() ):
6102 bars
[day
.date()] = []
6106 def getRoomBarsList( rooms
):
6111 roomBarsList
.append( RoomBars( room
, [] ) )
6115 def introduceRooms( rooms
, dayBarsDic
, calendarStartDT
, calendarEndDT
, showEmptyDays
=True, showEmptyRooms
=True, user
= None ):
6117 # dayBarsDic is a dictionary date => [bar1, bar2, bar3, ...]
6120 # newDayBarsDic is a dictionary date => [roomBars1, roomBars2, roomBars3, ...],
6121 # where roomBars is object JSON:{ room: RoomBase, bars: [bar1, bar2, bar3, ...] }
6123 #cleanRoomBarsList = getRoomBarsList( rooms )
6125 from MaKaC
.common
.utils
import formatDate
6126 for day
in iterdays( calendarStartDT
, calendarEndDT
):
6127 dayBars
= dayBarsDic
[day
.date()]
6130 bar
.canReject
= bar
.forReservation
.id is not None and bar
.forReservation
.canReject(user
)
6131 if bar
.forReservation
.repeatability
!= None:
6132 bar
.rejectURL
= str(urlHandlers
.UHRoomBookingRejectBookingOccurrence
.getURL( bar
.forReservation
, formatDate(bar
.startDT
.date()) ))
6134 bar
.rejectURL
= str(urlHandlers
.UHRoomBookingRejectBooking
.getURL( bar
.forReservation
))
6135 room
= bar
.forReservation
.room
6136 if not roomBarsDic
.has_key( room
):
6137 roomBarsDic
[room
] = []
6138 # Bars order should be preserved
6139 roomBarsDic
[room
].append( bar
)
6142 dayRoomBarsList
= getRoomBarsList( rooms
) #copy.copy( cleanRoomBarsList )
6144 for roomBar
in dayRoomBarsList
:
6145 roomBar
.bars
= roomBarsDic
.get( roomBar
.room
, [] )
6147 dayRoomBarsList
= []
6148 for room
in roomBarsDic
.keys():
6149 dayRoomBarsList
.append(RoomBars(room
,roomBarsDic
[room
]))
6151 if showEmptyDays
or len(dayBars
) > 0:
6152 newDayBarsDic
[day
.date()] = dayRoomBarsList
6154 return newDayBarsDic
6156 def getDayAttrsForRoom(dayDT
, room
):
6157 attrs
= {'tooltip': '', 'className': ''}
6158 roomBlocked
= room
.getBlockedDay(dayDT
)
6160 block
= roomBlocked
.block
6161 if roomBlocked
and block
.canOverride(ContextManager
.get('currentUser'), explicitOnly
=True):
6162 attrs
['className'] = "blocked_permitted"
6163 attrs
['tooltip'] = _('Blocked by %s:\n%s\n\n<b>You are permitted to override the blocking.</b>') % (block
.createdByUser
.getFullName(), block
.message
)
6164 elif roomBlocked
and roomBlocked
.active
is True:
6165 if block
.canOverride(ContextManager
.get('currentUser'), room
):
6166 attrs
['className'] = "blocked_override"
6167 attrs
['tooltip'] = _('Blocked by %s:\n%s\n\n<b>You own this room or are an administrator and are thus permitted to override the blocking. Please use this privilege with care!</b>') % (block
.createdByUser
.getFullName(), block
.message
)
6169 attrs
['className'] = "blocked"
6170 attrs
['tooltip'] = _('Blocked by %s:\n%s') % (block
.createdByUser
.getFullName(), block
.message
)
6171 elif roomBlocked
and roomBlocked
.active
is None:
6172 attrs
['className'] = "preblocked"
6173 attrs
['tooltip'] = _('Blocking requested by %s:\n%s\n\n<b>If this blocking is approved, any colliding bookings will be rejected!</b>') % (block
.createdByUser
.getFullName(), block
.message
)
6176 class WRoomBookingRoomStats( WTemplated
):
6178 def __init__( self
, rh
, standalone
= False ):
6180 self
._standalone
= standalone
6182 def getVars( self
):
6183 vars = WTemplated
.getVars( self
)
6184 vars["room"] = self
._rh
._room
6185 vars["standalone"] = self
._standalone
6186 vars["period"] = self
._rh
._period
6187 vars["kpiAverageOccupation"] = str( int( round( self
._rh
._kpiAverageOccupation
* 100 ) ) ) + "%"
6189 vars["kbiTotalBookings"] = self
._rh
._totalBookings
6191 vars["stats"] = self
._rh
._booking
_stats
6192 vars["statsURL"] = urlHandlers
.UHRoomBookingRoomStats
.getURL()
6196 class WRoomBookingRoomDetails( WTemplated
):
6198 def __init__( self
, rh
, standalone
= False ):
6200 self
._standalone
= standalone
6202 def getVars( self
):
6203 vars = WTemplated
.getVars( self
)
6204 vars["room"] = self
._rh
._room
6205 goodFactory
= Location
.parse( self
._rh
._room
.locationName
).factory
6206 attributes
= goodFactory
.getCustomAttributesManager().getAttributes( location
= self
._rh
._room
.locationName
)
6208 for attribute
in attributes
:
6209 if not attribute
.get("hidden",False) or self
._rh
._getUser
().isAdmin():
6210 vars["attrs"][attribute
['name']] = self
._rh
._room
.customAtts
.get(attribute
['name'],"")
6211 if attribute
['name'] == 'notification email' :
6212 vars["attrs"][attribute
['name']] = vars["attrs"][attribute
['name']].replace(',', ', ')
6213 vars["config"] = Config
.getInstance()
6214 #vars["roomPhoto"] = urlHandlers.UHSendRoomPhoto.getURL( self._rh._room.photoId, small = False )
6215 vars["standalone"] = self
._standalone
6216 vars["actionSucceeded"] = self
._rh
._afterActionSucceeded
6217 vars["deletionFailed"] = self
._rh
._afterDeletionFailed
6219 vars["roomStatsUH"] = urlHandlers
.UHRoomBookingRoomStats
6221 if self
._standalone
:
6222 vars["bookingFormUH"] = urlHandlers
.UHRoomBookingBookingForm
6223 vars["modifyRoomUH"] = urlHandlers
.UHRoomBookingRoomForm
6224 vars["deleteRoomUH"] = urlHandlers
.UHRoomBookingDeleteRoom
6225 vars["bookingDetailsUH"] = urlHandlers
.UHRoomBookingBookingDetails
6227 vars["bookingDetailsUH"] = urlHandlers
.UHConfModifRoomBookingDetails
6228 vars["conference"] = self
._rh
._conf
6229 vars["bookingFormUH"] = urlHandlers
.UHConfModifRoomBookingBookingForm
6230 vars["modifyRoomUH"] = urlHandlers
.UHRoomBookingRoomForm
6231 vars["deleteRoomUH"] = urlHandlers
.UHRoomBookingDeleteRoom
6233 # Calendar range: 3 months
6234 if self
._rh
._searchingStartDT
and self
._rh
._searchingEndDT
:
6235 sd
= self
._rh
._searchingStartDT
6236 calendarStartDT
= datetime( sd
.year
, sd
.month
, sd
.day
, 0, 0, 1 )
6237 ed
= self
._rh
._searchingEndDT
6238 calendarEndDT
= datetime( ed
.year
, ed
.month
, ed
.day
, 23, 59 )
6240 now
= datetime
.now()
6241 calendarStartDT
= datetime( now
.year
, now
.month
, now
.day
, 0, 0, 1 )
6242 calendarEndDT
= calendarStartDT
+ timedelta( 3 * 31, 50, 0, 0, 59, 23 )
6244 # Example resv. to ask for other reservations
6245 resvEx
= CrossLocationFactory
.newReservation( location
= self
._rh
._room
.locationName
)
6246 resvEx
.startDT
= calendarStartDT
6247 resvEx
.endDT
= calendarEndDT
6248 resvEx
.repeatability
= RepeatabilityEnum
.daily
6249 resvEx
.room
= self
._rh
._room
6250 resvEx
.isConfirmed
= None # to include not also confirmed
6252 # Bars: Existing reservations
6253 collisionsOfResvs
= resvEx
.getCollisions()
6256 for c
in collisionsOfResvs
:
6257 if c
.withReservation
.isConfirmed
:
6258 bars
.append( Bar( c
, Bar
.UNAVAILABLE
) )
6260 bars
.append( Bar( c
, Bar
.PREBOOKED
) )
6262 bars
= barsList2Dictionary( bars
)
6263 bars
= addOverlappingPrebookings( bars
)
6264 bars
= sortBarsByImportance( bars
, calendarStartDT
, calendarEndDT
)
6267 if not self
._standalone
:
6268 for dt
in bars
.iterkeys():
6269 for bar
in bars
[dt
]:
6270 bar
.forReservation
.setOwner( self
._rh
._conf
)
6272 vars["calendarStartDT"] = calendarStartDT
6273 vars["calendarEndDT"] = calendarEndDT
6274 bars
= introduceRooms( [self
._rh
._room
], bars
, calendarStartDT
, calendarEndDT
, user
= self
._rh
._aw
.getUser() )
6277 fossilizedBars
[str(key
)] = [fossilize(bar
, IRoomBarFossil
) for bar
in bars
[key
]]
6278 vars["barsFossil"] = fossilizedBars
6279 vars["dayAttrs"] = fossilize(dict((day
.strftime("%Y-%m-%d"), getDayAttrsForRoom(day
, self
._rh
._room
)) for day
in bars
.iterkeys()))
6281 vars["iterdays"] = iterdays
6282 vars["day_name"] = day_name
6284 vars["withConflicts"] = False
6285 vars["currentUser"] = self
._rh
._aw
.getUser()
6289 class WRoomBookingDetails( WTemplated
):
6291 def __init__(self
, rh
, conference
= None):
6293 self
._resv
= rh
._resv
6294 self
._conf
= conference
6295 self
._standalone
= (conference
is None)
6297 def getVars( self
):
6298 vars=WTemplated
.getVars( self
)
6299 vars["standalone"] = self
._standalone
6300 vars["reservation"] = self
._resv
6301 vars["config"] = Config
.getInstance()
6302 #vars["smallPhotoUH"] = urlHandlers.UHSendRoomPhoto
6303 #vars["roomPhotoUH"] = urlHandlers.UHSendRoomPhoto
6304 vars["actionSucceeded"] = self
._rh
._afterActionSucceeded
6305 if self
._rh
._afterActionSucceeded
:
6306 vars["title"] = self
._rh
._title
6307 vars["description"] = self
._rh
._description
6309 if self
._standalone
:
6310 vars["roomDetailsUH"] = urlHandlers
.UHRoomBookingRoomDetails
6311 vars["modifyBookingUH"] = urlHandlers
.UHRoomBookingBookingForm
6312 vars["cloneURL"] = urlHandlers
.UHRoomBookingCloneBooking
.getURL(self
._resv
)
6314 vars["roomDetailsUH"] = urlHandlers
.UHConfModifRoomBookingRoomDetails
6315 vars["modifyBookingUH"] = urlHandlers
.UHConfModifRoomBookingBookingForm
6316 vars["cloneURL"] = urlHandlers
.UHConfModifRoomBookingCloneBooking
.getURL(self
._resv
, self
._conf
)
6318 vars["bookMessage"] = "Book"
6319 if not self
._resv
.isConfirmed
:
6320 vars["bookMessage"] = "PRE-Book"
6326 class WRoomBookingBookingForm( WTemplated
):
6328 def __init__( self
, rh
, standalone
= False ):
6330 self
._candResv
= rh
._candResv
6331 self
._standalone
= standalone
6333 def getVars( self
):
6334 vars = WTemplated
.getVars( self
)
6336 vars["standalone"] = self
._standalone
6337 vars["config"] = Config
.getInstance()
6339 if self
._standalone
:
6341 vars["saveBookingUH"] = urlHandlers
.UHRoomBookingSaveBooking
6342 vars["roomDetailsUH"] = urlHandlers
.UHRoomBookingRoomDetails
6343 vars["calendarPreviewUH"] = urlHandlers
.UHRoomBookingBookingForm
6344 vars["bookingFormURL"] = urlHandlers
.UHRoomBookingBookingForm
6346 vars["conf"] = self
._rh
._conf
6347 vars["saveBookingUH"] = urlHandlers
.UHConfModifRoomBookingSaveBooking
6348 vars["roomDetailsUH"] = urlHandlers
.UHConfModifRoomBookingRoomDetails
6349 vars["calendarPreviewUH"] = urlHandlers
.UHConfModifRoomBookingBookingForm
6350 vars["bookingFormURL"] = urlHandlers
.UHConfModifRoomBookingBookingForm
6352 vars["candResv"] = self
._candResv
6353 vars["startDT"] = self
._candResv
.startDT
6354 vars["endDT"] = self
._candResv
.endDT
6355 vars["startT"] = '%02d:%02d' % (self
._candResv
.startDT
.hour
, self
._candResv
.startDT
.minute
)
6356 vars["endT"] = '%02d:%02d' % (self
._candResv
.endDT
.hour
, self
._candResv
.endDT
.minute
)
6358 vars["showErrors"] = self
._rh
._showErrors
6359 vars["errors"] = self
._rh
._errors
6360 vars["thereAreConflicts"] = self
._rh
._thereAreConflicts
6361 vars["skipConflicting"] = self
._rh
._skipConflicting
6363 if self
._rh
._formMode
== FormMode
.MODIF
:
6364 vars["allowPast"] = "true"
6366 vars["allowPast"] = "false"
6367 vars["formMode"] = self
._rh
._formMode
6368 vars["FormMode"] = FormMode
6370 # [Book] or [PRE-Book] ?
6371 bookingMessage
= "Book"
6372 room
= self
._candResv
.room
6373 user
= self
._rh
._getUser
()
6374 if room
.canPrebook( user
) and not room
.canBook( user
):
6375 bookingMessage
= "PRE-Book"
6376 vars["bookingMessage"] = bookingMessage
6378 if self
._rh
._formMode
!= FormMode
.MODIF
:
6379 bText
= bookingMessage
6383 vars["roomBookingRoomCalendar"] = WRoomBookingRoomCalendar( self
._rh
, self
._standalone
, buttonText
=bText
).getHTML( {} )
6387 class WRoomBookingConfirmBooking( WRoomBookingBookingForm
):
6389 def getVars( self
):
6390 vars = WTemplated
.getVars( self
)
6392 vars["candResv"] = self
._candResv
6394 vars["standalone"] = self
._standalone
6395 vars["formMode"] = self
._rh
._formMode
6396 vars["FormMode"] = FormMode
6397 vars["collisions"] = self
._rh
._collisions
6399 # If we are here, we are either in booking mode and trying to overwrite PRE-Bookings...
6400 bookingMessage
= "Book"
6401 bookingMessageOther
= "PRE-Book"
6402 vars["rejectOthers"] = True
6403 room
= self
._candResv
.room
6404 user
= self
._rh
._getUser
()
6405 if room
.canPrebook( user
) and not room
.canBook( user
):
6406 # ...or we are in PRE-booking mode and conflicting with another PRE-Booking
6407 bookingMessage
= "PRE-Book"
6408 bookingMessageOther
= "PRE-Book"
6409 vars["rejectOthers"] = False
6410 vars["bookingMessage"] = bookingMessage
6411 vars["bookingMessageOther"] = bookingMessageOther
6413 if self
._standalone
:
6415 vars["saveBookingUH"] = urlHandlers
.UHRoomBookingSaveBooking
6416 vars["roomDetailsUH"] = urlHandlers
.UHRoomBookingRoomDetails
6418 vars["conf"] = self
._rh
._conf
6419 vars["saveBookingUH"] = urlHandlers
.UHConfModifRoomBookingSaveBooking
6420 vars["roomDetailsUH"] = urlHandlers
.UHConfModifRoomBookingRoomDetails
6423 class WRoomBookingRoomForm( WTemplated
):
6425 def __init__( self
, rh
):
6428 def getVars( self
):
6429 vars = WTemplated
.getVars( self
)
6431 candRoom
= self
._rh
._candRoom
6432 goodFactory
= Location
.parse( candRoom
.locationName
).factory
6434 vars["Location"] = Location
6435 vars["room"] = candRoom
6436 vars["largePhotoPath"] = None
6437 vars["smallPhotoPath"] = None
6438 vars["config"] = Config
.getInstance()
6439 vars["possibleEquipment"] = goodFactory
.getEquipmentManager().getPossibleEquipment( location
= candRoom
.locationName
)
6441 vars["showErrors"] = self
._rh
._showErrors
6442 vars["errors"] = self
._rh
._errors
6444 vars["insert"] = ( candRoom
.id == None )
6445 vars["attrs"] = goodFactory
.getCustomAttributesManager().getAttributes( location
= candRoom
.locationName
)
6446 resp
= candRoom
.getResponsible()
6448 vars["responsibleName"] = resp
.getFullName()
6450 vars["responsibleName"] = ""
6452 nbd
= candRoom
.getNonBookableDates()
6454 from MaKaC
.plugins
.RoomBooking
.default
.room
import NonBookableDate
6455 nbd
= [NonBookableDate(None, None)]
6456 vars["nonBookableDates"] = nbd
6461 class WRoomBookingRoomCalendar( WTemplated
):
6463 def __init__( self
, rh
, standalone
= False, buttonText
='' ):
6465 self
._candResv
= rh
._candResv
6466 self
._standalone
= standalone
6467 self
._buttonText
= buttonText
6469 def getVars( self
):
6470 vars = WTemplated
.getVars( self
)
6472 candResv
= self
._candResv
6473 room
= candResv
.room
6475 if self
._standalone
:
6476 vars["bookingDetailsUH"] = urlHandlers
.UHRoomBookingBookingDetails
6478 vars["bookingDetailsUH"] = urlHandlers
.UHConfModifRoomBookingDetails
6481 now
= datetime
.now()
6482 if candResv
!= None: #.startDT != None and candResv.endDT != None:
6483 calendarStartDT
= datetime( candResv
.startDT
.year
, candResv
.startDT
.month
, candResv
.startDT
.day
, 0, 0, 1 ) # Potential performance problem
6484 calendarEndDT
= datetime( candResv
.endDT
.year
, candResv
.endDT
.month
, candResv
.endDT
.day
, 23, 59 ) # with very long reservation periods
6486 calendarStartDT
= datetime( now
.year
, now
.month
, now
.day
, 0, 0, 1 )
6487 calendarEndDT
= calendarStartDT
+ timedelta( 3 * 31, 50, 0, 0, 59, 23 )
6489 # example resv. to ask for other reservations
6490 resvEx
= CrossLocationFactory
.newReservation( location
= room
.locationName
)
6491 resvEx
.startDT
= calendarStartDT
6492 resvEx
.endDT
= calendarEndDT
6493 resvEx
.repeatability
= RepeatabilityEnum
.daily
6495 resvEx
.isConfirmed
= None # To include both confirmed and not confirmed
6497 # Bars: Existing reservations
6498 collisionsOfResvs
= resvEx
.getCollisions()
6500 for c
in collisionsOfResvs
:
6501 if c
.withReservation
.isConfirmed
:
6502 bars
.append( Bar( c
, Bar
.UNAVAILABLE
) )
6504 bars
.append( Bar( c
, Bar
.PREBOOKED
) )
6506 # Bars: Candidate reservation
6507 periodsOfCandResv
= candResv
.splitToPeriods()
6508 for p
in periodsOfCandResv
:
6509 bars
.append( Bar( Collision( (p
.startDT
, p
.endDT
), candResv
), Bar
.CANDIDATE
) )
6511 # Bars: Conflicts all vs candidate
6512 candResvIsConfirmed
= candResv
.isConfirmed
;
6513 candResv
.isConfirmed
= None
6514 allCollisions
= candResv
.getCollisions()
6515 candResv
.isConfirmed
= candResvIsConfirmed
6517 # Exclude candidate vs self pseudo-conflicts (Booking modification)
6518 allCollisions
= filter( lambda c
: c
.withReservation
.id != candResv
.id, allCollisions
)
6519 collisions
= [] # only with confirmed resvs
6520 for c
in allCollisions
:
6521 if c
.withReservation
.isConfirmed
:
6522 bars
.append( Bar( c
, Bar
.CONFLICT
) )
6523 collisions
.append( c
)
6525 bars
.append( Bar( c
, Bar
.PRECONFLICT
) )
6527 if not candResv
.isRejected
and not candResv
.isCancelled
:
6528 vars["thereAreConflicts"] = len( collisions
) > 0
6530 vars["thereAreConflicts"] = False
6531 vars["conflictsNumber"] = len( collisions
)
6533 bars
= barsList2Dictionary( bars
)
6534 bars
= addOverlappingPrebookings( bars
)
6535 bars
= sortBarsByImportance( bars
, calendarStartDT
, calendarEndDT
)
6537 if not self
._standalone
:
6538 for dt
in bars
.iterkeys():
6539 for bar
in bars
[dt
]:
6540 bar
.forReservation
.setOwner( self
._rh
._conf
)
6542 vars["blockConflicts"] = candResv
.getBlockingConflictState(self
._rh
._aw
.getUser())
6544 vars["calendarStartDT"] = calendarStartDT
6545 vars["calendarEndDT"] = calendarEndDT
6546 bars
= introduceRooms( [room
], bars
, calendarStartDT
, calendarEndDT
, user
= self
._rh
._aw
.getUser() )
6549 fossilizedBars
[str(key
)] = [fossilize(bar
, IRoomBarFossil
) for bar
in bars
[key
]]
6550 vars["barsFossil"] = fossilizedBars
6551 vars["dayAttrs"] = fossilize(dict((day
.strftime("%Y-%m-%d"), getDayAttrsForRoom(day
, room
)) for day
in bars
.iterkeys()))
6553 vars["iterdays"] = iterdays
6554 vars["day_name"] = day_name
6557 vars["buttonText"] = self
._buttonText
6558 vars["currentUser"] = self
._rh
._aw
.getUser()
6559 vars["withConflicts"] = True
6564 class WRoomBookingStatement( WTemplated
):
6566 def __init__( self
, rh
):
6569 def getVars( self
):
6570 vars = WTemplated
.getVars( self
)
6571 vars['title'] = self
._rh
._title
6572 vars['description'] = self
._rh
._description
6575 class WRoomBookingAdmin( WTemplated
):
6577 def __init__( self
, rh
):
6580 def getVars( self
):
6581 vars = WTemplated
.getVars( self
)
6582 vars["Location"] = Location
6586 class WRoomBookingAdminLocation( WTemplated
):
6588 def __init__( self
, rh
, location
):
6590 self
._location
= location
6592 def getVars( self
):
6593 vars = WTemplated
.getVars( self
)
6594 vars["location"] = self
._location
6595 vars["possibleEquipment"] = self
._location
.factory
.getEquipmentManager().getPossibleEquipment(location
= self
._location
.friendlyName
)
6596 vars["AttsManager"] = self
._location
.factory
.getCustomAttributesManager()
6599 rooms
= self
._location
.factory
.newRoom().getRooms(location
= self
._location
.friendlyName
)
6600 rooms
.sort(key
= lambda r
: r
.getFullName())
6602 vars["Rooms"] = rooms
6606 vars["withKPI"] = rh
._withKPI
6609 vars["kpiAverageOccupation"] = str( int( round( rh
._kpiAverageOccupation
* 100 ) ) ) + "%"
6611 vars["kpiTotalRooms"] = rh
._kpiTotalRooms
6612 vars["kpiActiveRooms"] = rh
._kpiActiveRooms
6613 vars["kpiReservableRooms"] = rh
._kpiReservableRooms
6615 vars["kpiReservableCapacity"] = rh
._kpiReservableCapacity
6616 vars["kpiReservableSurface"] = rh
._kpiReservableSurface
6620 vars["kbiTotalBookings"] = rh
._totalBookings
6623 vars["stats"] = rh
._booking
_stats
6627 class WRoomBookingBlockingsForMyRooms(WTemplated
):
6629 def __init__(self
, roomBlocks
):
6630 self
._roomBlocks
= roomBlocks
6633 vars = WTemplated
.getVars(self
)
6634 vars['roomBlocks'] = self
._roomBlocks
6637 class WRoomBookingBlockingDetails(WTemplated
):
6639 def __init__(self
, block
):
6643 vars = WTemplated
.getVars(self
)
6644 vars['block'] = self
._block
6647 class WRoomBookingBlockingList(WTemplated
):
6649 def __init__(self
, blocks
):
6650 self
._blocks
= blocks
6653 vars = WTemplated
.getVars(self
)
6655 self
._blocks
.sort(key
=attrgetter('startDate'), reverse
=True)
6656 vars['blocks'] = self
._blocks
6659 class WRoomBookingBlockingForm(WTemplated
):
6661 def __init__(self
, block
, hasErrors
):
6663 self
._hasErrors
= hasErrors
6666 vars = WTemplated
.getVars(self
)
6667 vars['block'] = self
._block
6668 vars['hasErrors'] = self
._hasErrors
6671 class WBaseSearchBox(WTemplated
):
6673 def __init__(self
, template
='SearchBox', targetId
=0):
6674 # overload the template
6675 WTemplated
.__init
__(self
,template
)
6676 self
._targetId
= targetId
6679 vars = WTemplated
.getVars( self
)
6680 vars["searchAction"] = urlHandlers
.UHSearch
.getURL();
6681 vars['targetId'] = self
._targetId
6682 vars['searchImg'] = imgLogo
=Configuration
.Config
.getInstance().getSystemIconURL( "search" )
6686 class WMiniSearchBox(WBaseSearchBox
):
6688 def __init__(self
, confId
):
6689 WBaseSearchBox
.__init
__(self
, template
='MiniSearchBox',targetId
= confId
)
6692 vars = WBaseSearchBox
.getVars( self
)
6695 class WCategorySearchBox(WBaseSearchBox
):
6697 def __init__(self
, categId
= 0, optionsClass
='arrowExpandIcon'):
6698 WBaseSearchBox
.__init
__(self
, targetId
= categId
)
6699 self
._categId
= categId
6700 self
._moreOptionsClass
= optionsClass
6703 vars = WBaseSearchBox
.getVars( self
)
6704 vars["categId"] = self
._categId
6705 vars['moreOptionsClass'] = self
._moreOptionsClass
6708 class WRootSearchBox(WBaseSearchBox
):
6711 # overload the template
6712 WBaseSearchBox
.__init
__(self
,'RootSearchBox')
6715 vars = WBaseSearchBox
.getVars( self
)
6716 vars["innerBox"] = WBaseSearchBox().getHTML()
6720 """A interface for creating easily some HTML elements..."""
6722 def createImg(cls
, imgId
, imgInfo
="", imgText
="", **attributes
):
6723 """ returns an HTML image with optional text on the right.
6725 imgId -- ID of the picture (see /code/MaKaC/common/MaCaKConfig.py ->SystemIcons).
6726 ImgInfo -- optional information text about the link.
6727 imgText -- optional text which will be displayed on the right of the pic.
6728 attributes -- [dictionary] attributes for <img> (e.g. border="" name="" ...).
6730 attr
= utils
.dictionaryToString(attributes
)
6731 return """<img src="%s" alt="%s" %s /> %s"""%(Config
.getInstance().getSystemIconURL(imgId
),imgInfo
,attr
,imgText
)
6732 createImg
= classmethod(createImg
)
6734 def createImgButton(cls
, url
, imgId
, imgInfo
="", imgText
="", **attributes
):
6735 """ returns an HTML image link with optional text on the right.
6737 url -- link of target.
6738 imgId -- ID of the picture (see /code/MaKaC/common/MaCaKConfig.py ->SystemIcons).
6739 ImgInfo -- optional information text about the link.
6740 imgText -- optional text which will be displayed on the right of the pic.
6741 attributes -- [dictionary] attributes for <a> (e.g. onclick="" onchange="" ...).
6743 attr
= utils
.dictionaryToString(attributes
)
6744 return """<a href="%s" %s>
6745 <img src="%s" alt="%s" /> %s
6746 </a>"""%(url
, attr
, Config
.getInstance().getSystemIconURL(imgId
), imgInfo
, imgText
)
6747 createImgButton
= classmethod(createImgButton
)
6749 def createChangingImgButton(cls
, url
, imgID
, imgOverId
, imgInfo
="", imgText
="", **attributes
):
6750 """ returns a changing HTML image link
6751 (i.e. the image changes depending on mouseOver/mouseOut)
6752 with optional text on the right.
6755 url -- link of target.
6756 imgID -- ID of the basic picture (see /code/MaKaC/common/MaCaKConfig.py ->SystemIcons).
6757 imgOverId -- ID of the picture appearing with onMouseOver.
6758 ImgInfo -- optional information text about the link.
6759 imgText -- optional text which will be displayed on the right of the pic.
6760 attributes -- [dictionary] attributes for <a> (e.g. onclick="" onchange="" ...).
6762 attr
= utils
.dictionaryToString(attributes
)
6763 iconUrl
= Config
.getInstance().getSystemIconURL(imgID
)
6764 iconOverUrl
= Config
.getInstance().getSystemIconURL(imgOverId
)
6765 return """<a href="%s" %s>
6766 <img src="%s" alt="%s" onmouseover="javascript:this.src='%s'" onMouseOut="javascript:this.src='%s'"/> %s
6767 </a>"""%(url
, attr
, iconUrl
, imgInfo
, iconOverUrl
, iconUrl
, imgText
)
6768 createChangingImgButton
= classmethod(createChangingImgButton
)
6770 def createTextarea(cls
, content
="", **attributes
):
6771 """ returns an HTML textarea with optional text.
6773 content -- optional text which will be displayed in the textarea.
6774 attributes -- [dictionary] attributes for <input> (e.g. name="" type="" ...).
6777 if content
==None: content
=""
6778 #attributes to string...
6779 attr
= utils
.dictionaryToString(attributes
)
6781 return """<textarea rows="5" cols="15" %s>%s</textarea>"""%(attr
,content
)
6782 createTextarea
= classmethod(createTextarea
)
6784 def createInput(cls
, text
="", **attributes
):
6785 """ returns an HTML input with optional text.
6787 text -- optional text which will be displayed on the right of the input.
6788 attributes -- [dictionary] attributes for <input> (e.g. name="" type="" ...).
6791 if text
==None: text
=""
6792 #attributes to string...
6793 attr
= utils
.dictionaryToString(attributes
)
6795 return """<input %s/>%s"""%(attr
,text
)
6796 createInput
= classmethod(createInput
)
6798 def createSelect(cls
, emptyOption
, options
, selected
="", **attributes
):
6799 """ returns an HTML select field.
6801 emptyOption -- [bool] if True, add a selectionable empty option in the select.
6802 options -- list of the options.
6803 selected -- (optional) the selected option.
6804 attributes -- [dictionary] attributes for <select> (e.g. name="" onchange="" ...).
6806 #attributes to string...
6807 attr
= utils
.dictionaryToString(attributes
)
6809 if emptyOption
==True:
6810 optionsHTML
="<option></option>"
6813 #treating options...
6814 for option
in options
:
6815 if option
!=None and option
!="":
6816 if str(option
)==str(selected
):
6817 optionsHTML
+= """<option selected>%s</option>"""%(option)
6819 optionsHTML
+= "<option>%s</option>"%(option)
6820 return """<select %s>%s</select>"""%(attr
,optionsHTML
)
6821 createSelect
= classmethod(createSelect
)
6823 def appendNewLine(cls
, htmlContent
):
6824 """ appends a new line <br/> to the given html element.
6826 htmlContent -- [str] html element
6828 return str(htmlContent
) + "<br/>"
6829 appendNewLine
= classmethod(appendNewLine
)
6831 class WBeautifulHTMLList(WTemplated
):
6833 def __init__(self
, listObject
, classNames
, level
):
6834 """ classNames: a dictionary such as {'UlClassName' : 'optionList'}. See the getVars for more class names.
6836 WTemplated
.__init
__(self
)
6837 self
.__listObject
= listObject
6838 self
.__classNames
= classNames
6839 self
.__level
= level
6842 vars = WTemplated
.getVars( self
)
6843 vars["ListObject"] = self
.__listObject
6844 vars["UlClassName"] = self
.__classNames
.get("UlClassName", "")
6845 vars["LiClassName"] = self
.__classNames
.get("LiClassName", "")
6846 vars["DivClassName"] = self
.__classNames
.get("DivClassName", "")
6847 vars["Level"] = self
.__level
6850 class WBeautifulHTMLDict(WTemplated
):
6852 def __init__(self
, dictObject
, classNames
, level
):
6853 """ classNames: a dictionary such as {'UlClassName' : 'optionList'}. See the getVars for more class names.
6855 WTemplated
.__init
__(self
)
6856 self
.__dictObject
= dictObject
6857 self
.__classNames
= classNames
6858 self
.__level
= level
6861 vars = WTemplated
.getVars( self
)
6862 vars["DictObject"] = self
.__dictObject
6863 vars["UlClassName"] = self
.__classNames
.get("UlClassName", "")
6864 vars["LiClassName"] = self
.__classNames
.get("LiClassName", "")
6865 vars["DivClassName"] = self
.__classNames
.get("DivClassName", "")
6866 vars["KeyClassName"] = self
.__classNames
.get("KeyClassName", "")
6867 vars["Level"] = self
.__level
6871 class WFilterCriteria(WTemplated
):
6873 Draws the options for a filter criteria object
6874 This means rendering the actual table that contains
6875 all the HTML for the several criteria
6878 def __init__(self
, options
, filterCrit
, extraInfo
=""):
6879 WTemplated
.__init
__(self
, tpl_name
= "FilterCriteria")
6880 self
._filterCrit
= filterCrit
6881 self
._options
= options
6882 self
._extraInfo
= extraInfo
6884 def _drawFieldOptions(self
, formName
, form
):
6885 raise Exception("Method WFilterCriteria._drawFieldOptions must be overwritten")
6889 vars = WTemplated
.getVars( self
)
6891 vars["extra"] = self
._extraInfo
6893 vars["content"] = list((name
, self
._drawFieldOptions
(name
, form
))
6894 for (name
, form
) in self
._options
)
6897 class WDateField(WTemplated
):
6899 def __init__(self
, name
, date
, format
, isDisabled
=False, isMandatory
=False):
6900 self
._withTime
= format
.find('%H') >= 0
6902 self
._format
= format
6903 self
._isMandatory
= isMandatory
6905 self
._isDisabled
= isDisabled
6908 vars = WTemplated
.getVars(self
)
6909 vars['name'] = self
._name
6910 vars['date'] = self
._date
6912 vars['dateDisplay'] = datetime
.strftime(self
._date
, self
._format
)
6914 vars['dateDisplay'] = ''
6915 vars['isDisabled'] = self
._isDisabled
6916 vars['withTime'] = self
._withTime
6917 vars['isMandatory'] = self
._isMandatory
6918 vars['format'] = self
._format