Hide event sidemenu items based on features
[cds-indico.git] / indico / MaKaC / webinterface / pages / conferences.py
blobba3b92f2e0eb613ad678346b9a6a0632a5daea0c
1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
17 import collections
18 from flask import session, request
19 import os
20 import re
21 import time
23 from datetime import timedelta, datetime
24 from xml.sax.saxutils import quoteattr, escape
26 import MaKaC.webinterface.wcomponents as wcomponents
27 import MaKaC.webinterface.urlHandlers as urlHandlers
28 import MaKaC.webinterface.displayMgr as displayMgr
29 import MaKaC.webinterface.linking as linking
30 import MaKaC.webinterface.navigation as navigation
31 import MaKaC.schedule as schedule
32 import MaKaC.conference as conference
33 import MaKaC.common.filters as filters
34 from MaKaC.common.utils import isStringHTML
35 import MaKaC.common.utils
36 import MaKaC.review as review
37 from MaKaC.review import AbstractTextField
38 from MaKaC.webinterface.pages.base import WPDecorated
39 from MaKaC.webinterface.common.tools import strip_ml_tags, escape_html
40 from MaKaC.webinterface.common.abstractStatusWrapper import AbstractStatusList
41 from MaKaC.webinterface.common.contribStatusWrapper import ContribStatusList
42 from MaKaC.common.output import outputGenerator
43 from MaKaC.webinterface.common.timezones import TimezoneRegistry
44 from MaKaC.PDFinterface.base import PDFSizes
45 from pytz import timezone
46 from MaKaC.common.timezoneUtils import nowutc, DisplayTZ
47 from MaKaC.conference import EventCloner
48 from MaKaC.badgeDesignConf import BadgeDesignConfiguration
49 from MaKaC.posterDesignConf import PosterDesignConfiguration
50 from MaKaC.webinterface.pages import main
51 from MaKaC.webinterface.pages import base
52 import MaKaC.common.info as info
53 from indico.util.i18n import i18nformat, _, ngettext
54 from indico.util.date_time import format_time, format_date, format_datetime
55 from indico.util.string import safe_upper
56 from MaKaC.common.fossilize import fossilize
57 from MaKaC.fossils.conference import IConferenceEventInfoFossil
58 from MaKaC.common.Conversion import Conversion
59 from indico.modules import ModuleHolder
60 from indico.modules.auth.util import url_for_logout
61 from MaKaC.paperReviewing import ConferencePaperReview as CPR
62 from MaKaC.conference import Session, Contribution
63 from indico.core.config import Config
64 from MaKaC.common.utils import formatDateTime
65 from MaKaC.user import AvatarHolder
66 from MaKaC.webinterface.general import WebFactory
67 from MaKaC.common.TemplateExec import render
69 from indico.core import signals
70 from indico.util import json
71 from indico.util.signals import values_from_signal
72 from indico.web.flask.util import url_for
74 LECTURE_SERIES_RE = re.compile(r'^part\d+$')
77 def stringToDate(str):
79 # Don't delete this dictionary inside comment. Its purpose is to
80 # add the dictionary in the language dictionary during the extraction!
81 # months = { _("January"): 1, _("February"): 2, _("March"): 3, _("April"): 4,
82 # _("May"): 5, _("June"): 6, _("July"): 7, _("August"): 8,
83 # _("September"): 9, _("October"): 10, _("November"): 11, _("December"): 12 }
85 months = {
86 "January": 1,
87 "February": 2,
88 "March": 3,
89 "April": 4,
90 "May": 5,
91 "June": 6,
92 "July": 7,
93 "August": 8,
94 "September": 9,
95 "October": 10,
96 "November": 11,
97 "December": 12
99 [day, month, year] = str.split("-")
100 return datetime(int(year), months[month], int(day))
103 class WPConferenceBase(base.WPDecorated):
105 def __init__(self, rh, conference, **kwargs):
106 WPDecorated.__init__(self, rh, **kwargs)
107 self._navigationTarget = self._conf = conference
108 tz = self._tz = DisplayTZ(rh._aw, self._conf).getDisplayTZ()
109 sDate = self.sDate = self._conf.getAdjustedScreenStartDate(tz)
110 eDate = self.eDate = self._conf.getAdjustedScreenEndDate(tz)
111 dates = " (%s)" % format_date(sDate, format='long')
112 if sDate.strftime("%d%B%Y") != eDate.strftime("%d%B%Y"):
113 if sDate.strftime("%B%Y") == eDate.strftime("%B%Y"):
114 dates = " (%s-%s)" % (sDate.strftime("%d"), format_date(eDate, format='long'))
115 else:
116 dates = " (%s - %s)" % (format_date(sDate, format='long'), format_date(eDate, format='long'))
117 self._setTitle("%s %s" % (strip_ml_tags(self._conf.getTitle()), dates))
119 def _getFooter(self):
122 wc = wcomponents.WFooter()
124 p = {"modificationDate": format_datetime(self._conf.getModificationDate(), format='d MMMM yyyy H:mm'),
125 "subArea": self._getSiteArea()
127 return wc.getHTML(p)
129 def getLogoutURL(self):
130 return url_for_logout(str(urlHandlers.UHConferenceDisplay.getURL(self._conf)))
133 class WPConferenceDisplayBase(WPConferenceBase):
134 pass
137 class WPConferenceDefaultDisplayBase( WPConferenceBase):
138 navigationEntry = None
140 def getJSFiles(self):
141 return (WPConferenceBase.getJSFiles(self) + self._includeJSPackage('Display') +
142 self._includeJSPackage('MaterialEditor'))
144 def _getFooter( self ):
145 wc = wcomponents.WFooter()
146 p = {"modificationDate": format_datetime(self._conf.getModificationDate(), format='d MMMM yyyy H:mm'),
147 "subArea": self._getSiteArea()}
149 cid = self._conf.getUrlTag().strip() or self._conf.getId()
150 p["shortURL"] = Config.getInstance().getShortEventURL() + cid
152 return wc.getHTML(p)
154 def _getHeader( self ):
157 wc = wcomponents.WConferenceHeader( self._getAW(), self._conf )
158 return wc.getHTML( { "loginURL": self.getLoginURL(),\
159 "logoutURL": self.getLogoutURL(),\
160 "confId": self._conf.getId(), \
161 "dark": True} )
163 def _defineSectionMenu( self ):
165 awUser = self._getAW().getUser()
166 self._sectionMenu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
167 self._overviewOpt = self._sectionMenu.getLinkByName("overview")
168 self._programOpt = self._sectionMenu.getLinkByName("programme")
169 link = self._programOpt
170 self._cfaOpt = self._sectionMenu.getLinkByName("CFA")
171 self._cfaNewSubmissionOpt = self._sectionMenu.getLinkByName("SubmitAbstract")
172 self._cfaViewSubmissionsOpt = self._sectionMenu.getLinkByName("ViewAbstracts")
173 self._abstractsBookOpt = self._sectionMenu.getLinkByName("abstractsBook")
174 if not self._conf.getAbstractMgr().isActive() or not self._conf.hasEnabledSection("cfa"):
175 self._cfaOpt.setVisible(False)
176 self._abstractsBookOpt.setVisible(False)
177 else:
178 self._cfaOpt.setVisible(True)
179 self._abstractsBookOpt.setVisible(True)
180 self._trackMgtOpt = self._sectionMenu.getLinkByName("manageTrack")
182 #registration form
183 self._regFormOpt = self._sectionMenu.getLinkByName("registrationForm")
184 self._registrantsListOpt = self._sectionMenu.getLinkByName("registrants")
185 if not self._conf.getRegistrationForm().isActivated() or not self._conf.hasEnabledSection("regForm"):
186 self._regFormOpt.setVisible(False)
187 self._registrantsListOpt.setVisible(False)
188 else:
189 self._regFormOpt.setVisible(True)
190 self._registrantsListOpt.setVisible(True)
192 #evaluation
193 evaluation = self._conf.getEvaluation()
194 self._evaluationOpt = self._sectionMenu.getLinkByName("evaluation")
195 self._newEvaluationOpt = self._sectionMenu.getLinkByName("newEvaluation")
196 self._viewEvaluationOpt = self._sectionMenu.getLinkByName("viewMyEvaluation")
197 self._evaluationOpt.setVisible(self._conf.hasEnabledSection("evaluation") and evaluation.isVisible() and evaluation.getNbOfQuestions()>0)
198 if awUser!=None and awUser.hasSubmittedEvaluation(evaluation):
199 self._newEvaluationOpt.setVisible(not awUser.hasSubmittedEvaluation(evaluation))
200 self._viewEvaluationOpt.setVisible(awUser.hasSubmittedEvaluation(evaluation))
201 else:
202 self._newEvaluationOpt.setVisible(True)
203 self._viewEvaluationOpt.setVisible(False)
207 self._sectionMenu.setCurrentItem(None)
209 self._timetableOpt = self._sectionMenu.getLinkByName("timetable")
210 self._contribListOpt = self._sectionMenu.getLinkByName("contributionList")
211 self._authorIndexOpt = self._sectionMenu.getLinkByName("authorIndex")
212 self._speakerIndexOpt = self._sectionMenu.getLinkByName("speakerIndex")
213 self._myStuffOpt=self._sectionMenu.getLinkByName("mystuff")
214 self._myStuffOpt.setVisible(awUser is not None)
215 self._mySessionsOpt=self._sectionMenu.getLinkByName("mysessions")
216 ls = set(self._conf.getCoordinatedSessions(awUser)) | set(self._conf.getManagedSession(awUser))
217 self._mySessionsOpt.setVisible(len(ls)>0)
218 self._myTracksOpt=self._sectionMenu.getLinkByName("mytracks")
219 lt=self._conf.getCoordinatedTracks(awUser)
220 self._myTracksOpt.setVisible(len(lt)>0)
221 if not self._conf.getAbstractMgr().isActive():
222 self._myTracksOpt.setVisible(False)
223 self._myContribsOpt=self._sectionMenu.getLinkByName("mycontribs")
224 lc=self._conf.getContribsForSubmitter(awUser)
225 self._myContribsOpt.setVisible(len(lc)>0)
226 self._trackMgtOpt.setVisible(len(lt)>0)
227 if not self._conf.getAbstractMgr().isActive():
228 self._trackMgtOpt.setVisible(False)
230 #paper reviewing related
231 self._paperReviewingOpt = self._sectionMenu.getLinkByName("paperreviewing")
232 self._paperReviewingMgtOpt=self._sectionMenu.getLinkByName("managepaperreviewing")
233 self._paperReviewingMgtOpt.setVisible(False)
235 self._assignContribOpt=self._sectionMenu.getLinkByName("assigncontributions")
236 self._assignContribOpt.setVisible(False)
238 self._judgeListOpt=self._sectionMenu.getLinkByName("judgelist")
239 self._judgeListOpt.setVisible(False)
240 self._judgereviewerListOpt=self._sectionMenu.getLinkByName("judgelistreviewer")
242 self._judgereviewerListOpt.setVisible(False)
243 self._judgeeditorListOpt=self._sectionMenu.getLinkByName("judgelisteditor")
244 self._judgeeditorListOpt.setVisible(False)
246 self._uploadPaperOpt = self._sectionMenu.getLinkByName("uploadpaper")
247 self._downloadTemplateOpt = self._sectionMenu.getLinkByName("downloadtemplate")
249 if self._conf.getConfPaperReview().hasReviewing():
250 self._paperReviewingOpt.setVisible(True)
251 # These options are shown if there is any contribution of this user
252 self._uploadPaperOpt.setVisible(len(lc)>0)
253 self._downloadTemplateOpt.setVisible(len(lc)>0)
254 else:
255 self._paperReviewingOpt.setVisible(False)
256 self._uploadPaperOpt.setVisible(False)
257 self._downloadTemplateOpt.setVisible(False)
259 if awUser is not None:
260 conferenceRoles = awUser.user.get_linked_roles('conference')
262 if "paperReviewManager" in conferenceRoles:
263 if self._conf in awUser.user.get_linked_objects('conference', 'paperReviewManager'):
264 self._paperReviewingMgtOpt.setVisible(True)
265 self._assignContribOpt.setVisible(True)
266 self._uploadPaperOpt.setVisible(len(lc)>0)
267 self._downloadTemplateOpt.setVisible(True)
269 if "referee" in conferenceRoles and "editor" in conferenceRoles and "reviewer" in conferenceRoles:
270 showrefereearea = self._conf in awUser.user.get_linked_objects('conference', 'referee')
271 showreviewerarea = self._conf in awUser.user.get_linked_objects('conference', 'reviewer')
272 showeditorarea = self._conf in awUser.user.get_linked_objects('conference', 'editor')
274 if showrefereearea and (self._conf.getConfPaperReview().getChoice() == CPR.CONTENT_REVIEWING or self._conf.getConfPaperReview().getChoice() == CPR.CONTENT_AND_LAYOUT_REVIEWING):
275 self._assignContribOpt.setVisible(True)
276 self._judgeListOpt.setVisible(True)
278 if showreviewerarea and (self._conf.getConfPaperReview().getChoice() == CPR.CONTENT_REVIEWING or self._conf.getConfPaperReview().getChoice() == CPR.CONTENT_AND_LAYOUT_REVIEWING):
279 self._judgereviewerListOpt.setVisible(True)
281 if showeditorarea and (self._conf.getConfPaperReview().getChoice() == CPR.LAYOUT_REVIEWING or self._conf.getConfPaperReview().getChoice() == CPR.CONTENT_AND_LAYOUT_REVIEWING):
282 self._judgeeditorListOpt.setVisible(True)
284 for item in values_from_signal(signals.event.sidemenu.send()):
285 if item.visible is not None:
286 link = self._sectionMenu.getLinkByName(item.name)
287 link.setVisible(item.visible(self._conf))
289 def _display( self, params ):
290 self._defineSectionMenu()
291 return WPConferenceBase._display(self,params)
293 def _getNavigationBarHTML(self):
294 item=None
295 if self.navigationEntry:
296 item = self.navigationEntry()
297 itemList = []
298 while item is not None:
299 if itemList == []:
300 itemList.insert(0, wcomponents.WTemplated.htmlText(item.getTitle()) )
301 else:
302 itemList.insert(0, """<a href=%s>%s</a>"""%( quoteattr(str(item.getURL(self._navigationTarget))), wcomponents.WTemplated.htmlText(item.getTitle()) ) )
303 item = item.getParent(self._navigationTarget)
304 itemList.insert(0, i18nformat("""<a href=%s> _("Home")</a>""")%quoteattr(str(urlHandlers.UHConferenceDisplay.getURL(self._conf))) )
305 return " &gt; ".join(itemList)
307 def _applyConfDisplayDecoration( self, body ):
308 drawer = wcomponents.WConfTickerTapeDrawer(self._conf, self._tz)
309 frame = WConfDisplayFrame( self._getAW(), self._conf )
311 frameParams = {
312 "confModifURL": urlHandlers.UHConferenceModification.getURL(self._conf),
313 "logoURL": urlHandlers.UHConferenceLogo.getURL(self._conf),
314 "currentURL": request.url,
315 "nowHappening": drawer.getNowHappeningHTML(),
316 "simpleTextAnnouncement": drawer.getSimpleText(),
318 if self._conf.getLogo():
319 frameParams["logoURL"] = urlHandlers.UHConferenceLogo.getURL(self._conf)
321 body = """
322 <div class="confBodyBox clearfix">
324 <div>
325 <div></div>
326 <div class="breadcrumps">%s</div>
327 </div>
328 <!--Main body-->
329 <div class="mainContent">
330 <div class="col2">
332 </div>
333 </div>
334 </div>""" % (self._getNavigationBarHTML(), body)
335 return frame.getHTML( self._sectionMenu, body, frameParams)
337 def _getHeadContent(self):
338 dmgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf)
339 path = self._getBaseURL()
340 try:
341 timestamp = os.stat(__file__).st_mtime
342 except OSError:
343 timestamp = 0
344 printCSS = """
345 <link rel="stylesheet" type="text/css" href="%s/css/Conf_Basic.css?%d" >
346 """ % (path, timestamp)
347 confCSS = dmgr.getStyleManager().getCSS()
349 if confCSS:
350 printCSS = printCSS + """<link rel="stylesheet" type="text/css" href="%s">""" % (confCSS.getURL())
352 # Include MathJax
354 return '\n'.join([
355 printCSS,
356 WConfMetadata(self._conf).getHTML(), # confMetadata
357 render('js/mathjax.config.js.tpl'), # mathJax
358 '\n'.join('<script src="{0}" type="text/javascript"></script>'.format(url)
359 for url in self._asset_env['mathjax_js'].urls())
362 def _applyDecoration( self, body ):
363 body = self._applyConfDisplayDecoration( body )
364 return WPConferenceBase._applyDecoration( self, body )
367 class WConfMetadata(wcomponents.WTemplated):
368 def __init__(self, conf):
369 self._conf = conf
371 def getVars(self):
372 v = wcomponents.WTemplated.getVars( self )
373 minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
375 v['site_name'] = minfo.getTitle()
376 v['fb_config'] = minfo.getSocialAppConfig().get('facebook', {})
378 if self._conf.getLogo():
379 v['image'] = urlHandlers.UHConferenceLogo.getURL(self._conf)
380 else:
381 v['image'] = Config.getInstance().getSystemIconURL("indico_co")
383 v['description'] = strip_ml_tags(self._conf.getDescription()[:500])
384 return v
387 class WConfDisplayFrame(wcomponents.WTemplated):
389 def __init__(self, aw, conf):
390 self._aw = aw
391 self._conf = conf
393 def getHTML( self, menu, body, params ):
394 self._body = body
395 self._menu = menu
396 return wcomponents.WTemplated.getHTML( self, params )
398 def getVars(self):
399 vars = wcomponents.WTemplated.getVars( self )
400 vars["logo"] = ""
401 if self._conf.getLogo():
402 vars["logo"] = "<img src=\"%s\" alt=\"%s\" border=\"0\" class=\"confLogo\" >"%(vars["logoURL"], escape_html(self._conf.getTitle(), escape_quotes = True))
403 vars["confTitle"] = self._conf.getTitle()
404 vars["displayURL"] = urlHandlers.UHConferenceDisplay.getURL(self._conf)
405 vars["imgConferenceRoom"] = Config.getInstance().getSystemIconURL( "conferenceRoom" )
406 tz = DisplayTZ(self._aw,self._conf).getDisplayTZ()
407 adjusted_sDate = self._conf.getAdjustedScreenStartDate(tz)
408 adjusted_eDate = self._conf.getAdjustedScreenEndDate(tz)
410 vars["timezone"] = tz
411 vars["confDateInterval"] = i18nformat("""_("from") %s _("to") %s""") % (
412 format_date(adjusted_sDate, format='long'), format_date(adjusted_eDate, format='long'))
413 if adjusted_sDate.strftime("%d%B%Y") == \
414 adjusted_eDate.strftime("%d%B%Y"):
415 vars["confDateInterval"] = format_date(adjusted_sDate, format='long')
416 elif adjusted_sDate.strftime("%B%Y") == adjusted_eDate.strftime("%B%Y"):
417 vars["confDateInterval"] = "%s-%s %s"%(adjusted_sDate.day, adjusted_eDate.day, format_date(adjusted_sDate, format='MMMM yyyy'))
418 vars["confLocation"] = ""
419 if self._conf.getLocationList():
420 vars["confLocation"] = self._conf.getLocationList()[0].getName()
421 vars["body"] = self._body
422 vars["supportEmail"] = ""
423 vars["supportTelephone"] = ""
425 sinfo = self._conf.getSupportInfo()
427 p = {"menu": self._menu,
428 "support_info": sinfo,
429 "event": self._conf}
430 vars["menu"] = WConfDisplayMenu(self._menu).getHTML(p)
432 dm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf, False)
433 format = dm.getFormat()
434 vars["bgColorCode"] = format.getFormatOption("titleBgColor")["code"].replace("#","")
435 vars["textColorCode"] = format.getFormatOption("titleTextColor")["code"].replace("#","")
437 vars["confId"] = self._conf.getId()
438 vars["dm"] = dm
439 vars["conf"] = self._conf
440 return vars
443 class WConfDisplayMenu(wcomponents.WTemplated):
445 def __init__(self, menu):
446 wcomponents.WTemplated.__init__(self)
447 self._menu = menu
450 class WConfDetailsBase( wcomponents.WTemplated ):
452 def __init__(self, aw, conf):
453 self._conf = conf
454 self._aw = aw
456 def getVars( self ):
457 vars = wcomponents.WTemplated.getVars( self )
458 tz = DisplayTZ(self._aw,self._conf).getDisplayTZ()
459 vars["timezone"] = tz
461 description = self._conf.getDescription()
462 vars["description_html"] = isStringHTML(description)
463 vars["description"] = description
465 sdate, edate = self._conf.getAdjustedScreenStartDate(tz), self._conf.getAdjustedScreenEndDate(tz)
466 fsdate, fedate = format_date(sdate, format='medium'), format_date(edate, format='medium')
467 fstime, fetime = sdate.strftime("%H:%M"), edate.strftime("%H:%M")
469 vars["dateInterval"] = (fsdate, fstime, fedate, fetime)
471 vars["location"] = None
472 vars["address"] = None
473 vars["room"] = None
475 location = self._conf.getLocation()
476 if location:
477 vars["location"] = location.getName()
478 vars["address"] = location.getAddress()
480 room = self._conf.getRoom()
481 if room and room.getName():
482 roomLink = linking.RoomLinker().getHTMLLink(room, location)
483 vars["room"] = roomLink
485 vars["chairs"] = self._conf.getChairList()
486 vars["attachments"] = self._conf.attached_items
487 vars["conf"] = self._conf
489 info = self._conf.getContactInfo()
490 vars["moreInfo_html"] = isStringHTML(info)
491 vars["moreInfo"] = info
492 vars["actions"] = ''
493 vars["isSubmitter"] = self._conf.getAccessController().canUserSubmit(self._aw.getUser()) or self._conf.canModify(self._aw)
495 regform = self._conf.getRegistrationForm()
496 if regform:
497 vars["registration_enabled"] = regform.isActivated()
498 vars["in_registration_period"] = regform.inRegistrationPeriod(nowutc())
499 vars["in_modification_period"] = regform.inModificationPeriod()
500 vars["registration_deadline"] = format_date(regform.getEndRegistrationDate())
501 vars["modification_deadline"] = format_date(regform.getModificationEndDate())
502 vars["ticket_enabled"] = regform.getETicket().isEnabled()
503 if session.avatar:
504 vars["registrant"] = session.avatar.getRegistrantById(self._conf.getId())
505 return vars
508 class WConfDetailsFull(WConfDetailsBase):
509 pass
512 #---------------------------------------------------------------------------
515 class WConfDetails:
517 def __init__(self, aw, conf):
518 self._conf = conf
519 self._aw = aw
521 def getHTML( self, params ):
522 return WConfDetailsFull( self._aw, self._conf ).getHTML( params )
525 class WPConferenceDisplay(WPConferenceDefaultDisplayBase):
527 def getCSSFiles(self):
528 return (WPConferenceDefaultDisplayBase.getCSSFiles(self)
529 + self._asset_env['eventservices_sass'].urls()
530 + self._asset_env['event_display_sass'].urls())
532 def _getBody(self, params):
534 wc = WConfDetails(self._getAW(), self._conf)
535 pars = {"modifyURL": urlHandlers.UHConferenceModification.getURL(self._conf),
536 "sessionModifyURLGen": urlHandlers.UHSessionModification.getURL,
537 "contribModifyURLGen": urlHandlers.UHContributionModification.getURL,
538 "subContribModifyURLGen": urlHandlers.UHSubContribModification.getURL}
539 return wc.getHTML(pars)
541 def _getFooter(self):
542 wc = wcomponents.WEventFooter(self._conf)
543 return wc.getHTML()
545 def _defineSectionMenu(self):
546 WPConferenceDefaultDisplayBase._defineSectionMenu(self)
547 self._sectionMenu.setCurrentItem(self._overviewOpt)
549 class WSentMail (wcomponents.WTemplated):
550 def __init__(self,conf):
551 self._conf = conf
553 def getVars(self):
554 vars = wcomponents.WTemplated.getVars( self )
555 vars["BackURL"]=urlHandlers.UHConferenceDisplay.getURL(self._conf)
556 return vars
559 class WPSentEmail( WPConferenceDefaultDisplayBase ):
560 def _getBody(self,params):
561 wc = WSentMail(self._conf)
562 return wc.getHTML()
564 class WEmail(wcomponents.WTemplated):
566 def __init__(self,conf,user,toUsers):
567 self._conf = conf
568 self._from = user
569 self._to = toUsers
571 def getVars(self):
572 vars = wcomponents.WTemplated.getVars( self )
573 if vars.get("from", None) is None :
574 vars["FromName"] = self._from
575 vars["fromUser"] = self._from
576 vars["toUsers"] = self._to
577 if vars.get("postURL",None) is None :
578 vars["postURL"]=urlHandlers.UHConferenceSendEmail.getURL(self._to)
579 if vars.get("subject", None) is None :
580 vars["subject"]=""
581 if vars.get("body", None) is None :
582 vars["body"]=""
583 return vars
585 class WPEMail ( WPConferenceDefaultDisplayBase ):
587 def _getBody(self,params):
588 toemail = params["emailto"]
589 wc = WEmail(self._conf, self._getAW().getUser(), toemail)
590 params["fromDisabled"] = True
591 params["toDisabled"] = True
592 params["ccDisabled"] = True
593 return wc.getHTML(params)
595 class WPXSLConferenceDisplay(WPConferenceBase):
597 Use this class just to transform to XML
600 def __init__(self, rh, conference, view, type, params):
601 WPConferenceBase.__init__(self, rh, conference)
602 self._params = params
603 self._view = view
604 self._conf = conference
605 self._type = type
606 self._firstDay = params.get("firstDay")
607 self._lastDay = params.get("lastDay")
608 self._daysPerRow = params.get("daysPerRow")
610 def _getFooter(self):
613 return ""
615 def _getHTMLHeader(self):
616 return ""
618 def _applyDecoration(self, body):
621 return body
623 def _getHTMLFooter(self):
624 return ""
626 def _getBodyVariables(self):
627 pars = { \
628 "modifyURL": urlHandlers.UHConferenceModification.getURL( self._conf ), \
629 "iCalURL": urlHandlers.UHConferenceToiCal.getURL(self._conf), \
630 "cloneURL": urlHandlers.UHConfClone.getURL( self._conf ), \
631 "sessionModifyURLGen": urlHandlers.UHSessionModification.getURL, \
632 "contribModifyURLGen": urlHandlers.UHContributionModification.getURL, \
633 "subContribModifyURLGen": urlHandlers.UHSubContribModification.getURL}
635 pars.update({ 'firstDay' : self._firstDay, 'lastDay' : self._lastDay, 'daysPerRow' : self._daysPerRow })
636 return pars
638 def _getBody(self, params):
639 body_vars = self._getBodyVariables()
640 view = self._view
641 outGen = outputGenerator(self._getAW())
642 styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
643 if styleMgr.existsXSLFile(self._view):
644 if self._params.get("detailLevel", "") == "contribution" or self._params.get("detailLevel", "") == "":
645 includeContribution = 1
646 else:
647 includeContribution = 0
648 body = outGen.getFormattedOutput(self._rh, self._conf, styleMgr.getXSLPath(self._view), body_vars, 1,
649 includeContribution, 1, 1, self._params.get("showSession", ""),
650 self._params.get("showDate", ""))
651 return body
652 else:
653 return _("Cannot find the %s stylesheet") % view
655 def _defineSectionMenu(self):
656 WPConferenceDefaultDisplayBase._defineSectionMenu(self)
657 self._sectionMenu.setCurrentItem(self._overviewOpt)
660 class WPTPLConferenceDisplay(WPXSLConferenceDisplay, object):
662 Overrides XSL related functions in WPXSLConferenceDisplay
663 class and re-implements them using normal Indico templates.
666 def __init__(self, rh, conference, view, type, params):
667 WPXSLConferenceDisplay.__init__(self, rh, conference, view, type, params)
668 imagesBaseURL = Config.getInstance().getImagesBaseURL()
669 self._types = {
670 "pdf" :{"mapsTo" : "pdf", "imgURL" : os.path.join(imagesBaseURL, "pdf_small.png"), "imgAlt" : "pdf file"},
671 "doc" :{"mapsTo" : "doc", "imgURL" : os.path.join(imagesBaseURL, "word.png"), "imgAlt" : "word file"},
672 "docx" :{"mapsTo" : "doc", "imgURL" : os.path.join(imagesBaseURL, "word.png"), "imgAlt" : "word file"},
673 "ppt" :{"mapsTo" : "ppt", "imgURL" : os.path.join(imagesBaseURL, "powerpoint.png"), "imgAlt" : "powerpoint file"},
674 "pptx" :{"mapsTo" : "ppt", "imgURL" : os.path.join(imagesBaseURL, "powerpoint.png"), "imgAlt" : "powerpoint file"},
675 "xls" :{"mapsTo" : "xls", "imgURL" : os.path.join(imagesBaseURL, "excel.png"), "imgAlt" : "excel file"},
676 "xlsx" :{"mapsTo" : "xls", "imgURL" : os.path.join(imagesBaseURL, "excel.png"), "imgAlt" : "excel file"},
677 "sxi" :{"mapsTo" : "odp", "imgURL" : os.path.join(imagesBaseURL, "impress.png"), "imgAlt" : "presentation file"},
678 "odp" :{"mapsTo" : "odp", "imgURL" : os.path.join(imagesBaseURL, "impress.png"), "imgAlt" : "presentation file"},
679 "sxw" :{"mapsTo" : "odt", "imgURL" : os.path.join(imagesBaseURL, "writer.png"), "imgAlt" : "writer file"},
680 "odt" :{"mapsTo" : "odt", "imgURL" : os.path.join(imagesBaseURL, "writer.png"), "imgAlt" : "writer file"},
681 "sxc" :{"mapsTo" : "ods", "imgURL" : os.path.join(imagesBaseURL, "calc.png"), "imgAlt" : "spreadsheet file"},
682 "ods" :{"mapsTo" : "ods", "imgURL" : os.path.join(imagesBaseURL, "calc.png"), "imgAlt" : "spreadsheet file"},
683 "other" :{"mapsTo" : "other", "imgURL" : os.path.join(imagesBaseURL, "file_small.png"), "imgAlt" : "unknown type file"},
684 "link" :{"mapsTo" : "link", "imgURL" : os.path.join(imagesBaseURL, "link.png"), "imgAlt" : "link"}
687 def _getVariables(self, conf):
688 wvars = {}
689 styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
690 wvars['INCLUDE'] = '../include'
692 wvars['accessWrapper'] = accessWrapper = self._rh._aw
693 wvars['conf'] = conf
694 if conf.getOwnerList():
695 wvars['category'] = conf.getOwnerList()[0].getName()
696 else:
697 wvars['category'] = ''
699 timezoneUtil = DisplayTZ(accessWrapper, conf)
700 tz = timezoneUtil.getDisplayTZ()
701 wvars['startDate'] = conf.getAdjustedStartDate(tz)
702 wvars['endDate'] = conf.getAdjustedEndDate(tz)
703 wvars['timezone'] = tz
705 if conf.getParticipation().displayParticipantList() :
706 wvars['participants'] = conf.getParticipation().getPresentParticipantListText()
708 attached_items = conf.attached_items
710 lectures, folders = [], []
712 for folder in attached_items.get('folders', []):
713 if LECTURE_SERIES_RE.match(folder.title):
714 lectures.append(folder)
715 elif folder.title != "Internal Page Files":
716 folders.append(folder)
718 cmp_title_number = lambda x, y: int(x.title[4:]) - int(y.title[4:])
720 wvars.update({
721 'files': attached_items.get('files', []),
722 'folders': folders,
723 'lectures': sorted(lectures, cmp=cmp_title_number)
726 if (conf.getType() in ("meeting", "simple_event")
727 and conf.getParticipation().isAllowedForApplying()
728 and conf.getStartDate() > nowutc()
729 and not conf.getParticipation().isFull()):
730 wvars['registrationOpen'] = True
731 evaluation = conf.getEvaluation()
732 if evaluation.isVisible() and evaluation.inEvaluationPeriod() and evaluation.getNbOfQuestions() > 0:
733 wvars['evaluationLink'] = urlHandlers.UHConfEvaluationDisplay.getURL(conf)
734 wvars['supportEmailCaption'] = conf.getSupportInfo().getCaption()
736 wvars['types'] = self._types
738 wvars['entries'] = []
739 confSchedule = conf.getSchedule()
740 showSession = self._params.get("showSession","all")
741 detailLevel = self._params.get("detailLevel", "contribution")
742 showDate = self._params.get("showDate", "all")
743 # Filter by day
744 if showDate == "all":
745 entrylist = confSchedule.getEntries()
746 else:
747 entrylist = confSchedule.getEntriesOnDay(timezone(tz).localize(stringToDate(showDate)))
748 # Check entries filters and access rights
749 for entry in entrylist:
750 sessionCand = entry.getOwner().getOwner()
751 # Filter by session
752 if isinstance(sessionCand, Session) and (showSession != "all" and sessionCand.getId() != showSession):
753 continue
754 # Hide/Show contributions
755 if isinstance(entry.getOwner(), Contribution) and detailLevel != "contribution":
756 continue
757 if entry.getOwner().canView(accessWrapper):
758 if type(entry) is schedule.BreakTimeSchEntry:
759 newItem = entry
760 else:
761 newItem = entry.getOwner()
762 wvars['entries'].append(newItem)
764 wvars['entries'].sort(key=lambda entry: entry.getEndDate(), reverse=True)
765 wvars['entries'].sort(key=lambda entry: (entry.getStartDate(),
766 entry.getFullTitle() if hasattr(entry, 'getFullTitle') else None))
767 wvars["daysPerRow"] = self._daysPerRow
768 wvars["firstDay"] = self._firstDay
769 wvars["lastDay"] = self._lastDay
770 wvars["currentUser"] = self._rh._aw.getUser()
771 wvars["reportNumberSystems"] = Config.getInstance().getReportNumberSystems()
772 return wvars
774 def _getItemType(self, item):
775 itemClass = item.__class__.__name__
776 if itemClass == 'BreakTimeSchEntry':
777 return 'Break'
778 elif itemClass == 'SessionSlot':
779 return 'Session'
780 elif itemClass == 'AcceptedContribution':
781 return 'Contribution'
782 else:
783 # return Conference, Contribution or SubContribution
784 return itemClass
786 def _extractInfoForButton(self, item):
787 info = {}
788 for key in ['sessId', 'slotId', 'contId', 'subContId']:
789 info[key] = 'null'
790 info['confId'] = self._conf.getId()
792 itemType = self._getItemType(item)
793 info['uploadURL'] = 'Indico.Urls.UploadAction.%s' % itemType.lower()
795 if itemType == 'Conference':
796 info['parentProtection'] = item.getAccessController().isProtected()
797 if item.canModify(self._rh._aw):
798 info["modifyLink"] = urlHandlers.UHConferenceModification.getURL(item)
799 info["minutesLink"] = True
800 info["materialLink"] = True
801 info["cloneLink"] = urlHandlers.UHConfClone.getURL(item)
802 if item.getAccessController().canUserSubmit(self._rh._aw.getUser()):
803 info["minutesLink"] = True
804 info["materialLink"] = True
806 elif itemType == 'Session':
807 session = item.getSession()
808 info['parentProtection'] = session.getAccessController().isProtected()
809 if session.canModify(self._rh._aw) or session.canCoordinate(self._rh._aw):
810 info["modifyLink"] = urlHandlers.UHSessionModification.getURL(item)
811 info['slotId'] = item.getId()
812 info['sessId'] = session.getId()
813 if session.canModify(self._rh._aw) or session.canCoordinate(self._rh._aw):
814 info["minutesLink"] = True
815 info["materialLink"] = True
816 url = urlHandlers.UHSessionModifSchedule.getURL(session)
817 ttLink = "%s#%s.s%sl%s" % (url, session.getStartDate().strftime('%Y%m%d'), session.getId(), info['slotId'])
818 info["sessionTimetableLink"] = ttLink
820 elif itemType == 'Contribution':
821 info['parentProtection'] = item.getAccessController().isProtected()
822 if item.canModify(self._rh._aw):
823 info["modifyLink"] = urlHandlers.UHContributionModification.getURL(item)
824 if item.canModify(self._rh._aw) or item.canUserSubmit(self._rh._aw.getUser()):
825 info["minutesLink"] = True
826 info["materialLink"] = True
827 info["contId"] = item.getId()
828 owner = item.getOwner()
829 if self._getItemType(owner) == 'Session':
830 info['sessId'] = owner.getId()
832 elif itemType == 'SubContribution':
833 info['parentProtection'] = item.getContribution().getAccessController().isProtected()
834 if item.canModify(self._rh._aw):
835 info["modifyLink"] = urlHandlers.UHSubContributionModification.getURL(item)
836 if item.canModify(self._rh._aw) or item.canUserSubmit(self._rh._aw.getUser()):
837 info["minutesLink"] = True
838 info["materialLink"] = True
839 info["subContId"] = item.getId()
840 info["contId"] = item.getContribution().getId()
841 owner = item.getOwner()
842 if self._getItemType(owner) == 'Session':
843 info['sessId'] = owner.getId()
845 return info
847 def _getHTMLHeader( self ):
848 return WPConferenceBase._getHTMLHeader(self)
850 def _getHeadContent( self ):
851 config = Config.getInstance()
852 styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
853 htdocs = config.getHtdocsDir()
854 baseurl = self._getBaseURL()
855 # First include the default Indico stylesheet
856 try:
857 timestamp = os.stat(__file__).st_mtime
858 except OSError:
859 timestamp = 0
860 styleText = """<link rel="stylesheet" href="%s/css/%s?%d">\n""" % \
861 (baseurl, Config.getInstance().getCssStylesheetName(), timestamp)
862 # Then the common event display stylesheet
863 if os.path.exists("%s/css/events/common.css" % htdocs):
864 styleText += """ <link rel="stylesheet" href="%s/css/events/common.css?%d">\n""" % (baseurl,
865 timestamp)
867 # And finally the specific display stylesheet
868 if styleMgr.existsCSSFile(self._view):
869 cssPath = os.path.join(baseurl, 'css', 'events', styleMgr.getCSSFilename(self._view))
870 styleText += """ <link rel="stylesheet" href="%s?%d">\n""" % (cssPath, timestamp)
872 confMetadata = WConfMetadata(self._conf).getHTML()
874 mathJax = render('js/mathjax.config.js.tpl') + \
875 '\n'.join(['<script src="{0}" type="text/javascript"></script>'.format(url) for url in
876 self._asset_env['mathjax_js'].urls()])
878 return styleText + confMetadata + mathJax
880 def _getFooter( self ):
883 wc = wcomponents.WEventFooter(self._conf)
884 p = {"modificationDate":format_datetime(self._conf.getModificationDate(), format='d MMMM yyyy H:mm'),"subArea": self._getSiteArea(),"dark":True}
885 if Config.getInstance().getShortEventURL():
886 id=self._conf.getUrlTag().strip()
887 if not id:
888 id = self._conf.getId()
889 p["shortURL"] = Config.getInstance().getShortEventURL() + id
890 return wc.getHTML(p)
892 def _getHeader( self ):
895 if self._type == "simple_event":
896 wc = wcomponents.WMenuSimpleEventHeader( self._getAW(), self._conf )
897 elif self._type == "meeting":
898 wc = wcomponents.WMenuMeetingHeader( self._getAW(), self._conf )
899 else:
900 wc = wcomponents.WMenuConferenceHeader( self._getAW(), self._conf )
901 return wc.getHTML( { "loginURL": self.getLoginURL(),\
902 "logoutURL": self.getLogoutURL(),\
903 "confId": self._conf.getId(),\
904 "currentView": self._view,\
905 "type": self._type,\
906 "selectedDate": self._params.get("showDate",""),\
907 "selectedSession": self._params.get("showSession",""),\
908 "detailLevel": self._params.get("detailLevel",""),\
909 "filterActive": self._params.get("filterActive",""),\
910 "dark": True } )
912 def getCSSFiles(self):
913 return (WPConferenceBase.getCSSFiles(self) +
914 self._asset_env['eventservices_sass'].urls() +
915 self._asset_env['event_display_sass'].urls())
917 def getJSFiles(self):
918 modules = WPConferenceBase.getJSFiles(self)
920 # TODO: find way to check if the user is able to manage
921 # anything inside the conference (sessions, ...)
922 modules += (self._includeJSPackage('Management') +
923 self._includeJSPackage('MaterialEditor') +
924 self._includeJSPackage('Display') +
925 self._asset_env['modules_vc_js'].urls() +
926 self._asset_env['modules_event_display_js'].urls() +
927 self._asset_env['zero_clipboard_js'].urls())
928 return modules
930 def _applyDecoration( self, body ):
933 if self._params.get("frame","")=="no" or self._params.get("fr","")=="no":
934 return WPrintPageFrame().getHTML({"content":body})
935 return WPConferenceBase._applyDecoration(self, body)
937 def _getHTMLFooter( self ):
938 if self._params.get("frame","")=="no" or self._params.get("fr","")=="no":
939 return ""
940 return WPConferenceBase._getHTMLFooter(self)
942 @staticmethod
943 def getLocationInfo(item, roomLink=True, fullName=False):
944 """Return a tuple (location, room, url) containing
945 information about the location of the item."""
946 minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
947 location = item.getLocation().getName() if item.getLocation() else ""
948 customRoom = item.getRoom()
949 if not customRoom:
950 roomName = ''
951 elif fullName and location and Config.getInstance().getIsRoomBookingActive():
952 # if we want the full name and we have a RB DB to search in
953 roomName = customRoom.getFullName()
954 if not roomName:
955 customRoom.retrieveFullName(location) # try to fetch the full name
956 roomName = customRoom.getFullName() or customRoom.getName()
957 else:
958 roomName = customRoom.getName()
959 # TODO check if the following if is required
960 if roomName in ['', '0--', 'Select:']:
961 roomName = ''
962 if roomLink:
963 url = linking.RoomLinker().getURL(item.getRoom(), item.getLocation())
964 else:
965 url = ""
966 return (location, roomName, url)
968 def _getBody(self, params):
969 """Return main information about the event."""
971 if self._view != 'xml':
972 vars = self._getVariables(self._conf)
973 vars['getTime'] = lambda date : format_time(date.time(), format="HH:mm")
974 vars['isTime0H0M'] = lambda date : (date.hour, date.minute) == (0,0)
975 vars['getDate'] = lambda date : format_date(date, format='yyyy-MM-dd')
976 vars['prettyDate'] = lambda date : format_date(date, format='full')
977 vars['prettyDuration'] = MaKaC.common.utils.prettyDuration
978 vars['parseDate'] = MaKaC.common.utils.parseDate
979 vars['isStringHTML'] = MaKaC.common.utils.isStringHTML
980 vars['extractInfoForButton'] = lambda item : self._extractInfoForButton(item)
981 vars['getItemType'] = lambda item : self._getItemType(item)
982 vars['getLocationInfo'] = WPTPLConferenceDisplay.getLocationInfo
983 vars['dumps'] = json.dumps
984 vars['timedelta'] = timedelta
985 else:
986 outGen = outputGenerator(self._rh._aw)
987 varsForGenerator = self._getBodyVariables()
988 vars = {}
989 vars['xml'] = outGen._getBasicXML(self._conf, varsForGenerator, 1, 1, 1, 1)
991 styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
992 if styleMgr.existsTPLFile(self._view):
993 fileName = os.path.splitext(styleMgr.getTemplateFilename(self._view))[0]
994 body = wcomponents.WTemplated(os.path.join("events", fileName)).getHTML(vars)
995 else:
996 return _("Template could not be found.")
997 return body
1000 class WPrintPageFrame (wcomponents.WTemplated):
1001 pass
1004 class WConfDisplayBodyBase(wcomponents.WTemplated):
1006 def _getTitle(self):
1007 default_caption = displayMgr.SystemLinkData().getLinkData()[self._linkname]["caption"]
1008 caption = self._conf.getDisplayMgr().getMenu().getLinkByName(self._linkname).getCaption()
1009 return _(caption) if caption == default_caption else caption
1012 class WConfProgram(WConfDisplayBodyBase):
1014 _linkname = "programme"
1016 def __init__(self, aw, conf):
1017 self._conf = conf
1018 self._aw = aw
1020 def buildTrackData(self, track):
1022 Returns a dict representing the data of the track and its Sub-tracks
1023 should it have any.
1025 description = track.getDescription()
1027 formattedTrack = {
1028 'title': track.getTitle(),
1029 'description': description
1032 if track.getConference().getAbstractMgr().isActive() and \
1033 track.getConference().hasEnabledSection("cfa") and \
1034 track.canCoordinate(self._aw):
1036 if track.getConference().canModify(self._aw):
1037 formattedTrack['url'] = urlHandlers.UHTrackModification.getURL(track)
1038 else:
1039 formattedTrack['url'] = urlHandlers.UHTrackModifAbstracts.getURL(track)
1041 return formattedTrack
1043 def getVars(self):
1044 pvars = wcomponents.WTemplated.getVars(self)
1045 pvars["body_title"] = self._getTitle()
1046 pvars['description'] = self._conf.getProgramDescription()
1047 pvars['program'] = [self.buildTrackData(t) for t in self._conf.getTrackList()]
1048 pvars['pdf_url'] = urlHandlers.UHConferenceProgramPDF.getURL(self._conf)
1050 return pvars
1053 class WPConferenceProgram(WPConferenceDefaultDisplayBase):
1055 def _getBody(self, params):
1056 wc = WConfProgram(self._getAW(), self._conf)
1057 return wc.getHTML()
1059 def _defineSectionMenu(self):
1060 WPConferenceDefaultDisplayBase._defineSectionMenu(self)
1061 self._sectionMenu.setCurrentItem(self._programOpt)
1064 class WInternalPageDisplay(wcomponents.WTemplated):
1066 def __init__(self, conf, page):
1067 self._conf = conf
1068 self._page=page
1070 def getVars( self ):
1071 vars = wcomponents.WTemplated.getVars( self )
1072 vars["content"] = self._page.getContent()
1073 return vars
1075 class WPInternalPageDisplay( WPConferenceDefaultDisplayBase ):
1077 def __init__( self, rh, conference, page ):
1078 WPConferenceDefaultDisplayBase.__init__( self, rh, conference )
1079 self._page = page
1081 def _getBody( self, params ):
1082 wc = WInternalPageDisplay( self._conf, self._page )
1083 return wc.getHTML()
1085 def _defineSectionMenu( self ):
1086 WPConferenceDefaultDisplayBase._defineSectionMenu(self)
1088 for link in self._sectionMenu.getAllLinks():
1089 if link.getType() == 'page' and link.getPage().getId() == self._page.getId():
1090 self._sectionMenu.setCurrentItem(link)
1091 break
1094 class WConferenceTimeTable(WConfDisplayBodyBase):
1096 _linkname = "timetable"
1098 def __init__(self, conference, aw):
1099 self._conf = conference
1100 self._aw = aw
1102 def getVars(self):
1103 wvars = wcomponents.WTemplated.getVars(self)
1104 tz = DisplayTZ(self._aw, self._conf).getDisplayTZ()
1105 sf = schedule.ScheduleToJson.process(self._conf.getSchedule(),
1106 tz, self._aw,
1107 useAttrCache=True,
1108 hideWeekends=True)
1109 # TODO: Move to beginning of file when proved useful
1110 try:
1111 import ujson
1112 jsonf = ujson.encode
1113 except ImportError:
1114 jsonf = json.dumps
1115 wvars["ttdata"] = jsonf(sf)
1116 eventInfo = fossilize(self._conf, IConferenceEventInfoFossil, tz=tz)
1117 eventInfo['isCFAEnabled'] = self._conf.getAbstractMgr().isActive()
1118 wvars['eventInfo'] = eventInfo
1119 wvars['timetableLayout'] = wvars.get('ttLyt', '')
1120 return wvars
1123 class WPConferenceTimeTable(WPConferenceDefaultDisplayBase):
1124 navigationEntry = navigation.NEConferenceTimeTable
1126 def getJSFiles(self):
1127 return WPConferenceDefaultDisplayBase.getJSFiles(self) + \
1128 self._includeJSPackage('Timetable')
1130 def _getHeadContent(self):
1131 content = WPConferenceDefaultDisplayBase._getHeadContent(self)
1132 return content + '<link rel="stylesheet" type="text/css" href="{}/css/timetable.css">'.format(
1133 self._getBaseURL())
1135 def _getBody( self, params ):
1136 wc = WConferenceTimeTable( self._conf, self._getAW() )
1137 return wc.getHTML(params)
1139 def _defineSectionMenu( self ):
1140 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
1141 self._sectionMenu.setCurrentItem(self._timetableOpt)
1144 class WPMeetingTimeTable( WPTPLConferenceDisplay ):
1146 def getJSFiles(self):
1147 return WPXSLConferenceDisplay.getJSFiles(self) + \
1148 self._includeJSPackage('Timetable')
1150 def _getBody( self, params ):
1151 wc = WConferenceTimeTable( self._conf, self._getAW() )
1152 return wc.getHTML(params)
1155 class WPConferenceModifBase(main.WPMainBase):
1157 _userData = ['favorite-user-ids']
1159 def __init__(self, rh, conference, **kwargs):
1160 main.WPMainBase.__init__(self, rh, **kwargs)
1161 self._navigationTarget = self._conf = conference
1163 def getJSFiles(self):
1164 return main.WPMainBase.getJSFiles(self) + \
1165 self._includeJSPackage('Management') + \
1166 self._includeJSPackage('MaterialEditor')
1168 def _getSiteArea(self):
1169 return "ModificationArea"
1171 def _getHeader( self ):
1174 wc = wcomponents.WHeader( self._getAW() )
1175 return wc.getHTML( { "subArea": self._getSiteArea(), \
1176 "loginURL": self._escapeChars(str(self.getLoginURL())),\
1177 "logoutURL": self._escapeChars(str(self.getLogoutURL())) } )
1179 def _getNavigationDrawer(self):
1180 pars = {"target": self._conf, "isModif": True }
1181 return wcomponents.WNavigationDrawer( pars, bgColor="white" )
1183 def _createSideMenu(self):
1184 self._sideMenu = wcomponents.ManagementSideMenu(event=self._conf)
1186 # The main section containing most menu items
1187 self._generalSection = wcomponents.SideMenuSection()
1189 self._generalSettingsMenuItem = wcomponents.SideMenuItem(_("General settings"),
1190 urlHandlers.UHConferenceModification.getURL( self._conf ))
1191 self._generalSection.addItem( self._generalSettingsMenuItem)
1193 self._timetableMenuItem = wcomponents.SideMenuItem(_("Timetable"),
1194 urlHandlers.UHConfModifSchedule.getURL( self._conf ))
1195 self._generalSection.addItem( self._timetableMenuItem)
1197 self._roomBookingMenuItem = wcomponents.SideMenuItem(_("Room booking"),
1198 url_for('event_mgmt.rooms_booking_list', self._conf))
1199 self._generalSection.addItem( self._roomBookingMenuItem)
1201 self._programMenuItem = wcomponents.SideMenuItem(_("Programme"),
1202 urlHandlers.UHConfModifProgram.getURL( self._conf ))
1203 self._generalSection.addItem( self._programMenuItem)
1205 self._regFormMenuItem = wcomponents.SideMenuItem(_("Registration"),
1206 urlHandlers.UHConfModifRegForm.getURL( self._conf ))
1207 self._generalSection.addItem( self._regFormMenuItem)
1209 self._abstractMenuItem = wcomponents.SideMenuItem(_("Abstracts"),
1210 urlHandlers.UHConfModifCFA.getURL( self._conf ))
1211 self._generalSection.addItem( self._abstractMenuItem)
1213 self._contribListMenuItem = wcomponents.SideMenuItem(_("Contributions"),
1214 urlHandlers.UHConfModifContribList.getURL( self._conf ))
1215 self._generalSection.addItem( self._contribListMenuItem)
1217 self._reviewingMenuItem = wcomponents.SideMenuItem(_("Paper Reviewing"),
1218 urlHandlers.UHConfModifReviewingAccess.getURL( target = self._conf ) )
1219 self._generalSection.addItem( self._reviewingMenuItem)
1221 self._participantsMenuItem = wcomponents.SideMenuItem(_("Participants"),
1222 urlHandlers.UHConfModifParticipants.getURL( self._conf ) )
1223 self._generalSection.addItem( self._participantsMenuItem)
1225 self._evaluationMenuItem = wcomponents.SideMenuItem(_("Evaluation"),
1226 urlHandlers.UHConfModifEvaluation.getURL( self._conf ) )
1227 self._generalSection.addItem( self._evaluationMenuItem)
1229 self.extra_menu_items = {}
1230 for name, item in sorted(values_from_signal(signals.event_management.sidemenu.send(self._conf)),
1231 key=lambda x: x[1]._title):
1232 self.extra_menu_items[name] = item
1233 self._generalSection.addItem(item)
1235 self._sideMenu.addSection(self._generalSection)
1237 # The section containing all advanced options
1238 self._advancedOptionsSection = wcomponents.SideMenuSection(_("Advanced options"))
1240 self._listingsMenuItem = wcomponents.SideMenuItem(_("Lists"),
1241 urlHandlers.UHConfAllSpeakers.getURL( self._conf ) )
1242 self._advancedOptionsSection.addItem( self._listingsMenuItem)
1244 self._ACMenuItem = wcomponents.SideMenuItem(_("Protection"),
1245 urlHandlers.UHConfModifAC.getURL( self._conf ) )
1246 self._advancedOptionsSection.addItem( self._ACMenuItem)
1248 self._toolsMenuItem = wcomponents.SideMenuItem(_("Tools"),
1249 urlHandlers.UHConfModifTools.getURL( self._conf ) )
1250 self._advancedOptionsSection.addItem( self._toolsMenuItem)
1252 self._layoutMenuItem = wcomponents.SideMenuItem(_("Layout"),
1253 urlHandlers.UHConfModifDisplay.getURL(self._conf))
1254 self._advancedOptionsSection.addItem( self._layoutMenuItem)
1256 self.extra_menu_items_advanced = {}
1257 for name, item in sorted(values_from_signal(signals.event_management.sidemenu_advanced.send(self._conf)),
1258 key=lambda x: x[1]._title):
1259 self.extra_menu_items_advanced[name] = item
1260 self._advancedOptionsSection.addItem(item)
1262 self._sideMenu.addSection(self._advancedOptionsSection)
1264 #we decide which side menu item appear and which don't
1265 from MaKaC.webinterface.rh.reviewingModif import RCPaperReviewManager, RCReviewingStaff
1267 canModify = self._conf.canModify(self._rh.getAW())
1268 isReviewingStaff = RCReviewingStaff.hasRights(self._rh)
1269 isPRM = RCPaperReviewManager.hasRights(self._rh)
1270 #isAM = RCAbstractManager.hasRights(self._rh)
1271 isRegistrar = self._conf.canManageRegistration(self._rh.getAW().getUser())
1273 if not canModify:
1274 self._generalSettingsMenuItem.setVisible(False)
1275 self._timetableMenuItem.setVisible(False)
1276 self._programMenuItem.setVisible(False)
1277 self._participantsMenuItem.setVisible(False)
1278 self._listingsMenuItem.setVisible(False)
1279 self._layoutMenuItem.setVisible(False)
1280 self._ACMenuItem.setVisible(False)
1281 self._toolsMenuItem.setVisible(False)
1282 self._evaluationMenuItem.setVisible(False)
1284 if not (Config.getInstance().getIsRoomBookingActive() and canModify):
1285 self._roomBookingMenuItem.setVisible(False)
1287 #if not (self._conf.hasEnabledSection("cfa") and (canModify or isAM)):
1288 if not (self._conf.hasEnabledSection("cfa") and (canModify)):
1289 self._abstractMenuItem.setVisible(False)
1291 if not (canModify or isPRM):
1292 self._contribListMenuItem.setVisible(False)
1294 if not (self._conf.hasEnabledSection("regForm") and (canModify or isRegistrar)):
1295 self._regFormMenuItem.setVisible(False)
1297 if not (self._conf.getType() == "conference" and (canModify or isReviewingStaff)):
1298 self._reviewingMenuItem.setVisible(False)
1299 else: #reviewing tab is enabled
1300 if isReviewingStaff and not canModify:
1301 self._reviewingMenuItem.setVisible(True)
1302 # For now we don't want the paper reviewing to be displayed
1303 #self._reviewingMenuItem.setVisible(False)
1305 #we hide the Advanced Options section if it has no items
1306 if not self._advancedOptionsSection.hasVisibleItems():
1307 self._advancedOptionsSection.setVisible(False)
1309 # we disable the Participants section for events of type conference
1310 if self._conf.getType() == 'conference':
1311 self._participantsMenuItem.setVisible(False)
1313 wf = self._rh.getWebFactory()
1314 if wf:
1315 wf.customiseSideMenu( self )
1317 def _setActiveSideMenuItem( self ):
1318 pass
1320 def _applyFrame( self, body ):
1321 frame = wcomponents.WConferenceModifFrame( self._conf, self._getAW())
1323 sideMenu = self._sideMenu.getHTML()
1325 p = { "categDisplayURLGen": urlHandlers.UHCategoryDisplay.getURL, \
1326 "confDisplayURLGen": urlHandlers.UHConferenceDisplay.getURL, \
1327 "event": "Conference",
1328 "sideMenu": sideMenu }
1329 wf = self._rh.getWebFactory()
1330 if wf:
1331 p["event"]=wf.getName()
1332 return frame.getHTML( body, **p )
1334 def _getBody( self, params ):
1335 self._createSideMenu()
1336 self._setActiveSideMenuItem()
1338 return self._applyFrame( self._getPageContent( params ) )
1340 def _getTabContent( self, params ):
1341 return "nothing"
1343 def _getPageContent( self, params ):
1344 return "nothing"
1346 class WPConferenceModifAbstractBase( WPConferenceModifBase ):
1348 def __init__(self, rh, conf):
1349 WPConferenceModifBase.__init__(self, rh, conf)
1351 def _createTabCtrl(self):
1352 self._tabCtrl = wcomponents.TabControl()
1354 self._tabCFA = self._tabCtrl.newTab( "cfasetup", _("Setup"), urlHandlers.UHConfModifCFA.getURL( self._conf ) )
1355 self._tabCFAPreview = self._tabCtrl.newTab("cfapreview", _("Preview"), urlHandlers.UHConfModifCFAPreview.getURL(self._conf))
1356 self._tabAbstractList = self._tabCtrl.newTab( "abstractList", _("List of Abstracts"), urlHandlers.UHConfAbstractList.getURL( self._conf ) )
1357 self._tabBOA = self._tabCtrl.newTab("boa", _("Book of Abstracts Setup"), urlHandlers.UHConfModAbstractBook.getURL(self._conf))
1358 self._tabCFAR = self._tabCtrl.newTab("reviewing", _("Reviewing"), urlHandlers.UHAbstractReviewingSetup.getURL(self._conf))
1360 # Create subtabs for the reviewing
1361 self._subTabARSetup = self._tabCFAR.newSubTab( "revsetup", _("Settings"),\
1362 urlHandlers.UHAbstractReviewingSetup.getURL(self._conf))
1363 self._subTabARTeam = self._tabCFAR.newSubTab( "revteam", _("Team"),\
1364 urlHandlers.UHAbstractReviewingTeam.getURL(self._conf))
1365 self._subTabARNotifTpl = self._tabCFAR.newSubTab( "notiftpl", _("Notification templates"),\
1366 urlHandlers.UHAbstractReviewingNotifTpl.getURL(self._conf))
1368 if not self._conf.hasEnabledSection("cfa"):
1369 self._tabBOA.disable()
1370 self._tabCFA.disable()
1371 self._tabAbstractList.disable()
1372 self._tabCFAPreview.disable()
1373 self._tabCFAR.disable()
1375 self._setActiveTab()
1377 def _getPageContent(self, params):
1378 self._createTabCtrl()
1380 return wcomponents.WTabControl( self._tabCtrl, self._getAW() ).getHTML( self._getTabContent( params ) )
1382 def _setActiveSideMenuItem(self):
1383 self._abstractMenuItem.setActive()
1385 def _getTabContent(self, params):
1386 return "nothing"
1388 def _setActiveTab(self):
1389 pass
1392 class WConfModifMainData(wcomponents.WTemplated):
1394 def __init__(self, conference, ct, rh):
1395 self._conf = conference
1396 self._ct = ct
1397 self._rh = rh
1399 def _getChairPersonsList(self):
1400 result = fossilize(self._conf.getChairList())
1401 for chair in result:
1402 av = AvatarHolder().match({"email": chair['email']},
1403 searchInAuthenticators=False, exact=True)
1404 chair['showManagerCB'] = True
1405 chair['showSubmitterCB'] = True
1406 if not av:
1407 if self._conf.getPendingQueuesMgr().getPendingConfSubmittersByEmail(chair['email']):
1408 chair['showSubmitterCB'] = False
1409 elif (av[0] in self._conf.getAccessController().getSubmitterList()):
1410 chair['showSubmitterCB'] = False
1411 if (av and self._conf.getAccessController().canModify(av[0])) or chair['email'] in self._conf.getAccessController().getModificationEmail():
1412 chair['showManagerCB'] = False
1413 return result
1415 def getVars(self):
1416 vars = wcomponents.WTemplated.getVars(self)
1417 type = vars["type"]
1418 vars["defaultStyle"] = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getDefaultStyle()
1419 vars["visibility"] = self._conf.getVisibility()
1420 vars["dataModificationURL"]=quoteattr(str(urlHandlers.UHConfDataModif.getURL(self._conf)))
1421 vars["addTypeURL"]=urlHandlers.UHConfAddContribType.getURL(self._conf)
1422 vars["removeTypeURL"]=urlHandlers.UHConfRemoveContribType.getURL(self._conf)
1423 vars["title"]=self._conf.getTitle()
1424 if isStringHTML(self._conf.getDescription()):
1425 vars["description"] = self._conf.getDescription()
1426 elif self._conf.getDescription():
1427 vars["description"] = self._conf.getDescription()
1428 else:
1429 vars["description"] = ""
1431 ###################################
1432 # Fermi timezone awareness #
1433 ###################################
1434 tz = self._conf.getTimezone()
1435 vars["timezone"] = tz
1436 vars["startDate"]=formatDateTime(self._conf.getAdjustedStartDate())
1437 vars["endDate"]=formatDateTime(self._conf.getAdjustedEndDate())
1438 ###################################
1439 # Fermi timezone awareness(end) #
1440 ###################################
1441 vars["chairText"] = self.htmlText(self._conf.getChairmanText())
1442 place=self._conf.getLocation()
1444 vars["locationName"]=vars["locationAddress"]=""
1445 if place:
1446 vars["locationName"]=self.htmlText(place.getName())
1447 vars["locationAddress"]=self.htmlText(place.getAddress())
1448 room=self._conf.getRoom()
1449 vars["locationRoom"]=""
1450 if room:
1451 vars["locationRoom"]=self.htmlText(room.getName())
1452 if isStringHTML(self._conf.getContactInfo()):
1453 vars["contactInfo"]=self._conf.getContactInfo()
1454 else:
1455 vars["contactInfo"] = """<table class="tablepre"><tr><td><pre>%s</pre></td></tr></table>""" % self._conf.getContactInfo()
1456 vars["supportEmailCaption"] = self._conf.getSupportInfo().getCaption()
1457 vars["supportEmail"] = i18nformat("""--_("not set")--""")
1458 if self._conf.getSupportInfo().hasEmail():
1459 vars["supportEmail"] = self.htmlText(self._conf.getSupportInfo().getEmail())
1460 typeList = []
1461 for type in self._conf.getContribTypeList():
1462 typeList.append("""<input type="checkbox" name="types" value="%s"><a href="%s">%s</a><br>
1463 <table><tr><td width="30"></td><td><font><pre>%s</pre></font></td></tr></table>"""%( \
1464 type.getId(), \
1465 str(urlHandlers.UHConfEditContribType.getURL(type)), \
1466 type.getName(), \
1467 type.getDescription()))
1468 vars["typeList"] = "".join(typeList)
1469 #------------------------------------------------------
1470 vars["reportNumbersTable"]=wcomponents.WReportNumbersTable(self._conf).getHTML()
1471 vars["eventType"] = self._conf.getType()
1472 vars["keywords"] = self._conf.getKeywords()
1473 vars["shortURLBase"] = Config.getInstance().getShortEventURL()
1474 vars["shortURLTag"] = self._conf.getUrlTag()
1475 vars["screenDatesURL"] = urlHandlers.UHConfScreenDatesEdit.getURL(self._conf)
1476 ssdate = format_datetime(self._conf.getAdjustedScreenStartDate(), format='EEEE d MMMM yyyy H:mm')
1477 if self._conf.getScreenStartDate() == self._conf.getStartDate():
1478 ssdate += i18nformat(""" <i> _("(normal)")</i>""")
1479 else:
1480 ssdate += i18nformat(""" <font color='red'>_("(modified)")</font>""")
1481 sedate = format_datetime(self._conf.getAdjustedScreenEndDate(), format='EEEE d MMMM yyyy H:mm')
1482 if self._conf.getScreenEndDate() == self._conf.getEndDate():
1483 sedate += i18nformat(""" <i> _("(normal)")</i>""")
1484 else:
1485 sedate += i18nformat(""" <font color='red'> _("(modified)")</font>""")
1486 vars['rbActive'] = Config.getInstance().getIsRoomBookingActive()
1487 vars["screenDates"] = "%s -> %s" % (ssdate, sedate)
1488 vars["timezoneList"] = TimezoneRegistry.getList()
1489 vars["chairpersons"] = self._getChairPersonsList()
1491 loc = self._conf.getLocation()
1492 room = self._conf.getRoom()
1493 vars["currentLocation"] = { 'location': loc.getName() if loc else "",
1494 'room': room.name if room else "",
1495 'address': loc.getAddress() if loc else "" }
1496 return vars
1498 class WPConferenceModificationClosed( WPConferenceModifBase ):
1500 def __init__(self, rh, target):
1501 WPConferenceModifBase.__init__(self, rh, target)
1503 def _getPageContent( self, params ):
1504 message = _("The event is currently locked and you cannot modify it in this status. ")
1505 if self._conf.canModify(self._rh.getAW()):
1506 message += _("If you unlock the event, you will be able to modify its details again.")
1507 return wcomponents.WClosed().getHTML({"message": message,
1508 "postURL": urlHandlers.UHConferenceOpen.getURL(self._conf),
1509 "showUnlockButton": self._conf.canModify(self._rh.getAW()),
1510 "unlockButtonCaption": _("Unlock event")})
1513 class WPConferenceModification( WPConferenceModifBase ):
1515 def __init__(self, rh, target, ct=None):
1516 WPConferenceModifBase.__init__(self, rh, target)
1517 self._ct = ct
1519 def _setActiveSideMenuItem( self ):
1520 self._generalSettingsMenuItem.setActive()
1522 def _getPageContent( self, params ):
1523 wc = WConfModifMainData(self._conf, self._ct, self._rh)
1524 pars = { "type": params.get("type","") , "conferenceId": self._conf.getId()}
1525 return wc.getHTML( pars )
1527 class WConfModScreenDatesEdit(wcomponents.WTemplated):
1529 def __init__(self,conf):
1530 self._conf=conf
1532 def getVars(self):
1533 vars=wcomponents.WTemplated.getVars(self)
1534 vars["postURL"]=quoteattr(str(urlHandlers.UHConfScreenDatesEdit.getURL(self._conf)))
1535 ###################################
1536 # Fermi timezone awareness #
1537 ###################################
1538 csd = self._conf.getAdjustedStartDate()
1539 ced = self._conf.getAdjustedEndDate()
1540 ###################################
1541 # Fermi timezone awareness(end) #
1542 ###################################
1543 vars["conf_start_date"]=self.htmlText(format_datetime(csd, format='EEEE d MMMM yyyy H:mm'))
1544 vars["conf_end_date"]=self.htmlText(format_datetime(ced, format='EEEE d MMMM yyyy H:mm'))
1545 vars["start_date_own_sel"]=""
1546 vars["start_date_conf_sel"]=" checked"
1547 vars["sDay"],vars["sMonth"],vars["sYear"]=csd.day,csd.month,csd.year
1548 vars["sHour"],vars["sMin"]=csd.hour,csd.minute
1549 if self._conf.getScreenStartDate() != self._conf.getStartDate():
1550 vars["start_date_own_sel"]=" checked"
1551 vars["start_date_conf_sel"]=""
1552 sd=self._conf.getAdjustedScreenStartDate()
1553 vars["sDay"]=quoteattr(str(sd.day))
1554 vars["sMonth"]=quoteattr(str(sd.month))
1555 vars["sYear"]=quoteattr(str(sd.year))
1556 vars["sHour"]=quoteattr(str(sd.hour))
1557 vars["sMin"]=quoteattr(str(sd.minute))
1558 vars["end_date_own_sel"]=""
1559 vars["end_date_conf_sel"]=" checked"
1560 vars["eDay"],vars["eMonth"],vars["eYear"]=ced.day,ced.month,ced.year
1561 vars["eHour"],vars["eMin"]=ced.hour,ced.minute
1562 if self._conf.getScreenEndDate() != self._conf.getEndDate():
1563 vars["end_date_own_sel"]=" checked"
1564 vars["end_date_conf_sel"]=""
1565 ed=self._conf.getAdjustedScreenEndDate()
1566 vars["eDay"]=quoteattr(str(ed.day))
1567 vars["eMonth"]=quoteattr(str(ed.month))
1568 vars["eYear"]=quoteattr(str(ed.year))
1569 vars["eHour"]=quoteattr(str(ed.hour))
1570 vars["eMin"]=quoteattr(str(ed.minute))
1571 return vars
1573 class WPScreenDatesEdit(WPConferenceModification):
1575 def _getPageContent( self, params ):
1576 wc = WConfModScreenDatesEdit(self._conf)
1577 return wc.getHTML()
1579 class WConferenceDataModificationAdditionalInfo(wcomponents.WTemplated):
1581 def __init__( self, conference ):
1582 self._conf = conference
1584 def getVars(self):
1585 vars = wcomponents.WTemplated.getVars( self )
1586 vars["contactInfo"] = self._conf.getContactInfo()
1587 return vars
1590 class WConferenceDataModification(wcomponents.WTemplated):
1592 def __init__( self, conference, rh ):
1593 self._conf = conference
1594 self._rh = rh
1596 def _getVisibilityHTML(self):
1597 visibility = self._conf.getVisibility()
1598 topcat = self._conf.getOwnerList()[0]
1599 level = 0
1600 selected = ""
1601 if visibility == 0:
1602 selected = "selected"
1603 vis = [ i18nformat("""<option value="0" %s> _("Nowhere")</option>""") % selected]
1604 while topcat:
1605 level += 1
1606 selected = ""
1607 if level == visibility:
1608 selected = "selected"
1609 if topcat.getId() != "0":
1610 from MaKaC.common.TemplateExec import truncateTitle
1611 vis.append("""<option value="%s" %s>%s</option>""" % (level, selected, truncateTitle(topcat.getName(), 120)))
1612 topcat = topcat.getOwner()
1613 selected = ""
1614 if visibility > level:
1615 selected = "selected"
1616 vis.append( i18nformat("""<option value="999" %s> _("Everywhere")</option>""") % selected)
1617 vis.reverse()
1618 return "".join(vis)
1620 def getVars(self):
1621 vars = wcomponents.WTemplated.getVars( self )
1622 minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
1624 navigator = ""
1625 styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
1626 type = self._conf.getType()
1627 vars["timezoneOptions"] = TimezoneRegistry.getShortSelectItemsHTML(self._conf.getTimezone())
1628 styles=styleMgr.getExistingStylesForEventType(type)
1629 styleoptions = ""
1630 defStyle = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getDefaultStyle()
1631 if defStyle not in styles:
1632 defStyle = ""
1633 for styleId in styles:
1634 if styleId == defStyle or (defStyle == "" and styleId == "static"):
1635 selected = "selected"
1636 else:
1637 selected = ""
1638 styleoptions += "<option value=\"%s\" %s>%s</option>" % (styleId,selected,styleMgr.getStyleName(styleId))
1639 vars["conference"] = self._conf
1640 vars["useRoomBookingModule"] = Config.getInstance().getIsRoomBookingActive()
1641 vars["styleOptions"] = styleoptions
1642 import MaKaC.webinterface.webFactoryRegistry as webFactoryRegistry
1643 wr = webFactoryRegistry.WebFactoryRegistry()
1644 types = [ "conference" ]
1645 for fact in wr.getFactoryList():
1646 types.append(fact.getId())
1647 vars["types"] = ""
1648 for id in types:
1649 typetext = id
1650 if typetext == "simple_event":
1651 typetext = "lecture"
1652 if self._conf.getType() == id:
1653 vars["types"] += "<option value=\"%s\" selected>%s" % (id,typetext)
1654 else:
1655 vars["types"] += "<option value=\"%s\">%s" % (id,typetext)
1656 vars["title"] = quoteattr( self._conf.getTitle() )
1657 vars["description"] = self._conf.getDescription()
1658 vars["keywords"] = self._conf.getKeywords()
1659 tz = self._conf.getTimezone()
1660 vars["sDay"] = str( self._conf.getAdjustedStartDate(tz).day )
1661 vars["sMonth"] = str( self._conf.getAdjustedStartDate(tz).month )
1662 vars["sYear"] = str( self._conf.getAdjustedStartDate(tz).year )
1663 vars["sHour"] = str( self._conf.getAdjustedStartDate(tz).hour )
1664 vars["sMinute"] = str( self._conf.getAdjustedStartDate(tz).minute )
1665 vars["eDay"] = str( self._conf.getAdjustedEndDate(tz).day )
1666 vars["eMonth"] = str( self._conf.getAdjustedEndDate(tz).month )
1667 vars["eYear"] = str( self._conf.getAdjustedEndDate(tz).year )
1668 vars["eHour"] = str( self._conf.getAdjustedEndDate(tz).hour )
1669 vars["eMinute"] = str( self._conf.getAdjustedEndDate(tz).minute )
1670 vars["chairText"] = quoteattr( self._conf.getChairmanText() )
1671 vars["orgText"] = quoteattr( self._conf.getOrgText() )
1672 vars["visibility"] = self._getVisibilityHTML()
1673 vars["shortURLTag"] = quoteattr( self._conf.getUrlTag() )
1674 locName, locAddress, locRoom = "", "", ""
1675 location = self._conf.getLocation()
1676 if location:
1677 locName = location.getName()
1678 locAddress = location.getAddress()
1679 room = self._conf.getRoom()
1680 if room:
1681 locRoom = room.getName()
1682 vars["locator"] = self._conf.getLocator().getWebForm()
1684 vars["locationAddress"] = locAddress
1686 vars["supportCaption"] = quoteattr(self._conf.getSupportInfo().getCaption())
1687 vars["supportEmail"] = quoteattr( self._conf.getSupportInfo().getEmail() )
1688 vars["locator"] = self._conf.getLocator().getWebForm()
1689 vars["event_type"] = ""
1690 vars["navigator"] = navigator
1691 eventType = self._conf.getType()
1692 if eventType == "conference":
1693 vars["additionalInfo"] = WConferenceDataModificationAdditionalInfo(self._conf).getHTML(vars)
1694 else:
1695 vars["additionalInfo"] = ""
1696 return vars
1699 class WPConfDataModif( WPConferenceModification ):
1701 def _getPageContent( self, params ):
1702 p = WConferenceDataModification( self._conf, self._rh )
1703 pars = {
1704 "postURL": urlHandlers.UHConfPerformDataModif.getURL(self._conf),
1705 "type": params.get("type")
1707 return p.getHTML( pars )
1710 class WConfModifScheduleGraphic(wcomponents.WTemplated):
1712 def __init__(self, conference, customLinks, **params):
1713 wcomponents.WTemplated.__init__(self, **params)
1714 self._conf = conference
1715 self._customLinks = customLinks
1717 def getVars( self ):
1718 vars=wcomponents.WTemplated.getVars(self)
1719 ################################
1720 # Fermi timezone awareness #
1721 ################################
1722 tz = self._conf.getTimezone()
1723 vars["timezone"]= tz
1724 vars["start_date"]=self._conf.getAdjustedStartDate().strftime("%a %d/%m")
1725 vars["end_date"]=self._conf.getAdjustedEndDate().strftime("%a %d/%m")
1726 #################################
1727 # Fermi timezone awareness(end) #
1728 #################################
1729 vars["editURL"]=quoteattr(str(urlHandlers.UHConfModScheduleDataEdit.getURL(self._conf)))
1731 vars['ttdata'] = schedule.ScheduleToJson.process(self._conf.getSchedule(), tz, None,
1732 days = None, mgmtMode = True)
1734 vars['customLinks'] = self._customLinks
1736 eventInfo = fossilize(self._conf, IConferenceEventInfoFossil, tz = tz)
1737 eventInfo['isCFAEnabled'] = self._conf.getAbstractMgr().isActive()
1738 vars['eventInfo'] = eventInfo
1740 return vars
1742 class WPConfModifScheduleGraphic( WPConferenceModifBase ):
1744 _userData = ['favorite-user-list', 'favorite-user-ids']
1746 def __init__(self, rh, conf):
1747 WPConferenceModifBase.__init__(self, rh, conf)
1748 self._contrib = None
1750 def _setActiveSideMenuItem( self ):
1751 self._timetableMenuItem.setActive()
1753 def getJSFiles(self):
1754 return WPConferenceModifBase.getJSFiles(self) + self._includeJSPackage('Timetable')
1756 def _getSchedule(self):
1757 custom_links = dict(values_from_signal(signals.event.timetable_buttons.send(self)))
1758 return WConfModifScheduleGraphic(self._conf, custom_links)
1760 def _getTTPage( self, params ):
1761 wc = self._getSchedule()
1762 return wc.getHTML(params)
1764 def _getPageContent(self, params):
1765 return self._getTTPage(params)
1767 #------------------------------------------------------------------------------
1768 class WPConfModifSchedule( WPConferenceModifBase ):
1770 def _setActiveTab( self ):
1771 self._tabSchedule.setActive()
1773 #------------------------------------------------------------------------------
1774 class WConfModScheduleDataEdit(wcomponents.WTemplated):
1776 def __init__(self,conf):
1777 self._conf=conf
1779 def getVars(self):
1780 vars=wcomponents.WTemplated.getVars(self)
1781 vars["postURL"]=quoteattr(str(urlHandlers.UHConfModScheduleDataEdit.getURL(self._conf)))
1782 #######################################
1783 # Fermi timezone awareness #
1784 #######################################
1785 csd = self._conf.getAdjustedStartDate()
1786 ced = self._conf.getAdjustedEndDate()
1787 #######################################
1788 # Fermi timezone awareness(end) #
1789 #######################################
1790 vars["sDay"],vars["sMonth"],vars["sYear"]=str(csd.day),str(csd.month),str(csd.year)
1791 vars["sHour"],vars["sMin"]=str(csd.hour),str(csd.minute)
1792 vars["eDay"],vars["eMonth"],vars["eYear"]=str(ced.day),str(ced.month),str(ced.year)
1793 vars["eHour"],vars["eMin"]=str(ced.hour),str(ced.minute)
1794 return vars
1796 class WPModScheduleDataEdit(WPConfModifSchedule):
1798 def _getPageContent( self, params ):
1799 wc = WConfModScheduleDataEdit(self._conf)
1800 return wc.getHTML()
1803 class WConfModifACSessionCoordinatorRights(wcomponents.WTemplated):
1805 def __init__(self,conf):
1806 self._conf = conf
1808 def getVars( self ):
1809 vars = wcomponents.WTemplated.getVars(self)
1810 url = urlHandlers.UHConfModifCoordinatorRights.getURL(self._conf)
1811 html=[]
1812 scr = conference.SessionCoordinatorRights()
1813 for rightKey in scr.getRightKeys():
1814 url = urlHandlers.UHConfModifCoordinatorRights.getURL(self._conf)
1815 url.addParam("rightId", rightKey)
1816 if self._conf.hasSessionCoordinatorRight(rightKey):
1817 imgurl=Config.getInstance().getSystemIconURL("tick")
1818 else:
1819 imgurl=Config.getInstance().getSystemIconURL("cross")
1820 html.append("""
1821 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=%s><img class="imglink" src=%s></a> %s
1822 """%(quoteattr(str(url)), quoteattr(str(imgurl)), scr.getRight(rightKey)))
1823 vars["optionalRights"]="<br>".join(html)
1824 return vars
1827 class WConfModifAC:
1829 def __init__(self, conference, eventType, user):
1830 self.__conf = conference
1831 self._eventType = eventType
1832 self.__user = user
1834 def getHTML( self, params ):
1835 ac = wcomponents.WConfAccessControlFrame().getHTML( self.__conf,\
1836 params["setVisibilityURL"])
1837 dc = ""
1838 if not self.__conf.isProtected():
1839 dc = "<br>%s"%wcomponents.WDomainControlFrame( self.__conf ).getHTML()
1841 mc = wcomponents.WConfModificationControlFrame().getHTML( self.__conf) + "<br>"
1843 if self._eventType == "conference":
1844 rc = wcomponents.WConfRegistrarsControlFrame().getHTML(self.__conf) + "<br>"
1845 else:
1846 rc = ""
1848 tf = ""
1849 if self._eventType in ["conference", "meeting"]:
1850 tf = "<br>%s" % wcomponents.WConfProtectionToolsFrame(self.__conf).getHTML()
1851 cr = ""
1852 if self._eventType == "conference":
1853 cr = "<br>%s" % WConfModifACSessionCoordinatorRights(self.__conf).getHTML()
1855 return """<br><table width="100%%" class="ACtab"><tr><td>%s%s%s%s%s%s<br></td></tr></table>""" % (mc, rc, ac, dc, tf, cr)
1858 class WPConfModifAC(WPConferenceModifBase):
1860 def __init__(self, rh, conf):
1861 WPConferenceModifBase.__init__(self, rh, conf)
1862 self._eventType = "conference"
1863 if self._rh.getWebFactory() is not None:
1864 self._eventType = self._rh.getWebFactory().getId()
1865 self._user = self._rh._getUser()
1867 def _setActiveSideMenuItem(self):
1868 self._ACMenuItem.setActive()
1870 def _getPageContent(self, params):
1871 wc = WConfModifAC(self._conf, self._eventType, self._user)
1872 p = {
1873 'setVisibilityURL': urlHandlers.UHConfSetVisibility.getURL(self._conf)
1875 return wc.getHTML(p)
1877 class WPConfModifToolsBase(WPConferenceModifBase):
1879 def _setActiveSideMenuItem(self):
1880 self._toolsMenuItem.setActive()
1882 def _createTabCtrl(self):
1883 self._tabCtrl = wcomponents.TabControl()
1885 self._tabReminders = self._tabCtrl.newTab('reminders', _("Reminders"),
1886 url_for('event_reminders.list', self._conf))
1887 self._tabCloneEvent = self._tabCtrl.newTab("clone", _("Clone Event"), \
1888 urlHandlers.UHConfClone.getURL(self._conf))
1889 self._tabPosters = self._tabCtrl.newTab("posters", _("Posters"), \
1890 urlHandlers.UHConfModifPosterPrinting.getURL(self._conf))
1891 self._tabBadges = self._tabCtrl.newTab("badges", _("Badges/Tablesigns"), \
1892 urlHandlers.UHConfModifBadgePrinting.getURL(self._conf))
1893 self._tabClose = self._tabCtrl.newTab("close", _("Lock"), \
1894 urlHandlers.UHConferenceClose.getURL(self._conf))
1895 self._tabDelete = self._tabCtrl.newTab("delete", _("Delete"), \
1896 urlHandlers.UHConfDeletion.getURL(self._conf))
1897 self._tabMatPackage = self._tabCtrl.newTab("matPackage", _("Material Package"),
1898 url_for('attachments.package_management', self._conf))
1900 if Config.getInstance().getOfflineStore():
1901 self._tabOffline = self._tabCtrl.newTab("offline", _("Offline copy"),
1902 url_for('static_site.list', self._conf))
1904 self._setActiveTab()
1906 wf = self._rh.getWebFactory()
1907 if wf:
1908 wf.customiseToolsTabCtrl(self._tabCtrl)
1910 def _getPageContent(self, params):
1911 self._createTabCtrl()
1913 html = wcomponents.WTabControl(self._tabCtrl, self._getAW()).getHTML(self._getTabContent(params))
1914 return html
1916 def _setActiveTab(self):
1917 pass
1919 def _getTabContent(self, params):
1920 return "nothing"
1923 class WPConfClosing(WPConfModifToolsBase):
1925 def __init__(self, rh, conf):
1926 WPConferenceModifBase.__init__(self, rh, conf)
1927 self._eventType = "conference"
1928 if self._rh.getWebFactory() is not None:
1929 self._eventType = self._rh.getWebFactory().getId()
1931 def _setActiveTab(self):
1932 self._tabClose.setActive()
1934 def _getTabContent(self, params):
1935 msg = {'challenge': _("Are you sure that you want to lock the event?"),
1936 'target': self._conf.getTitle(),
1937 'subtext': _("Note that if you lock the event, you will not be able to change its details any more. "
1938 "Only the creator of the event or an administrator of the system / category can unlock an event."),
1941 wc = wcomponents.WConfirmation()
1942 return wc.getHTML(msg,
1943 urlHandlers.UHConferenceClose.getURL(self._conf),
1945 severity="warning",
1946 confirmButtonCaption=_("Yes, lock this event"),
1947 cancelButtonCaption=_("No"))
1950 class WPConfDeletion(WPConfModifToolsBase):
1952 def _setActiveTab(self):
1953 self._tabDelete.setActive()
1955 def _getTabContent(self, params):
1956 msg = {'challenge': _("Are you sure that you want to delete the conference?"),
1957 'target': self._conf.getTitle(),
1958 'subtext': _("Note that if you delete the conference, all the items below it will also be deleted")
1961 wc = wcomponents.WConfirmation()
1962 return wc.getHTML(msg,
1963 urlHandlers.UHConfDeletion.getURL(self._conf),
1965 severity="danger",
1966 confirmButtonCaption=_("Yes, I am sure"),
1967 cancelButtonCaption=_("No"))
1970 class WPConfCloneConfirm(WPConfModifToolsBase):
1972 def __init__(self, rh, conf, nbClones):
1973 WPConfModifToolsBase.__init__(self, rh, conf)
1974 self._nbClones = nbClones
1976 def _setActiveTab(self):
1977 self._tabCloneEvent.setActive()
1979 def _getTabContent(self, params):
1981 msg = _("This action will create {0} new events. Are you sure you want to proceed").format(self._nbClones)
1983 wc = wcomponents.WConfirmation()
1984 url = urlHandlers.UHConfPerformCloning.getURL(self._conf)
1985 params = self._rh._getRequestParams()
1986 for key in params.keys():
1987 url.addParam(key, params[key])
1988 return wc.getHTML( msg, \
1989 url, {}, True, \
1990 confirmButtonCaption=_("Yes"), cancelButtonCaption=_("No"))
1992 #---------------------------------------------------------------------------
1995 class WPConferenceModifParticipantBase(WPConferenceModifBase):
1997 def __init__(self, rh, conf):
1998 WPConferenceModifBase.__init__(self, rh, conf)
2000 def _createTabCtrl(self):
2001 self._tabCtrl = wcomponents.TabControl()
2003 self._tabParticipantsSetup = self._tabCtrl.newTab("participantsetup", _("Setup"), urlHandlers.UHConfModifParticipantsSetup.getURL(self._conf))
2004 self._tabParticipantsList = self._tabCtrl.newTab("participantsList", _("Participants"), urlHandlers.UHConfModifParticipants.getURL(self._conf))
2005 self._tabStatistics = self._tabCtrl.newTab("statistics", _("Statistics"), urlHandlers.UHConfModifParticipantsStatistics.getURL(self._conf))
2006 if self._conf.getParticipation().getPendingParticipantList() and nowutc() < self._conf.getStartDate():
2007 self._tabParticipantsPendingList = self._tabCtrl.newTab("pendingList", _("Pending"), urlHandlers.UHConfModifParticipantsPending.getURL(self._conf), className="pendingTab")
2008 if self._conf.getParticipation().getDeclinedParticipantList():
2009 self._tabParticipantsDeclinedList = self._tabCtrl.newTab("declinedList", _("Declined"), urlHandlers.UHConfModifParticipantsDeclined.getURL(self._conf))
2011 self._setActiveTab()
2013 def _getPageContent(self, params):
2014 self._createTabCtrl()
2016 return wcomponents.WTabControl(self._tabCtrl, self._getAW()).getHTML(self._getTabContent(params))
2018 def getJSFiles(self):
2019 return WPConferenceModifBase.getJSFiles(self) + \
2020 self._includeJSPackage('Display')
2022 def _setActiveSideMenuItem(self):
2023 self._participantsMenuItem.setActive()
2025 def _getTabContent(self, params):
2026 return "nothing"
2028 def _setActiveTab(self):
2029 pass
2032 class WConferenceParticipant(wcomponents.WTemplated):
2034 def __init__(self, conference, participant):
2035 self._conf = conference
2036 self._participant = participant
2038 def getVars(self):
2039 vars = wcomponents.WTemplated.getVars(self)
2040 vars["conference"] = self._conf
2041 vars["participant"] = self._participant
2042 return vars
2045 class WConferenceParticipantPending(wcomponents.WTemplated):
2047 def __init__(self, conference, id, pending):
2048 self._conf = conference
2049 self._id = id
2050 self._pending = pending
2052 def getVars(self):
2053 vars = wcomponents.WTemplated.getVars(self)
2054 vars["conference"] = self._conf
2055 vars["id"] = self._id
2056 vars["pending"] = self._pending
2057 return vars
2060 class WConferenceParticipantsSetup(wcomponents.WTemplated):
2062 def __init__(self, conference):
2063 self._conf = conference
2065 def getVars(self):
2066 vars = wcomponents.WTemplated.getVars(self)
2067 vars["confId"] = self._conf.getId()
2068 vars["isObligatory"] = self._conf.getParticipation().isObligatory()
2069 vars["allowDisplay"] = self._conf.getParticipation().displayParticipantList()
2070 vars["addedInfo"] = self._conf.getParticipation().isAddedInfo()
2071 vars["allowForApply"] = self._conf.getParticipation().isAllowedForApplying()
2072 vars["autoAccept"] = self._conf.getParticipation().isAutoAccept()
2073 vars["numMaxParticipants"] = self._conf.getParticipation().getNumMaxParticipants()
2074 vars["notifyMgrNewParticipant"] = self._conf.getParticipation().isNotifyMgrNewParticipant()
2075 return vars
2078 class WPConfModifParticipantsSetup(WPConferenceModifParticipantBase):
2080 def _setActiveTab(self):
2081 self._tabParticipantsSetup.setActive()
2083 def _getTabContent(self, params):
2084 p = WConferenceParticipantsSetup(self._conf)
2085 return p.getHTML(params)
2088 class WConferenceParticipants(wcomponents.WTemplated):
2090 def __init__(self, conference):
2091 self._conf = conference
2093 def getVars(self):
2094 vars = wcomponents.WTemplated.getVars(self)
2096 vars["selectAll"] = Config.getInstance().getSystemIconURL("checkAll")
2097 vars["deselectAll"] = Config.getInstance().getSystemIconURL("uncheckAll")
2099 vars["participantsAction"] = str(urlHandlers.UHConfModifParticipantsAction.getURL(self._conf))
2100 vars["hasStarted"] = nowutc() < self._conf.getStartDate()
2101 vars["currentUser"] = self._rh._aw.getUser()
2102 vars["numberParticipants"] = len(self._conf.getParticipation().getParticipantList())
2103 vars["conf"] = self._conf
2104 vars["excelIconURL"] = quoteattr(str(Config.getInstance().getSystemIconURL("excel")))
2106 return vars
2109 class WPConfModifParticipants(WPConferenceModifParticipantBase):
2111 def _setActiveTab(self):
2112 self._tabParticipantsList.setActive()
2114 def _getTabContent(self, params):
2115 p = WConferenceParticipants(self._conf)
2116 return p.getHTML(params)
2119 class WConferenceParticipantsPending(wcomponents.WTemplated):
2121 def __init__(self, conference):
2122 self._conf = conference
2124 def getVars(self):
2125 vars = wcomponents.WTemplated.getVars(self)
2127 vars["selectAll"] = Config.getInstance().getSystemIconURL("checkAll")
2128 vars["deselectAll"] = Config.getInstance().getSystemIconURL("uncheckAll")
2129 vars["pending"] = self._getPendingParticipantsList()
2130 vars["numberPending"] = self._conf.getParticipation().getPendingNumber()
2131 vars["conf"] = self._conf
2132 vars["conferenceStarted"] = nowutc() > self._conf.getStartDate()
2133 vars["currentUser"] = self._rh._aw.getUser()
2135 return vars
2137 def _getPendingParticipantsList(self):
2138 l = []
2140 for k in self._conf.getParticipation().getPendingParticipantList().keys():
2141 p = self._conf.getParticipation().getPendingParticipantByKey(k)
2142 l.append((k, p))
2143 return l
2146 class WPConfModifParticipantsPending(WPConferenceModifParticipantBase):
2148 def _setActiveTab(self):
2149 self._tabParticipantsPendingList.setActive()
2151 def _getTabContent(self, params):
2152 p = WConferenceParticipantsPending(self._conf)
2153 return p.getHTML()
2156 class WConferenceParticipantsDeclined(wcomponents.WTemplated):
2158 def __init__(self, conference):
2159 self._conf = conference
2161 def getVars(self):
2163 vars = wcomponents.WTemplated.getVars(self)
2164 vars["declined"] = self._getDeclinedParticipantsList()
2165 vars["numberDeclined"] = self._conf.getParticipation().getDeclinedNumber()
2166 return vars
2168 def _getDeclinedParticipantsList(self):
2169 l = []
2171 for k in self._conf.getParticipation().getDeclinedParticipantList().keys():
2172 p = self._conf.getParticipation().getDeclinedParticipantByKey(k)
2173 l.append((k, p))
2174 return l
2177 class WPConfModifParticipantsDeclined(WPConferenceModifParticipantBase):
2179 def _setActiveTab(self):
2180 self._tabParticipantsDeclinedList.setActive()
2182 def _getTabContent(self, params):
2183 p = WConferenceParticipantsDeclined(self._conf)
2184 return p.getHTML()
2187 class WConferenceParticipantsStatistics(wcomponents.WTemplated):
2189 def __init__(self, conference):
2190 self._conf = conference
2192 def getVars(self):
2194 vars = wcomponents.WTemplated.getVars(self)
2195 vars["invited"] = self._conf.getParticipation().getInvitedNumber()
2196 vars["rejected"] = self._conf.getParticipation().getRejectedNumber()
2197 vars["added"] = self._conf.getParticipation().getAddedNumber()
2198 vars["refused"] = self._conf.getParticipation().getRefusedNumber()
2199 vars["pending"] = self._conf.getParticipation().getPendingNumber()
2200 vars["declined"] = self._conf.getParticipation().getDeclinedNumber()
2201 vars["conferenceStarted"] = nowutc() > self._conf.getStartDate()
2202 vars["present"] = self._conf.getParticipation().getPresentNumber()
2203 vars["absent"] = self._conf.getParticipation().getAbsentNumber()
2204 vars["excused"] = self._conf.getParticipation().getExcusedNumber()
2205 return vars
2208 class WPConfModifParticipantsStatistics(WPConferenceModifParticipantBase):
2210 def _setActiveTab(self):
2211 self._tabStatistics.setActive()
2213 def _getTabContent(self, params):
2214 p = WConferenceParticipantsStatistics(self._conf)
2215 return p.getHTML(params)
2218 class WPConfModifParticipantsInvitationBase(WPConferenceDisplayBase):
2220 def _getHeader(self):
2223 wc = wcomponents.WMenuSimpleEventHeader(self._getAW(), self._conf)
2224 return wc.getHTML({"loginURL": self.getLoginURL(),\
2225 "logoutURL": self.getLogoutURL(),\
2226 "confId": self._conf.getId(),\
2227 "currentView": "static",\
2228 "type": WebFactory.getId(),\
2229 "dark": True})
2231 def _getBody(self, params):
2232 return '<div style="margin:10px">{0}</div>'.format(self._getContent(params))
2235 class WPConfModifParticipantsInvite(WPConfModifParticipantsInvitationBase):
2237 def _getContent(self, params):
2238 msg = _("Please indicate whether you want to accept or reject the invitation to '{0}'").format(self._conf.getTitle())
2239 wc = wcomponents.WConfirmation()
2240 url = urlHandlers.UHConfParticipantsInvitation.getURL(self._conf)
2241 url.addParam("participantId",params["participantId"])
2242 return wc.getHTML(msg,
2243 url,
2245 confirmButtonCaption=_("Accept"),
2246 cancelButtonCaption=_("Reject"),
2247 severity="accept")
2249 #---------------------------------------------------------------------------
2251 class WPConfModifParticipantsRefuse(WPConfModifParticipantsInvitationBase):
2253 def _getContent( self, params ):
2254 msg = i18nformat("""
2255 <font size="+2"> _("Are you sure you want to refuse to attend the '%s'")?</font>
2256 """)%(self._conf.getTitle())
2257 wc = wcomponents.WConfirmation()
2258 url = urlHandlers.UHConfParticipantsRefusal.getURL( self._conf )
2259 url.addParam("participantId",params["participantId"])
2260 return wc.getHTML( msg, url, {}, \
2261 confirmButtonCaption= _("Refuse"), cancelButtonCaption= _("Cancel") )
2263 #---------------------------------------------------------------------------
2265 class WConfModifListings( wcomponents.WTemplated ):
2267 def __init__( self, conference ):
2268 self.__conf = conference
2270 def getVars( self ):
2271 vars = wcomponents.WTemplated.getVars( self )
2272 vars["pendingQueuesIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("listing")))
2273 vars["pendingQueuesURL"]=quoteattr(str(urlHandlers.UHConfModifPendingQueues.getURL( self.__conf )))
2274 vars["allSessionsConvenersIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("listing")))
2275 vars["allSessionsConvenersURL"]=quoteattr(str(urlHandlers.UHConfAllSessionsConveners.getURL( self.__conf )))
2276 vars["allSpeakersIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("listing")))
2277 vars["allSpeakersURL"]=quoteattr(str(urlHandlers.UHConfAllSpeakers.getURL( self.__conf )))
2278 return vars
2281 class WPConfModifListings(WPConferenceModifBase):
2283 def __init__(self, rh, conference):
2284 WPConferenceModifBase.__init__(self, rh, conference)
2285 self._createTabCtrl()
2287 def _setActiveSideMenuItem(self):
2288 self._listingsMenuItem.setActive()
2290 def _createTabCtrl(self):
2291 self._tabCtrl = wcomponents.TabControl()
2292 self._subTabSpeakers = self._tabCtrl.newTab('speakers',
2293 _('All Contribution Speakers'),
2294 urlHandlers.UHConfAllSpeakers.getURL(self._conf))
2295 self._subTabConveners = self._tabCtrl.newTab('conveners',
2296 _('All Session Conveners'),
2297 urlHandlers.UHConfAllSessionsConveners.getURL(self._conf))
2298 self._subTabUsers = self._tabCtrl.newTab('users',
2299 _('People Pending'),
2300 urlHandlers.UHConfModifPendingQueues.getURL(self._conf))
2302 def _getPageContent(self, params):
2303 self._setActiveTab()
2304 return wcomponents.WTabControl(self._tabCtrl, self._getAW()).getHTML(self._getTabContent(params))
2306 def _setActiveTab(self):
2307 self._subTabUsers.setActive()
2309 #---------------------------------------------------------------------------
2310 #---------------------------------------------------------------------------
2312 class WConferenceClone(wcomponents.WTemplated):
2314 def __init__(self, conference):
2315 self.__conf = conference
2317 def _getSelectDay(self):
2318 sd = ""
2319 for i in range(31) :
2320 selected = ""
2321 if datetime.today().day == (i+1) :
2322 selected = "selected=\"selected\""
2323 sd += "<OPTION VALUE=\"%d\" %s>%d\n"%(i+1, selected, i+1)
2324 return sd
2326 def _getSelectMonth(self):
2327 sm = ""
2328 month = [ "January", "February", "March", "April", "May", "June",
2329 "July", "August", "September", "October", "November", "December"]
2330 for i in range(12) :
2331 selected = ""
2332 if datetime.today().month == (i+1) :
2333 selected = "selected=\"selected\""
2334 sm += "\t<OPTION VALUE=\"%d\" %s>%s\n"%(i+1, selected, _(month[i]))
2335 return sm
2337 def _getSelectYear(self):
2338 sy = ""
2339 i = 1995
2340 while i < 2015 :
2341 selected = ""
2342 if datetime.today().year == i :
2343 selected = "selected=\"selected\""
2344 sy += "\t<OPTION VALUE=\"%d\" %s>%d\n"%(i, selected, i)
2345 i += 1
2346 return sy
2349 def getVars(self):
2350 vars = wcomponents.WTemplated.getVars(self)
2351 vars["confTitle"] = self.__conf.getTitle()
2352 vars["confId"] = self.__conf.getId()
2353 vars["selectDay"] = self._getSelectDay()
2354 vars["selectMonth"] = self._getSelectMonth()
2355 vars["selectYear"] = self._getSelectYear()
2356 return vars
2359 class WPConfClone(WPConfModifToolsBase):
2361 def _setActiveTab( self ):
2362 self._tabCloneEvent.setActive()
2364 def _getTabContent( self, params ):
2365 p = WConferenceClone( self._conf )
2366 pars = {"cancelURL": urlHandlers.UHConfModifTools.getURL(self._conf),
2367 "cloning": urlHandlers.UHConfPerformCloning.getURL(self._conf),
2368 "cloneOptions": i18nformat("""<li><input type="checkbox" name="cloneTracks" id="cloneTracks" value="1" />_("Tracks")</li>
2369 <li><input type="checkbox" name="cloneTimetable" id="cloneTimetable" value="1" />_("Full timetable")</li>
2370 <li><ul style="list-style-type: none;"><li><input type="checkbox" name="cloneSessions" id="cloneSessions" value="1" />_("Sessions")</li></ul></li>
2371 <li><input type="checkbox" name="cloneRegistration" id="cloneRegistration" value="1" >_("Registration")</li>
2372 <li><input type="checkbox" name="cloneEvaluation" id="cloneEvaluation" value="1" />_("Evaluation")</li>""") }
2373 pars['cloneOptions'] += EventCloner.get_plugin_items(self._conf)
2374 return p.getHTML(pars)
2377 class WConferenceAllSessionsConveners(wcomponents.WTemplated):
2379 def __init__(self, conference):
2380 self.__conf = conference
2382 def getVars(self):
2383 vars = wcomponents.WTemplated.getVars(self)
2384 vars["confTitle"] = self.__conf.getTitle()
2385 vars["confId"] = self.__conf.getId()
2386 vars["convenerSelectionAction"] = quoteattr(str(urlHandlers.UHConfAllSessionsConvenersAction.getURL(self.__conf)))
2387 vars["contribSetIndex"] = 'index'
2388 vars["convenerNumber"] = str(len(self.__conf.getAllSessionsConvenerList()))
2389 vars["conveners"] = self._getAllConveners()
2390 return vars
2392 def _getTimetableURL(self, convener):
2393 url = urlHandlers.UHSessionModifSchedule.getURL(self.__conf)
2394 url.addParam("sessionId", convener.getSession().getId())
2395 if hasattr(convener, "getSlot"):
2396 timetable = "#" + str(convener.getSlot().getStartDate().strftime("%Y%m%d")) + ".s%sl%s" % (convener.getSession().getId(), convener.getSlot().getId())
2397 else:
2398 timetable = "#" + str(convener.getSession().getStartDate().strftime("%Y%m%d"))
2400 return "%s%s" % (url, timetable)
2402 def _getAllConveners(self):
2403 convenersFormatted = []
2404 convenersDict = self.__conf.getAllSessionsConvenerList()
2406 for key, conveners in convenersDict.iteritems():
2407 data = None
2409 for convener in convenersDict[key]:
2411 if not data:
2412 data = {
2413 'email': convener.getEmail(),
2414 'name': convener.getFullName() or '',
2415 'sessions': []
2418 sessionData = {
2419 'title': '',
2420 'urlTimetable': self._getTimetableURL(convener),
2421 'urlSessionModif': None
2424 if isinstance(convener, conference.SlotChair):
2425 title = convener.getSlot().getTitle() or "Block %s" % convener.getSlot().getId()
2426 sessionData['title'] = convener.getSession().getTitle() + ': ' + title
2427 else:
2428 url = urlHandlers.UHSessionModification.getURL(self.__conf)
2429 url.addParam('sessionId', convener.getSession().getId())
2431 sessionData['urlSessionModif'] = str(url)
2432 sessionData['title'] = convener.getSession().getTitle() or ''
2434 data['sessions'].append(sessionData)
2436 convenersFormatted.append(data)
2438 return convenersFormatted
2441 class WPConfAllSessionsConveners(WPConfModifListings):
2443 def _setActiveTab(self):
2444 self._subTabConveners.setActive()
2446 def _getTabContent(self, params):
2447 p = WConferenceAllSessionsConveners(self._conf)
2448 return p.getHTML()
2450 #---------------------------------------------------------------------------------------
2453 class WConfModifAllContribParticipants(wcomponents.WTemplated):
2455 def __init__(self, conference, partIndex):
2456 self._title = _("All participants list")
2457 self._conf = conference
2458 self._order = ""
2459 self._dispopts = ["Email", "Contributions"]
2460 self._partIndex = partIndex
2462 def getVars(self):
2463 vars = wcomponents.WTemplated.getVars(self)
2464 self._url = vars["participantMainPageURL"]
2465 vars["speakers"] = self._getAllParticipants()
2466 vars["participantNumber"] = str(len(self._partIndex.getParticipationKeys()))
2468 return vars
2470 def _getAllParticipants(self):
2471 speakers = []
2473 for key in self._partIndex.getParticipationKeys():
2474 participationList = self._partIndex.getById(key)
2476 if participationList:
2477 participant = participationList[0]
2479 pData = {
2480 'name': participant.getFullName(),
2481 'email': participant.getEmail(),
2482 'contributions': []
2485 for participation in participationList:
2486 contribution = participation.getContribution()
2488 if contribution:
2489 pData['contributions'].append({
2490 'title': contribution.getTitle(),
2491 'url': str(urlHandlers.UHContributionModification.getURL(contribution))
2494 speakers.append(pData)
2496 return speakers
2498 def _getURL(self):
2499 return self._url
2502 class WPConfAllSpeakers(WPConfModifListings):
2504 def _setActiveTab(self):
2505 self._subTabSpeakers.setActive()
2507 def _getTabContent(self, params):
2508 p = WConfModifAllContribParticipants( self._conf, self._conf.getSpeakerIndex() )
2509 return p.getHTML({"title": _("All speakers list"), \
2510 "participantMainPageURL":urlHandlers.UHConfAllSpeakers.getURL(self._conf), \
2511 "participantSelectionAction":quoteattr(str(urlHandlers.UHConfAllSpeakersAction.getURL(self._conf)))})
2514 class WPEMailContribParticipants ( WPConfModifListings):
2515 def __init__(self, rh, conf, participantList):
2516 WPConfModifListings.__init__(self, rh, conf)
2517 self._participantList = participantList
2519 def _getPageContent(self,params):
2520 wc = WEmailToContribParticipants(self._conf, self._getAW().getUser(), self._participantList)
2521 return wc.getHTML()
2523 class WEmailToContribParticipants(wcomponents.WTemplated):
2524 def __init__(self,conf,user,contribParticipantList):
2525 self._conf = conf
2526 try:
2527 self._fromemail = user.getEmail()
2528 except:
2529 self._fromemail = ""
2530 self._contribParticipantList = contribParticipantList
2532 def getVars(self):
2533 vars = wcomponents.WTemplated.getVars( self )
2534 toEmails=[]
2535 toIds=[]
2536 for email in self._contribParticipantList:
2537 if len(email) > 0 :
2538 toEmails.append(email)
2539 vars["From"] = self._fromemail
2540 vars["toEmails"]= ", ".join(toEmails)
2541 vars["emails"]= ",".join(toEmails)
2542 vars["postURL"]=urlHandlers.UHContribParticipantsSendEmail.getURL(self._conf)
2543 vars["subject"]=""
2544 vars["body"]=""
2545 return vars
2546 #---------------------------------------------------------------------------------------
2548 class WPEMailConveners ( WPConfModifListings):
2549 def __init__(self, rh, conf, convenerList):
2550 WPConfModifListings.__init__(self, rh, conf)
2551 self._convenerList = convenerList
2553 def _getPageContent(self,params):
2554 wc = WEmailToConveners(self._conf, self._getAW().getUser(), self._convenerList)
2555 return wc.getHTML()
2557 class WEmailToConveners(wcomponents.WTemplated):
2558 def __init__(self,conf,user,convenerList):
2559 self._conf = conf
2560 try:
2561 self._fromemail = user.getEmail()
2562 except:
2563 self._fromemail = ""
2564 self._convenerList = convenerList
2566 def getVars(self):
2567 vars = wcomponents.WTemplated.getVars( self )
2568 toEmails=[]
2569 toIds=[]
2570 for email in self._convenerList:
2571 if len(email) > 0 :
2572 toEmails.append(email)
2573 vars["From"] = self._fromemail
2574 vars["toEmails"]= ", ".join(toEmails)
2575 vars["emails"]= ",".join(toEmails)
2576 vars["postURL"]=urlHandlers.UHConvenersSendEmail.getURL(self._conf)
2577 vars["subject"]=""
2578 vars["body"]=""
2579 return vars
2582 #---------------------------------------------------------------------------------------
2585 class WConvenerSentMail (wcomponents.WTemplated):
2586 def __init__(self,conf):
2587 self._conf = conf
2589 def getVars(self):
2590 vars = wcomponents.WTemplated.getVars( self )
2591 vars["BackURL"]=quoteattr(str(urlHandlers.UHConfAllSessionsConveners.getURL(self._conf)))
2592 return vars
2594 class WPConvenerSentEmail( WPConfModifListings ):
2595 def _getTabContent(self,params):
2596 wc = WConvenerSentMail(self._conf)
2597 return wc.getHTML()
2600 class WContribParticipationSentMail(wcomponents.WTemplated):
2601 def __init__(self,conf):
2602 self._conf = conf
2604 def getVars(self):
2605 vars = wcomponents.WTemplated.getVars( self )
2606 vars["BackURL"]=quoteattr(str(urlHandlers.UHConfAllSpeakers.getURL(self._conf)))
2607 return vars
2610 class WPContribParticipationSentEmail( WPConfModifListings ):
2611 def _getTabContent(self,params):
2612 wc = WContribParticipationSentMail(self._conf)
2613 return wc.getHTML()
2616 class WConfModifCFA(wcomponents.WTemplated):
2618 def __init__(self, conference):
2619 self._conf = conference
2621 def _getAbstractFieldsHTML(self, vars):
2622 abMgr = self._conf.getAbstractMgr()
2623 enabledText = _("Click to disable")
2624 disabledText = _("Click to enable")
2625 laf = []
2626 urlRemove = str(urlHandlers.UHConfModifCFARemoveOptFld.getURL(self._conf))
2627 laf.append("""<form action="" method="POST">""")
2628 for af in abMgr.getAbstractFieldsMgr().getFields():
2629 urlUp = urlHandlers.UHConfModifCFAAbsFieldUp.getURL(self._conf)
2630 urlUp.addParam("fieldId", af.getId())
2631 urlDown = urlHandlers.UHConfModifCFAAbsFieldDown.getURL(self._conf)
2632 urlDown.addParam("fieldId", af.getId())
2633 if af.isMandatory():
2634 mandatoryText = _("mandatory")
2635 else:
2636 mandatoryText = _("optional")
2637 maxCharText = ""
2638 if isinstance(af, AbstractTextField):
2639 maxCharText = " - "
2640 if int(af.getMaxLength()) != 0:
2641 maxCharText += _("max: %s %s.") % (af.getMaxLength(), af.getLimitation())
2642 else:
2643 maxCharText += _("not limited")
2644 addInfo = "(%s%s)" % (mandatoryText, maxCharText)
2645 url = urlHandlers.UHConfModifCFAOptFld.getURL(self._conf)
2646 url.addParam("fieldId", af.getId())
2647 url = quoteattr("%s#optional" % str(url))
2648 if self._conf.getAbstractMgr().hasEnabledAbstractField(af.getId()):
2649 icon = vars["enablePic"]
2650 textIcon = enabledText
2651 else:
2652 icon = vars["disablePic"]
2653 textIcon = disabledText
2654 if af.getId() == "content":
2655 removeButton = ""
2656 else:
2657 removeButton = "<input type=\"checkbox\" name=\"fieldId\" value=\"%s\">" % af.getId()
2658 laf.append("""
2659 <tr>
2660 <td>
2661 <a href=%s><img src=%s alt="%s" class="imglink"></a>&nbsp;<a href=%s><img src=%s border="0" alt=""></a><a href=%s><img src=%s border="0" alt=""></a>
2662 </td>
2663 <td width="1%%">%s</td>
2664 <td>
2665 &nbsp;<a class="edit-field" href="#" data-id=%s data-fieldType=%s>%s</a> %s
2666 </td>
2667 </tr>
2668 """ % (
2669 url,
2670 icon,
2671 textIcon,
2672 quoteattr(str(urlUp)),
2673 quoteattr(str(Config.getInstance().getSystemIconURL("upArrow"))),
2674 quoteattr(str(urlDown)),
2675 quoteattr(str(Config.getInstance().getSystemIconURL("downArrow"))),
2676 removeButton,
2677 af.getId(),
2678 af.getType(),
2679 af.getCaption(),
2680 addInfo))
2681 laf.append(i18nformat("""
2682 <tr>
2683 <td align="right" colspan="3">
2684 <input type="submit" value="_("remove")" onClick="this.form.action='%s';" class="btn">
2685 <input id="add-field-button" type="submit" value="_("add")" class="btn">
2686 </td>
2687 </tr>
2688 </form>""") % urlRemove)
2689 laf.append("</form>")
2690 return "".join(laf)
2692 def getVars(self):
2693 vars = wcomponents.WTemplated.getVars(self)
2694 abMgr = self._conf.getAbstractMgr()
2696 vars["iconDisabled"] = str(Config.getInstance().getSystemIconURL("disabledSection"))
2697 vars["iconEnabled"] = str(Config.getInstance().getSystemIconURL("enabledSection"))
2699 vars["multipleTracks"] = abMgr.getMultipleTracks()
2700 vars["areTracksMandatory"] = abMgr.areTracksMandatory()
2701 vars["canAttachFiles"] = abMgr.canAttachFiles()
2702 vars["showSelectAsSpeaker"] = abMgr.showSelectAsSpeaker()
2703 vars["isSelectSpeakerMandatory"] = abMgr.isSelectSpeakerMandatory()
2704 vars["showAttachedFilesContribList"] = abMgr.showAttachedFilesContribList()
2706 vars["multipleUrl"] = urlHandlers.UHConfCFASwitchMultipleTracks.getURL(self._conf)
2707 vars["mandatoryUrl"] = urlHandlers.UHConfCFAMakeTracksMandatory.getURL(self._conf)
2708 vars["attachUrl"] = urlHandlers.UHConfCFAAllowAttachFiles.getURL(self._conf)
2709 vars["showSpeakerUrl"] = urlHandlers.UHConfCFAShowSelectAsSpeaker.getURL(self._conf)
2710 vars["speakerMandatoryUrl"] = urlHandlers.UHConfCFASelectSpeakerMandatory.getURL(self._conf)
2711 vars["showAttachedFilesUrl"] = urlHandlers.UHConfCFAAttachedFilesContribList.getURL(self._conf)
2713 vars["setStatusURL"] = urlHandlers.UHConfCFAChangeStatus.getURL(self._conf)
2714 vars["dataModificationURL"] = urlHandlers.UHCFADataModification.getURL(self._conf)
2715 if abMgr.getCFAStatus():
2716 vars["changeTo"] = "False"
2717 vars["status"] = _("ENABLED")
2718 vars["changeStatus"] = _("DISABLE")
2719 vars["startDate"] = format_date(abMgr.getStartSubmissionDate(), format='full')
2720 vars["endDate"] = format_date(abMgr.getEndSubmissionDate(), format='full')
2721 vars["announcement"] = abMgr.getAnnouncement()
2722 vars["disabled"] = ""
2723 modifDL = abMgr.getModificationDeadline()
2724 vars["modifDL"] = i18nformat("""--_("not specified")--""")
2725 if modifDL:
2726 vars["modifDL"] = format_date(modifDL, format='full')
2727 vars["notification"] = i18nformat("""
2728 <table align="left">
2729 <tr>
2730 <td align="right"><b> _("To List"):</b></td>
2731 <td align="left">%s</td>
2732 </tr>
2733 <tr>
2734 <td align="right"><b> _("Cc List"):</b></td>
2735 <td align="left">%s</td>
2736 </tr>
2737 </table>
2738 """) % (", ".join(abMgr.getSubmissionNotification().getToList()) or i18nformat("""--_("no TO list")--"""), ", ".join(abMgr.getSubmissionNotification().getCCList()) or i18nformat("""--_("no CC list")--"""))
2739 else:
2740 vars["changeTo"] = "True"
2741 vars["status"] = _("DISABLED")
2742 vars["changeStatus"] = _("ENABLE")
2743 vars["startDate"] = ""
2744 vars["endDate"] = ""
2745 vars["announcement"] = ""
2746 vars["manage"] = ""
2747 vars["type"] = ""
2748 vars["disabled"] = "disabled"
2749 vars["modifDL"] = ""
2750 vars["submitters"] = ""
2751 vars["notification"] = ""
2752 vars["enablePic"] = quoteattr(str(Config.getInstance().getSystemIconURL("enabledSection")))
2753 vars["disablePic"] = quoteattr(str(Config.getInstance().getSystemIconURL("disabledSection")))
2754 vars["abstractFields"] = self._getAbstractFieldsHTML(vars)
2755 vars["addNotifTplURL"] = urlHandlers.UHAbstractModNotifTplNew.getURL(self._conf)
2756 vars["remNotifTplURL"] = urlHandlers.UHAbstractModNotifTplRem.getURL(self._conf)
2757 vars["confId"] = self._conf.getId()
2758 vars["lateAuthUsers"] = fossilize(self._conf.getAbstractMgr().getAuthorizedSubmitterList())
2759 return vars
2762 class WPConfModifCFAPreview(WPConferenceModifAbstractBase):
2764 def _setActiveTab(self):
2765 self._tabCFAPreview.setActive()
2767 def _getHeadContent(self):
2768 return WPConferenceModifAbstractBase._getHeadContent(self) + render('js/mathjax.config.js.tpl') + \
2769 '\n'.join(['<script src="{0}" type="text/javascript"></script>'.format(url)
2770 for url in self._asset_env['mathjax_js'].urls()])
2772 def getCSSFiles(self):
2773 return WPConferenceModifAbstractBase.getCSSFiles(self) + \
2774 self._asset_env['contributions_sass'].urls()
2776 def getJSFiles(self):
2777 return WPConferenceModifAbstractBase.getJSFiles(self) + \
2778 self._asset_env['abstracts_js'].urls()
2780 def _getTabContent(self, params):
2781 import MaKaC.webinterface.pages.abstracts as abstracts
2782 wc = abstracts.WAbstractDataModification(self._conf)
2783 # Simulate fake abstract
2784 from MaKaC.webinterface.common.abstractDataWrapper import AbstractData
2785 ad = AbstractData(self._conf.getAbstractMgr(), {}, 9999)
2786 params = ad.toDict()
2787 params["postURL"] = ""
2788 params["origin"] = "management"
2789 return wc.getHTML(params)
2792 class WPConfModifCFA(WPConferenceModifAbstractBase):
2794 def _setActiveTab(self):
2795 self._tabCFA.setActive()
2797 def _getTabContent(self, params):
2798 wc = WConfModifCFA(self._conf)
2799 return wc.getHTML()
2802 class WCFADataModification(wcomponents.WTemplated):
2804 def __init__(self, conf):
2805 self._conf = conf
2807 def getVars(self):
2808 vars = wcomponents.WTemplated.getVars(self)
2809 abMgr = self._conf.getAbstractMgr()
2810 vars["sDay"] = abMgr.getStartSubmissionDate().day
2811 vars["sMonth"] = abMgr.getStartSubmissionDate().month
2812 vars["sYear"] = abMgr.getStartSubmissionDate().year
2814 vars["eDay"] = abMgr.getEndSubmissionDate().day
2815 vars["eMonth"] = abMgr.getEndSubmissionDate().month
2816 vars["eYear"] = abMgr.getEndSubmissionDate().year
2818 vars["mDay"] = ""
2819 vars["mMonth"] = ""
2820 vars["mYear"] = ""
2821 if abMgr.getModificationDeadline():
2822 vars["mDay"] = str(abMgr.getModificationDeadline().day)
2823 vars["mMonth"] = str(abMgr.getModificationDeadline().month)
2824 vars["mYear"] = str(abMgr.getModificationDeadline().year)
2826 vars["announcement"] = abMgr.getAnnouncement()
2827 vars["toList"] = ", ".join(abMgr.getSubmissionNotification().getToList())
2828 vars["ccList"] = ", ".join(abMgr.getSubmissionNotification().getCCList())
2829 vars["postURL"] = urlHandlers.UHCFAPerformDataModification.getURL(self._conf)
2830 return vars
2833 class WPCFADataModification(WPConferenceModifAbstractBase):
2835 def _setActiveTab(self):
2836 self._tabCFA.setActive()
2838 def _getTabContent(self, params):
2839 p = WCFADataModification(self._conf)
2840 return p.getHTML()
2843 class WConfModifProgram(wcomponents.WTemplated):
2845 def __init__( self, conference ):
2846 self._conf = conference
2848 def getVars( self ):
2849 vars = wcomponents.WTemplated.getVars(self)
2850 vars["deleteItemsURL"]=urlHandlers.UHConfDelTracks.getURL(self._conf)
2851 vars["addTrackURL"]=urlHandlers.UHConfAddTrack.getURL( self._conf )
2852 vars["conf"] = self._conf
2853 return vars
2856 class WPConfModifProgram( WPConferenceModifBase ):
2858 def _setActiveSideMenuItem( self ):
2859 self._programMenuItem.setActive()
2861 def _getPageContent( self, params ):
2862 wc = WConfModifProgram( self._conf )
2863 return wc.getHTML()
2866 class WTrackCreation( wcomponents.WTemplated ):
2868 def __init__( self, targetConf ):
2869 self.__conf = targetConf
2871 def getVars( self ):
2872 vars = wcomponents.WTemplated.getVars(self)
2873 vars['title'] = ''
2874 vars['description'] = ''
2875 return vars
2879 class WPConfAddTrack( WPConfModifProgram ):
2881 def _setActiveSideMenuItem(self):
2882 self._programMenuItem.setActive()
2884 def _getPageContent( self, params ):
2885 p = WTrackCreation( self._conf )
2886 pars = {"postURL": urlHandlers.UHConfPerformAddTrack.getURL(self._conf)}
2887 return p.getHTML( pars )
2889 class WFilterCriteriaAbstracts(wcomponents.WFilterCriteria):
2891 Draws the options for a filter criteria object
2892 This means rendering the actual table that contains
2893 all the HTML for the several criteria
2896 def __init__(self, options, filterCrit, extraInfo=""):
2897 wcomponents.WFilterCriteria.__init__(self, options, filterCrit, extraInfo)
2899 def _drawFieldOptions(self, id, data):
2900 page = WFilterCriterionOptionsAbstracts(id, data)
2902 # TODO: remove when we have a better template system
2903 return page.getHTML()
2905 class WFilterCriterionOptionsAbstracts(wcomponents.WTemplated):
2907 def __init__(self, id, data):
2908 self._id = id
2909 self._data = data
2911 def getVars(self):
2913 vars = wcomponents.WTemplated.getVars( self )
2915 vars["id"] = self._id
2916 vars["title"] = self._data["title"]
2917 vars["options"] = self._data["options"]
2918 vars["selectFunc"] = self._data.get("selectFunc", True)
2920 return vars
2922 class WAbstracts( wcomponents.WTemplated ):
2924 # available columns
2925 COLUMNS = ["ID", "Title", "PrimaryAuthor", "Tracks", "Type", "Status", "Rating", "AccTrack", "AccType", "SubmissionDate", "ModificationDate"]
2927 def __init__( self, conference, filterCrit, sortingCrit, order, display, filterUsed):
2928 self._conf = conference
2929 self._filterCrit = filterCrit
2930 self._sortingCrit = sortingCrit
2931 self._order = order
2932 self._display = display
2933 self._filterUsed = filterUsed
2935 def _getURL( self, sortingField, column ):
2936 url = urlHandlers.UHConfAbstractManagment.getURL(self._conf)
2937 url.addParam("sortBy", column)
2938 if sortingField and sortingField.getId() == column:
2939 if self._order == "down":
2940 url.addParam("order","up")
2941 elif self._order == "up":
2942 url.addParam("order","down")
2943 return url
2946 def _getTrackFilterItemList( self ):
2947 checked = ""
2948 field=self._filterCrit.getField("track")
2949 if field is not None and field.getShowNoValue():
2950 checked = " checked"
2951 l = [ i18nformat("""<input type="checkbox" name="trackShowNoValue"%s> --_("not specified")--""")%checked]
2952 for t in self._conf.getTrackList():
2953 checked = ""
2954 if field is not None and t.getId() in field.getValues():
2955 checked = " checked"
2956 l.append( """<input type="checkbox" name="track" value=%s%s> (%s) %s\n"""%(quoteattr(t.getId()),checked,self.htmlText(t.getCode()),self.htmlText(t.getTitle())))
2957 return l
2959 def _getContribTypeFilterItemList( self ):
2960 checked = ""
2961 field=self._filterCrit.getField("type")
2962 if field is not None and field.getShowNoValue():
2963 checked = " checked"
2964 l = [ i18nformat("""<input type="checkbox" name="typeShowNoValue"%s> --_("not specified")--""")%checked]
2965 for contribType in self._conf.getContribTypeList():
2966 checked = ""
2967 if field is not None and contribType.getId() in field.getValues():
2968 checked = " checked"
2969 l.append( """<input type="checkbox" name="type" value=%s%s> %s"""%(quoteattr(contribType.getId()), checked, self.htmlText(contribType.getName())) )
2970 return l
2972 def _getAccTrackFilterItemList( self ):
2973 checked = ""
2974 field=self._filterCrit.getField("acc_track")
2975 if field is not None and field.getShowNoValue():
2976 checked = " checked"
2977 l = [ i18nformat("""<input type="checkbox" name="accTrackShowNoValue"%s> --_("not specified")--""")%checked]
2978 for t in self._conf.getTrackList():
2979 checked = ""
2980 if field is not None and t.getId() in field.getValues():
2981 checked=" checked"
2982 l.append("""<input type="checkbox" name="acc_track" value=%s%s> (%s) %s"""%(quoteattr(t.getId()),checked,self.htmlText(t.getCode()),self.htmlText(t.getTitle())))
2983 return l
2985 def _getAccContribTypeFilterItemList( self ):
2986 checked = ""
2987 field=self._filterCrit.getField("acc_type")
2988 if field is not None and field.getShowNoValue():
2989 checked = " checked"
2990 l = [ i18nformat("""<input type="checkbox" name="accTypeShowNoValue"%s> --_("not specified")--""")%checked]
2991 for contribType in self._conf.getContribTypeList():
2992 checked = ""
2993 if field is not None and contribType.getId() in field.getValues():
2994 checked = " checked"
2995 l.append( """<input type="checkbox" name="acc_type" value=%s%s> %s"""%(quoteattr(contribType.getId()),checked,self.htmlText(contribType.getName())))
2996 return l
2998 def _getStatusFilterItemList( self ):
2999 l = []
3000 for status in AbstractStatusList.getInstance().getStatusList():
3001 checked = ""
3002 statusId = AbstractStatusList.getInstance().getId( status )
3003 statusCaption = AbstractStatusList.getInstance().getCaption( status )
3004 statusCode=AbstractStatusList.getInstance().getCode(status)
3005 statusIconURL= AbstractStatusList.getInstance().getIconURL( status )
3006 field=self._filterCrit.getField("status")
3007 if field is not None and statusId in field.getValues():
3008 checked = "checked"
3009 imgHTML = """<img src=%s border="0" alt="">"""%(quoteattr(str(statusIconURL)))
3010 l.append( """<input type="checkbox" name="status" value=%s%s>%s (%s) %s"""%(quoteattr(statusId),checked,imgHTML,self.htmlText(statusCode),self.htmlText(statusCaption)))
3011 return l
3013 def _getOthersFilterItemList( self ):
3014 checkedShowMultiple, checkedShowComments = "", ""
3015 track_field=self._filterCrit.getField("track")
3016 if track_field is not None and track_field.onlyMultiple():
3017 checkedShowMultiple = " checked"
3018 if self._filterCrit.getField("comment") is not None:
3019 checkedShowComments = " checked"
3020 l = [ i18nformat("""<input type="checkbox" name="trackShowMultiple"%s> _("only multiple tracks")""")%checkedShowMultiple,
3021 i18nformat("""<input type="checkbox" name="comment"%s> _("only with comments")""")%checkedShowComments]
3022 return l
3024 def _getFilterMenu(self):
3026 options = [
3027 ('Tracks', {"title": _("tracks"),
3028 "options": self._getTrackFilterItemList()}),
3029 ('Types', {"title": _("types"),
3030 "options": self._getContribTypeFilterItemList()}),
3031 ('Status', {"title": _("status"),
3032 "options": self._getStatusFilterItemList()}),
3033 ('AccTracks', {"title": _("(proposed to be) accepted for tracks"),
3034 "options": self._getAccTrackFilterItemList()}),
3035 ('AccTypes', {"title": _("(proposed to be) accepted for types"),
3036 "options": self._getAccContribTypeFilterItemList()}),
3037 ('Others', {"title": _("others"),
3038 "selectFunc": False,
3039 "options": self._getOthersFilterItemList()})
3042 extraInfo = ""
3043 if self._conf.getRegistrationForm().getStatusesList():
3044 extraInfo = i18nformat("""<table align="center" cellspacing="10" width="100%%">
3045 <tr>
3046 <td colspan="5" class="titleCellFormat"> _("Author search") <input type="text" name="authSearch" value=%s></td>
3047 </tr>
3048 </table>
3049 """)%(quoteattr(str(self._authSearch)))
3051 p = WFilterCriteriaAbstracts(options, None, extraInfo)
3053 return p.getHTML()
3056 def _getColumnTitlesDict(self):
3058 Dictionary with the translation from "ids" to "name to display" for each of the options you can choose for the display.
3059 This method complements the method "_setDispOpts" in which we get a dictonary with "ids".
3061 if not hasattr(self, "_columns"):
3062 self._columns = {"ID": "ID","Title": "Title", "PrimaryAuthor": "Primary Author", "Tracks": "Tracks", "Type": "Type", "Status":"Status", \
3063 "Rating":" Rating", "AccTrack": "Acc. Track", "AccType": "Acc. Type", "SubmissionDate": "Submission Date", "ModificationDate": "Modification Date"}
3064 return self._columns
3066 def _getDisplay(self):
3068 These are the 'display' options selected by the user. In case no options were selected we add some of them by default.
3070 display = self._display[:]
3072 if display == []:
3073 display = self.COLUMNS
3074 return display
3076 def _getAccType(self, abstract):
3077 status = abstract.getCurrentStatus()
3078 if isinstance(status,(review.AbstractStatusAccepted, review.AbstractStatusProposedToAccept)) and status.getType() is not None:
3079 return self.htmlText(status.getType().getName())
3080 return ""
3082 def _getAccTrack(self, abstract):
3083 acc_track = abstract.getAcceptedTrack()
3084 if not acc_track:
3085 return ""
3086 return self.htmlText(acc_track.getCode())
3088 def getVars( self ):
3089 vars = wcomponents.WTemplated.getVars(self)
3090 vars["abstractSelectionAction"]=quoteattr(str(urlHandlers.UHAbstractConfSelectionAction.getURL(self._conf)))
3091 vars["confId"] = self._conf.getId()
3092 self._authSearch=vars.get("authSearch","")
3094 vars["filterMenu"] = self._getFilterMenu()
3096 sortingField=None
3097 if self._sortingCrit is not None:
3098 sortingField=self._sortingCrit.getField()
3100 vars["sortingField"] = sortingField.getId()
3101 vars["order"] = self._order
3102 vars["downArrow"] = Config.getInstance().getSystemIconURL("downArrow")
3103 vars["upArrow"] = Config.getInstance().getSystemIconURL("upArrow")
3104 vars["getSortingURL"] = lambda column: self._getURL(sortingField, column)
3105 vars["getAccType"] = lambda abstract: self._getAccType(abstract)
3106 vars["getAccTrack"] = lambda abstract: self._getAccTrack(abstract)
3108 f = filters.SimpleFilter( self._filterCrit, self._sortingCrit )
3109 abstractList=f.apply(self._conf.getAbstractMgr().getAbstractsMatchingAuth(self._authSearch))
3110 if self._order =="up":
3111 abstractList.reverse()
3112 vars["abstracts"] = abstractList
3114 vars["totalNumberAbstracts"] = str(len(self._conf.getAbstractMgr().getAbstractList()))
3115 vars["filteredNumberAbstracts"] = str(len(abstractList))
3116 vars["filterUsed"] = self._filterUsed
3117 vars["accessAbstract"] = quoteattr(str(urlHandlers.UHAbstractDirectAccess.getURL(self._conf)))
3119 url = urlHandlers.UHConfAbstractManagment.getURL(self._conf)
3120 url.setSegment( "results" )
3121 vars["filterPostURL"] = quoteattr(str(url))
3122 vars["excelIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("excel")))
3123 vars["pdfIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("pdf")))
3124 vars["xmlIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("xml")))
3125 vars["displayColumns"] = self._getDisplay()
3126 vars["columnsDict"] = self._getColumnTitlesDict()
3127 vars["columns"] = self.COLUMNS
3129 return vars
3131 class WPConfAbstractList( WPConferenceModifAbstractBase ):
3133 def __init__(self, rh, conf, msg, filterUsed = False ):
3134 self._msg = msg
3135 self._filterUsed = filterUsed
3136 WPConferenceModifAbstractBase.__init__(self, rh, conf)
3138 def _getTabContent( self, params ):
3139 order = params.get("order","down")
3140 wc = WAbstracts( self._conf, params.get("filterCrit", None ),
3141 params.get("sortingCrit", None),
3142 order,
3143 params.get("display",None),
3144 self._filterUsed )
3145 p = {"authSearch":params.get("authSearch","")}
3146 return wc.getHTML( p )
3148 def _setActiveTab(self):
3149 self._tabAbstractList.setActive()
3152 class WPModNewAbstract(WPConfAbstractList):
3154 def __init__(self, rh, conf, abstractData):
3155 WPConfAbstractList.__init__(self, rh, conf, "")
3157 def _getTabContent(self, params):
3158 from MaKaC.webinterface.pages.abstracts import WAbstractDataModification
3159 params["postURL"] = urlHandlers.UHConfModNewAbstract.getURL(self._conf)
3160 params["origin"] = "management"
3161 wc = WAbstractDataModification(self._conf)
3162 return wc.getHTML(params)
3164 def getCSSFiles(self):
3165 return WPConfAbstractList.getCSSFiles(self) + \
3166 self._asset_env['contributions_sass'].urls()
3168 def getJSFiles(self):
3169 return WPConfAbstractList.getJSFiles(self) + \
3170 self._includeJSPackage('Management') + \
3171 self._asset_env['abstracts_js'].urls()
3173 def _getHeadContent(self):
3174 return WPConfAbstractList._getHeadContent(self) + render('js/mathjax.config.js.tpl') + \
3175 '\n'.join(['<script src="{0}" type="text/javascript"></script>'.format(url)
3176 for url in self._asset_env['mathjax_js'].urls()])
3179 class WConfModAbstractsMerge(wcomponents.WTemplated):
3181 def __init__(self,conf):
3182 self._conf=conf
3184 def getVars(self):
3185 vars=wcomponents.WTemplated.getVars(self)
3186 vars["postURL"]=quoteattr(str(urlHandlers.UHConfModAbstractsMerge.getURL(self._conf)))
3187 vars["selAbstracts"]=",".join(vars.get("absIdList",[]))
3188 vars["targetAbs"]=quoteattr(str(vars.get("targetAbsId","")))
3189 vars["inclAuthChecked"]=""
3190 if vars.get("inclAuth",False):
3191 vars["inclAuthChecked"]=" checked"
3192 vars["comments"]=self.htmlText(vars.get("comments",""))
3193 vars["notifyChecked"]=""
3194 if vars.get("notify",False):
3195 vars["notifyChecked"]=" checked"
3196 return vars
3199 class WPModMergeAbstracts(WPConfAbstractList):
3201 def __init__(self, rh, conf):
3202 WPConfAbstractList.__init__(self, rh, conf, "")
3204 def _getTabContent(self, params):
3205 wc = WConfModAbstractsMerge(self._conf)
3206 p = {"absIdList": params.get("absIdList", []),
3207 "targetAbsId": params.get("targetAbsId", ""),
3208 "inclAuth": params.get("inclAuth", False),
3209 "comments": params.get("comments", ""),
3210 "notify": params.get("notify", True),
3212 return wc.getHTML(p)
3216 class WPConfModifDisplayBase( WPConferenceModifBase ):
3218 def _createTabCtrl( self ):
3220 self._tabCtrl = wcomponents.TabControl()
3222 self._tabDisplayCustomization = self._tabCtrl.newTab( "dispCustomization", _("Layout customization"), \
3223 urlHandlers.UHConfModifDisplayCustomization.getURL( self._conf ) )
3224 self._tabDisplayConfHeader = self._tabCtrl.newTab( "displConfHeader", _("Conference header"), \
3225 urlHandlers.UHConfModifDisplayConfHeader.getURL( self._conf ) )
3226 self._tabDisplayMenu = self._tabCtrl.newTab( "dispMenu", _("Menu"), \
3227 urlHandlers.UHConfModifDisplayMenu.getURL( self._conf ) )
3228 self._tabDisplayResources = self._tabCtrl.newTab( "dispResources", _("Images"), \
3229 urlHandlers.UHConfModifDisplayResources.getURL( self._conf ) )
3231 self._setActiveTab()
3233 def _getPageContent( self, params ):
3234 self._createTabCtrl()
3236 html = wcomponents.WTabControl( self._tabCtrl, self._getAW() ).getHTML( self._getTabContent( params ) )
3237 return html
3239 def _getTabContent( self ):
3240 return "nothing"
3242 def _setActiveSideMenuItem( self ):
3243 self._layoutMenuItem.setActive()
3245 class WPConfModifDisplayCustomization( WPConfModifDisplayBase ):
3247 def __init__(self, rh, conf):
3248 WPConfModifDisplayBase.__init__(self, rh, conf)
3250 def _getTabContent( self, params ):
3251 wc = WConfModifDisplayCustom( self._conf )
3252 return wc.getHTML()
3254 def _setActiveTab( self ):
3255 self._tabDisplayCustomization.setActive()
3257 class WConfModifDisplayCustom(wcomponents.WTemplated):
3259 def __init__(self, conf):
3260 self._conf = conf
3261 dm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf)
3262 self._format = dm.getFormat()
3264 def getVars(self):
3265 vars = wcomponents.WTemplated.getVars(self)
3266 vars["conf"]=self._conf
3267 vars["saveLogo"]=urlHandlers.UHSaveLogo.getURL(self._conf)
3268 vars["logoURL"]=""
3269 if self._conf.getLogo():
3270 vars["logoURL"] = urlHandlers.UHConferenceLogo.getURL(self._conf, _=int(time.time()))
3272 vars["formatTitleTextColor"] = WFormatColorOptionModif("titleTextColor", self._format, self._conf, 3).getHTML()
3273 vars["formatTitleBgColor"] = WFormatColorOptionModif("titleBgColor", self._format, self._conf, 4).getHTML()
3275 # Set up the logo of the conference
3276 vars["logoIconURL"] = Config.getInstance().getSystemIconURL("logo")
3277 if vars["logoURL"]:
3278 vars["logo"] = """<img heigth=\"95\" width=\"150\" src="%s" alt="%s" border="0">"""%(vars["logoURL"], self._conf.getTitle())
3279 vars["removeLogo"] = i18nformat("""<form action=%s method="POST"><input type="submit" class="btn" value="_("remove")"></form>""")%quoteattr(str(urlHandlers.UHRemoveLogo.getURL(self._conf)))
3280 else:
3281 vars["logo"] = "<em>No logo has been saved for this conference</em>"
3282 vars["removeLogo"] = ""
3285 #creating css part
3286 vars["saveCSS"]=urlHandlers.UHSaveCSS.getURL(self._conf)
3287 sm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getStyleManager()
3288 if sm.getLocalCSS():
3289 vars["cssDownload"] = sm.getCSS().getURL()
3290 else:
3291 vars["css"] = ""
3292 vars["cssDownload"] = ""
3293 vars["removeCSS"] = str(urlHandlers.UHRemoveCSS.getURL(self._conf))
3294 vars["previewURL"]= urlHandlers.UHConfModifPreviewCSS.getURL(self._conf)
3297 if sm.getCSS():
3298 vars["currentCSSFileName"] = sm.getCSS().getFileName()
3299 else:
3300 vars["currentCSSFileName"] = ""
3301 return vars
3303 class WPConfModifDisplayMenu( WPConfModifDisplayBase ):
3305 def __init__(self, rh, conf, linkId):
3306 WPConfModifDisplayBase.__init__(self, rh, conf)
3307 self._linkId = linkId
3309 def _getTabContent( self, params ):
3310 wc = WConfModifDisplayMenu( self._conf, self._linkId )
3311 return wc.getHTML()
3313 def _setActiveTab( self ):
3314 self._tabDisplayMenu.setActive()
3316 class WConfModifDisplayMenu(wcomponents.WTemplated):
3318 def __init__(self, conf, linkId):
3319 self._conf = conf
3320 dm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf)
3321 self._menu = dm.getMenu()
3322 self._link = self._menu.getLinkById(linkId)
3324 def getVars(self):
3325 vars = wcomponents.WTemplated.getVars(self)
3326 vars["addLinkURL"]=quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._conf)))
3327 vars["addPageURL"]=quoteattr(str(urlHandlers.UHConfModifDisplayAddPage.getURL(self._conf)))
3328 vars["addSpacerURL"]=quoteattr(str(urlHandlers.UHConfModifDisplayAddSpacer.getURL(self._conf)))
3329 vars["menuDisplay"] = ConfEditMenu(self._menu, urlHandlers.UHConfModifDisplayMenu.getURL).getHTML()
3330 vars["confId"] = self._conf.getId()
3331 if self._link:
3332 if isinstance(self._link, displayMgr.SystemLink):
3333 p = {
3334 "dataModificationURL": quoteattr(str(urlHandlers.UHConfModifDisplayModifySystemData.getURL(self._link))), \
3335 "moveUpURL": quoteattr(str(urlHandlers.UHConfModifDisplayUpLink.getURL(self._link))), \
3336 "imageUpURL": quoteattr(str(Config.getInstance().getSystemIconURL("upArrow"))), \
3337 "moveDownURL": quoteattr(str(urlHandlers.UHConfModifDisplayDownLink.getURL(self._link))), \
3338 "imageDownURL": quoteattr(str(Config.getInstance().getSystemIconURL("downArrow")))
3340 name = self._link.getName()
3341 if name == "timetable":
3342 vars["linkEdition"] = WTimetableModif(self._link).getHTML(p)
3343 else:
3344 vars["linkEdition"] = WSystemLinkModif(self._link).getHTML(p)
3345 elif isinstance(self._link, displayMgr.Spacer):
3346 p = {
3347 "removeLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayRemoveLink.getURL(self._link))), \
3348 "toggleLinkStatusURL": quoteattr(str(urlHandlers.UHConfModifDisplayToggleLinkStatus.getURL(self._link))), \
3349 "moveUpURL": quoteattr(str(urlHandlers.UHConfModifDisplayUpLink.getURL(self._link))), \
3350 "imageUpURL": quoteattr(str(Config.getInstance().getSystemIconURL("upArrow"))), \
3351 "moveDownURL": quoteattr(str(urlHandlers.UHConfModifDisplayDownLink.getURL(self._link))), \
3352 "imageDownURL": quoteattr(str(Config.getInstance().getSystemIconURL("downArrow")))
3354 vars["linkEdition"] = WSpacerModif(self._link).getHTML(p)
3355 elif isinstance(self._link, displayMgr.ExternLink):
3356 p = {
3357 "dataModificationURL": quoteattr(str(urlHandlers.UHConfModifDisplayModifyData.getURL(self._link))), \
3358 "removeLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayRemoveLink.getURL(self._link))), \
3359 "addSubLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._link))), \
3360 "toggleLinkStatusURL": quoteattr(str(urlHandlers.UHConfModifDisplayToggleLinkStatus.getURL(self._link))), \
3361 "moveUpURL": quoteattr(str(urlHandlers.UHConfModifDisplayUpLink.getURL(self._link))), \
3362 "imageUpURL": quoteattr(str(Config.getInstance().getSystemIconURL("upArrow"))), \
3363 "moveDownURL": quoteattr(str(urlHandlers.UHConfModifDisplayDownLink.getURL(self._link))), \
3364 "imageDownURL": quoteattr(str(Config.getInstance().getSystemIconURL("downArrow"))) }
3365 vars["linkEdition"] = WLinkModif(self._link).getHTML(p)
3366 else:
3367 p = {
3368 "dataModificationURL": quoteattr(str(urlHandlers.UHConfModifDisplayModifyData.getURL(self._link))), \
3369 "removeLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayRemoveLink.getURL(self._link))), \
3370 "toggleLinkStatusURL": quoteattr(str(urlHandlers.UHConfModifDisplayToggleLinkStatus.getURL(self._link))), \
3371 "toggleHomePageURL": quoteattr(str(urlHandlers.UHConfModifDisplayToggleHomePage.getURL(self._link))), \
3372 "moveUpURL": quoteattr(str(urlHandlers.UHConfModifDisplayUpLink.getURL(self._link))), \
3373 "imageUpURL": quoteattr(str(Config.getInstance().getSystemIconURL("upArrow"))), \
3374 "moveDownURL": quoteattr(str(urlHandlers.UHConfModifDisplayDownLink.getURL(self._link))), \
3375 "imageDownURL": quoteattr(str(Config.getInstance().getSystemIconURL("downArrow"))) }
3376 vars["linkEdition"] = WPageLinkModif(self._link).getHTML(p)
3377 else:
3378 vars["linkEdition"] = i18nformat("""<center><b> _("Click on an item of the menu to edit it")</b></center>""")
3380 return vars
3382 class WPConfModifDisplayResources( WPConfModifDisplayBase ):
3384 def __init__(self, rh, conf):
3385 WPConfModifDisplayBase.__init__(self, rh, conf)
3387 def _getTabContent( self, params ):
3388 wc = WConfModifDisplayResources( self._conf)
3389 return wc.getHTML()
3391 def _setActiveTab( self ):
3392 self._tabDisplayResources.setActive()
3394 class WConfModifDisplayResources(wcomponents.WTemplated):
3396 def __init__(self, conf):
3397 self._conf = conf
3399 def getVars(self):
3400 vars = wcomponents.WTemplated.getVars(self)
3401 vars["savePic"]=urlHandlers.UHSavePic.getURL(self._conf)
3402 #creating picture items for each saved picture
3403 vars["picsList"] = []
3404 im = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getImagesManager()
3405 for pic in im.getPicList().values():
3406 vars["picsList"].append({"id":pic.getId(),
3407 "picURL": str(urlHandlers.UHConferencePic.getURL(pic))})
3408 return vars
3410 class WPConfModifDisplayConfHeader( WPConfModifDisplayBase ):
3412 def __init__(self, rh, conf, optionalParams={}):
3413 WPConfModifDisplayBase.__init__(self, rh, conf)
3414 self._optionalParams=optionalParams
3416 def _getTabContent( self, params ):
3417 wc = WConfModifDisplayConfHeader( self._conf)
3418 return wc.getHTML(self._optionalParams)
3420 def _setActiveTab( self ):
3421 self._tabDisplayConfHeader.setActive()
3423 class WConfModifDisplayConfHeader(wcomponents.WTemplated):
3425 def __init__(self, conf):
3426 self._conf = conf
3427 dm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf)
3428 self._tickerTape=dm.getTickerTape()
3429 self._searchEnabled = dm.getSearchEnabled()
3431 def getVars(self):
3432 vars = wcomponents.WTemplated.getVars(self)
3434 #indico-style "checkboxes"
3435 vars["enablePic"]=quoteattr(str(Config.getInstance().getSystemIconURL( "enabledSection" )))
3436 vars["disablePic"]=quoteattr(str(Config.getInstance().getSystemIconURL( "disabledSection" )))
3437 enabledText = _("Click to disable")
3438 disabledText = _("Click to enable")
3440 # ------ Ticker Tape: ------
3441 # general
3442 vars["tickertapeURL"]=quoteattr(str(urlHandlers.UHTickerTapeAction.getURL(self._conf)))
3443 status= _("DISABLED")
3444 btnLabel= _("Enable")
3445 statusColor = "#612828"
3446 if self._tickerTape.isSimpleTextEnabled():
3447 statusColor = "#286135"
3448 status= _("ENABLED")
3449 btnLabel= _("Disable")
3450 vars["status"]= """<span style="color: %s;">%s</span>""" %(statusColor,status)
3451 vars["statusBtn"]=btnLabel
3452 # annoucements
3453 urlNP=urlHandlers.UHTickerTapeAction.getURL(self._conf)
3454 urlNP.addParam("nowHappening", "action")
3455 if self._tickerTape.isNowHappeningEnabled():
3456 vars["nowHappeningIcon"]=vars["enablePic"]
3457 vars["nowHappeningTextIcon"]=enabledText
3458 else:
3459 vars["nowHappeningIcon"]=vars["disablePic"]
3460 vars["nowHappeningTextIcon"]=disabledText
3461 vars["nowHappeningURL"]=quoteattr("%s#tickerTape"%str(urlNP))
3463 urlST=urlHandlers.UHTickerTapeAction.getURL(self._conf)
3464 urlST.addParam("simpleText", "action")
3465 vars["simpleTextURL"]=quoteattr("%s#tickerTape"%urlST)
3466 # simple ext
3467 vars["text"]=quoteattr(self._tickerTape.getText())
3468 if not vars.has_key("modifiedText"):
3469 vars["modifiedText"]=""
3470 else:
3471 vars["modifiedText"]= i18nformat("""<font color="green"> _("(text saved)")</font>""")
3473 #enable or disable the contribution search feature
3474 urlSB=urlHandlers.UHConfModifToggleSearch.getURL(self._conf)
3475 if self._searchEnabled:
3476 vars["searchBoxIcon"]=vars["enablePic"]
3477 vars["searchBoxTextIcon"]=enabledText
3478 else:
3479 vars["searchBoxIcon"]=vars["disablePic"]
3480 vars["searchBoxTextIcon"]=disabledText
3481 vars["searchBoxURL"]=quoteattr(str(urlSB))
3483 #enable or disable navigation icons
3484 vars["confType"] = self._conf.getType()
3485 urlSB=urlHandlers.UHConfModifToggleNavigationBar.getURL(self._conf)
3486 if displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getDisplayNavigationBar():
3487 vars["navigationBoxIcon"]=vars["enablePic"]
3488 vars["navigationBoxTextIcon"]=enabledText
3489 else:
3490 vars["navigationBoxIcon"]=vars["disablePic"]
3491 vars["navigationBoxTextIcon"]=disabledText
3492 vars["navigationBoxURL"]=quoteattr(str(urlSB))
3494 return vars
3496 class WFormatColorOptionModif(wcomponents.WTemplated):
3498 def __init__(self, formatOption, format, conf, formId=4):
3499 self._formatOption = formatOption
3500 self._format = format
3501 self._conf = conf
3503 # The form number on the page... used for the color picker
3504 self._formId = formId
3506 def getVars(self):
3507 vars = wcomponents.WTemplated.getVars(self)
3508 value = self._format.getFormatOption(self._formatOption)
3510 urlChangeColor = value["url"].getURL(self._conf)
3511 urlChangeColor.addParam("formatOption",self._formatOption)
3513 vars["changeColorURL"] = str(urlChangeColor)
3514 vars["colorCode"] = value["code"]
3515 vars["formatOption"] = self._formatOption
3517 return vars
3519 class ConfEditMenu:
3521 def __init__(self, menu, modifURLGen=None):
3522 self._menu = menu
3523 self._linkModifHandler = modifURLGen
3525 def getHTML(self):
3526 html = ["<table>"]
3527 for link in self._menu.getLinkList():
3528 html.append(self._getLinkHTML(link))
3529 html.append("</table>")
3530 return "".join(html)
3532 def _getLinkHTML(self, link, indent=""):
3533 if self._menu.linkHasToBeDisplayed(link):
3534 disabled = i18nformat("""<font size="-1" color="red"> _("(disabled)")</font>""")
3535 if link.isEnabled():
3536 disabled = ""
3537 if link.getType() == "spacer":
3538 html = """<tr><td></td><td nowrap><a href="%s">[%s]</a>%s</td></tr>\n"""%(self._linkModifHandler(link), link.getName(), disabled)
3539 else:
3540 system = "<font size=-1>E </font>"
3541 home = ""
3542 if isinstance(link, displayMgr.SystemLink):
3543 system = "<font size=-1 color=\"green\">S </font>"
3544 if isinstance(link, displayMgr.PageLink):
3545 if link.getPage().isHome():
3546 home = "&nbsp;<font size=-1 color=\"green\">(home)</font>"
3547 system = "<font size=-1 color=\"black\">P </font>"
3548 html = ["""<tr><td>%s</td><td nowrap>%s<a href="%s">%s</a>%s%s</td></tr>\n"""%(system, indent, self._linkModifHandler(link), escape(link.getCaption()), disabled, home)]
3549 for l in link.getLinkList():
3550 html.append( self._getLinkHTML(l, "%s%s"%(indent ,self._menu.getIndent())))
3551 return "".join(html)
3552 return ""
3555 class WLinkModif(wcomponents.WTemplated):
3556 def __init__(self, link):
3557 self._link = link
3559 def getVars(self):
3560 vars = wcomponents.WTemplated.getVars(self)
3562 vars["linkName"] = self._link.getCaption()
3563 vars["linkURL"] = self._link.getURL()
3564 vars["displayTarget"] = _("Display in the SAME window")
3565 if self._link.getDisplayTarget() == "_blank":
3566 vars["displayTarget"] = _("Display in a NEW window")
3567 if self._link.isEnabled():
3568 vars["linkStatus"] = _("Activated")
3569 vars["changeStatusTo"] = _("Disable")
3570 else:
3571 vars["linkStatus"] = _("Disabled")
3572 vars["changeStatusTo"] = _("Activate")
3574 return vars
3576 class WPageLinkModif(wcomponents.WTemplated):
3578 def __init__(self, link):
3579 self._link = link
3581 def getVars(self):
3582 vars = wcomponents.WTemplated.getVars(self)
3584 vars["linkName"] = self._link.getCaption()
3585 vars["linkContent"] = self.htmlText("%s..."%self._link.getPage().getContent()[0:50])
3586 vars["displayTarget"] = _("Display in the SAME window")
3587 if self._link.getDisplayTarget() == "_blank":
3588 vars["displayTarget"] = _("Display in a NEW window")
3589 if self._link.isEnabled():
3590 vars["linkStatus"] = _("Activated")
3591 vars["changeStatusTo"] = _("Disable")
3592 else:
3593 vars["linkStatus"] = _("Disabled")
3594 vars["changeStatusTo"] = _("Activate")
3595 if self._link.getPage().isHome():
3596 vars["homeText"] = _("Default conference home page")
3597 vars["changeHomeTo"] = _("Normal page")
3598 else:
3599 vars["homeText"] = _("Normal page")
3600 vars["changeHomeTo"] = _("Default conference home page")
3601 return vars
3603 class WSystemLinkModif(wcomponents.WTemplated):
3605 def __init__(self, link):
3606 self._link = link
3608 def getVars(self):
3609 vars = wcomponents.WTemplated.getVars(self)
3610 vars["linkName"] = self._link.getCaption()
3611 vars["linkStatus"] = _("Disabled")
3612 vars["changeStatusTo"] = _("Activate")
3613 if self._link.isEnabled():
3614 vars["linkStatus"] = _("Activated")
3615 vars["changeStatusTo"] = _("Disable")
3616 url=urlHandlers.UHConfModifDisplayToggleLinkStatus.getURL(self._link)
3617 vars["toggleLinkStatusURL"]=quoteattr(str(url))
3618 return vars
3620 class WTimetableModif(WSystemLinkModif):
3622 def getVars(self):
3623 wvars = WSystemLinkModif.getVars(self)
3624 # Timetable detailed view
3625 wvars["viewMode"] = _("Generic")
3626 wvars["changeViewModeTo"] = _("Detailed")
3627 if self._link.getMenu().is_timetable_detailed_view():
3628 wvars["viewMode"] = _("Detailed")
3629 wvars["changeViewModeTo"] = _("Generic")
3630 wvars["toggleTimetableViewURL"] = str(urlHandlers.UHConfModifDisplayToggleTimetableView.getURL(self._link))
3631 # Timeable Layout
3632 wvars["defaultTTLayout"] = _("Normal")
3633 wvars["changedefaultTTLayoutTo"] = _("By room")
3634 if self._link.getMenu().get_timetable_layout() == 'room':
3635 wvars["defaultTTLayout"] = _("By room")
3636 wvars["changedefaultTTLayoutTo"] = _("Normal")
3637 wvars["toggleTTDefaultLayoutURL"] = str(urlHandlers.UHConfModifDisplayToggleTTDefaultLayout.getURL(self._link))
3638 return wvars
3641 class WSpacerModif(wcomponents.WTemplated):
3642 def __init__(self, link):
3643 self._link = link
3645 def getVars(self):
3646 vars = wcomponents.WTemplated.getVars(self)
3647 vars["linkName"] = self._link.getName()
3648 if self._link.isEnabled():
3649 vars["linkStatus"] = _("Activated")
3650 vars["changeStatusTo"] = _("Disable")
3651 else:
3652 vars["linkStatus"] = _("Disabled")
3653 vars["changeStatusTo"] = _("Activate")
3654 return vars
3656 class WPConfModifDisplayAddPage( WPConfModifDisplayBase ):
3658 def __init__(self, rh, conf, linkId):
3659 WPConfModifDisplayBase.__init__(self, rh, conf)
3660 self._linkId = linkId
3661 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3662 if linkId:
3663 self._link = self._menu.getLinkById(linkId)
3664 else:
3665 self._link = self._menu
3667 def _setActiveTab( self ):
3668 self._tabDisplayMenu.setActive()
3670 def _getTabContent( self, params ):
3671 return WConfModifDisplayAddPage( self._conf, self._linkId ).getHTML()
3674 class WConfModifDisplayAddPage(wcomponents.WTemplated):
3676 def __init__(self, conf, linkId):
3677 self._conf = conf
3678 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3679 if linkId:
3680 self._link = self._menu.getLinkById(linkId)
3681 else:
3682 self._link = self._menu
3684 def getVars(self):
3685 vars = wcomponents.WTemplated.getVars(self)
3686 vars["saveLinkURL"] = quoteattr(str(urlHandlers.UHConfModifDisplayAddPage.getURL(self._link)))
3687 vars["content"]=""
3688 return vars
3690 class WPConfModifDisplayAddLink( WPConfModifDisplayBase ):
3691 def __init__(self, rh, conf, linkId):
3692 WPConfModifDisplayBase.__init__(self, rh, conf)
3693 self._linkId = linkId
3694 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3695 if linkId:
3696 self._link = self._menu.getLinkById(linkId)
3697 else:
3698 self._link = self._menu
3700 def _setActiveTab( self ):
3701 self._tabDisplayMenu.setActive()
3703 def _getTabContent( self, params ):
3704 wc = WConfModifDisplayAddLink( self._conf, self._linkId )
3705 p = {"addLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._conf))), \
3706 "addPageURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddPage.getURL(self._conf))), \
3707 "addSpacerURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddSpacer.getURL(self._conf))) }
3708 return wc.getHTML( p )
3711 class WConfModifDisplayAddLink(wcomponents.WTemplated):
3713 def __init__(self, conf, linkId):
3714 self._conf = conf
3715 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3716 if linkId:
3717 self._link = self._menu.getLinkById(linkId)
3718 else:
3719 self._link = self._menu
3721 def getVars(self):
3722 vars = wcomponents.WTemplated.getVars(self)
3723 vars["menuDisplay"] = ConfEditMenu(self._menu, urlHandlers.UHConfModifDisplay.getURL).getHTML()
3724 vars["saveLinkURL"] = quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._link)))
3725 return vars
3728 class WPConfModifDisplayModifyData( WPConfModifDisplayBase ):
3729 def __init__(self, rh, conf, link):
3730 WPConfModifDisplayBase.__init__(self, rh, conf)
3731 self._link = link
3732 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3734 def _setActiveTab( self ):
3735 self._tabDisplayMenu.setActive()
3737 def _getTabContent( self, params ):
3738 wc = WConfModifDisplayModifyData( self._conf, self._link )
3739 p = {
3740 "modifyDataURL": quoteattr(str(urlHandlers.UHConfModifDisplayModifyData.getURL(self._link))), \
3741 "addLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._conf))), \
3742 "addPageURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddPage.getURL(self._conf))), \
3743 "addSpacerURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddSpacer.getURL(self._conf))) }
3744 return wc.getHTML( p )
3746 class WConfModifDisplayModifyData(wcomponents.WTemplated):
3748 def __init__(self, conf, link):
3749 self._conf = conf
3750 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3751 self._link = link
3754 def getVars(self):
3755 vars = wcomponents.WTemplated.getVars(self)
3756 vars["menuDisplay"] = ConfEditMenu(self._menu, urlHandlers.UHConfModifDisplay.getURL).getHTML()
3757 vars["saveLinkURL"] = quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._link)))
3758 vars["name"] = self._link.getCaption()
3759 vars["value_name"] = quoteattr(self._link.getCaption())
3760 vars["url"] = self._link.getURL()
3761 if self._link.getDisplayTarget() == "_blank":
3762 vars["newChecked"] = _("""CHECKED""")
3763 vars["sameChecked"] = ""
3764 else:
3765 vars["newChecked"] = ""
3766 vars["sameChecked"] = _("""CHECKED""")
3768 return vars
3772 class WPConfModifDisplayModifyPage( WPConfModifDisplayBase ):
3773 def __init__(self, rh, conf, link):
3774 WPConfModifDisplayBase.__init__(self, rh, conf)
3775 self._link = link
3776 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3778 def _setActiveTab( self ):
3779 self._tabDisplayMenu.setActive()
3781 def _getTabContent( self, params ):
3782 wc = WConfModifDisplayModifyPage( self._conf, self._link )
3783 p = {
3784 "modifyDataURL": quoteattr(str(urlHandlers.UHConfModifDisplayModifyData.getURL(self._link))) }
3785 return wc.getHTML( p )
3787 class WConfModifDisplayModifyPage(wcomponents.WTemplated):
3789 def __init__(self, conf, link):
3790 self._conf = conf
3791 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3792 self._link = link
3795 def getVars(self):
3796 vars = wcomponents.WTemplated.getVars(self)
3797 vars["saveLinkURL"] = quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._link)))
3798 vars["name"] = self._link.getCaption()
3799 vars["value_name"] = quoteattr(self._link.getCaption())
3800 vars["content"] = self._link.getPage().getContent().replace('"','\\"').replace("'","\\'").replace('\r\n','\\n').replace('\n','\\n')
3801 if self._link.getDisplayTarget() == "_blank":
3802 vars["newChecked"] = _("""CHECKED""")
3803 vars["sameChecked"] = ""
3804 else:
3805 vars["newChecked"] = ""
3806 vars["sameChecked"] = _("""CHECKED""")
3807 return vars
3809 class WPConfModifDisplayModifySystemData( WPConfModifDisplayBase ):
3810 def __init__(self, rh, conf, link):
3811 WPConfModifDisplayBase.__init__(self, rh, conf)
3812 self._link = link
3813 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3815 def _setActiveTab( self ):
3816 self._tabDisplayMenu.setActive()
3818 def _getTabContent( self, params ):
3819 wc = WConfModifDisplayModifySystemData( self._conf, self._link )
3820 p = {
3821 "modifyDataURL": quoteattr(str(urlHandlers.UHConfModifDisplayModifySystemData.getURL(self._link))), \
3822 "addLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._conf))), \
3823 "addPageURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddPage.getURL(self._conf))), \
3824 "addSpacerURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddSpacer.getURL(self._conf))) }
3825 return wc.getHTML( p )
3827 class WConfModifDisplayModifySystemData(wcomponents.WTemplated):
3829 def __init__(self, conf, link):
3830 self._conf = conf
3831 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3832 self._link = link
3835 def getVars(self):
3836 vars = wcomponents.WTemplated.getVars(self)
3837 vars["menuDisplay"] = ConfEditMenu(self._menu, urlHandlers.UHConfModifDisplay.getURL).getHTML()
3838 vars["saveLinkURL"] = quoteattr(str(urlHandlers.UHConfModifDisplayModifySystemData.getURL(self._link)))
3839 vars["name"] = self._link.getCaption()
3840 vars["value_name"] = quoteattr(self._link.getCaption())
3841 return vars
3844 class WPConfModifDisplayRemoveLink( WPConfModifDisplayBase ):
3845 def __init__(self, rh, conf, link):
3846 WPConfModifDisplayBase.__init__(self, rh, conf)
3847 self._link = link
3849 def _setActiveTab( self ):
3850 self._tabDisplayMenu.setActive()
3852 def _getTabContent( self, params ):
3854 msg = {
3855 'challenge': _("Are you sure that you want to delete this link?"),
3856 'target': self._link.getName()
3859 postURL = quoteattr(str(urlHandlers.UHConfModifDisplayRemoveLink.getURL(self._link)))
3860 return wcomponents.WConfirmation().getHTML( msg, postURL, {})
3863 class WPConfParticipantList( WPConfAbstractList ):
3865 def __init__(self, rh, conf, emailList, displayedGroups, abstracts):
3866 WPConfAbstractList.__init__(self, rh, conf, None)
3867 self._emailList = emailList
3868 self._displayedGroups = displayedGroups
3869 self._abstracts = abstracts
3871 def _getTabContent( self, params ):
3872 wc = WAbstractsParticipantList(self._conf, self._emailList, self._displayedGroups, self._abstracts)
3873 return wc.getHTML()
3875 class WPConfModifParticipantList( WPConferenceBase ):
3877 def __init__(self, rh, conf, emailList, displayedGroups, contribs):
3878 WPConferenceBase.__init__(self, rh, conf)
3879 self._emailList = emailList
3880 self._displayedGroups = displayedGroups
3881 self._contribs = contribs
3883 def _getBody( self, params ):
3884 WPConferenceBase._getBody(self, params)
3885 wc = WContribParticipantList(self._conf, self._emailList, self._displayedGroups, self._contribs)
3886 params = {"urlDisplayGroup":urlHandlers.UHContribsConfManagerDisplayParticipantList.getURL(self._conf)}
3887 return wc.getHTML(params)
3890 class WConfModifContribList(wcomponents.WTemplated):
3892 def __init__(self,conf,filterCrit, sortingCrit, order, filterUsed=False, filterUrl=None):
3893 self._conf=conf
3894 self._filterCrit=filterCrit
3895 self._sortingCrit=sortingCrit
3896 self._order = order
3897 self._totaldur =timedelta(0)
3898 self._filterUsed = filterUsed
3899 self._filterUrl = filterUrl
3902 def _getURL( self ):
3903 #builds the URL to the contribution list page
3904 # preserving the current filter and sorting status
3905 url = urlHandlers.UHConfModifContribList.getURL(self._conf)
3907 #save params in websession
3908 dict = session.setdefault('ContributionFilterConf%s' % self._conf.getId(), {})
3909 if self._filterCrit.getField("type"):
3910 l=[]
3911 for t in self._filterCrit.getField("type").getValues():
3912 if t!="":
3913 l.append(t)
3914 dict["types"] = l
3915 if self._filterCrit.getField("type").getShowNoValue():
3916 dict["typeShowNoValue"] = "1"
3918 if self._filterCrit.getField("track"):
3919 dict["tracks"] = self._filterCrit.getField("track").getValues()
3920 if self._filterCrit.getField("track").getShowNoValue():
3921 dict["trackShowNoValue"] = "1"
3923 if self._filterCrit.getField("session"):
3924 dict["sessions"] = self._filterCrit.getField("session").getValues()
3925 if self._filterCrit.getField("session").getShowNoValue():
3926 dict["sessionShowNoValue"] = "1"
3928 if self._filterCrit.getField("status"):
3929 dict["status"] = self._filterCrit.getField("status").getValues()
3931 if self._sortingCrit.getField():
3932 dict["sortBy"] = self._sortingCrit.getField().getId()
3933 dict["order"] = "down"
3934 dict["OK"] = "1"
3935 session.modified = True
3937 return url
3939 def _getMaterialsHTML(self, contrib):
3940 attached_items = contrib.attached_items
3941 if attached_items:
3942 num_files = len(attached_items['files']) + sum(len(f.attachments) for f in attached_items['folders'])
3943 return '<a href="{}">{}</a>'.format(
3944 url_for('attachments.management', contrib),
3945 ngettext('1 file', '{num} files', num_files).format(num=num_files)
3948 def _getContribHTML( self, contrib ):
3949 try:
3950 sdate=contrib.getAdjustedStartDate().strftime("%d-%b-%Y %H:%M" )
3951 except AttributeError:
3952 sdate = ""
3953 title = """<a href=%s>%s</a>"""%( quoteattr( str( urlHandlers.UHContributionModification.getURL( contrib ) ) ), self.htmlText( contrib.getTitle() ))
3954 strdur = ""
3955 if contrib.getDuration() is not None and contrib.getDuration().seconds != 0:
3956 strdur = (datetime(1900,1,1)+ contrib.getDuration()).strftime("%Hh%M'")
3957 dur = contrib.getDuration()
3958 self._totaldur = self._totaldur + dur
3960 l = [self.htmlText( spk.getFullName() ) for spk in contrib.getSpeakerList()]
3961 speaker = "<br>".join( l )
3962 session = ""
3963 if contrib.getSession() is not None:
3964 if contrib.getSession().getCode() != "no code":
3965 session=self.htmlText(contrib.getSession().getCode())
3966 else:
3967 session=self.htmlText(contrib.getSession().getId())
3968 track = ""
3969 if contrib.getTrack() is not None:
3970 if contrib.getTrack().getCode() is not None:
3971 track = self.htmlText( contrib.getTrack().getCode() )
3972 else:
3973 track = self.htmlText( contrib.getTrack().getId() )
3974 cType=""
3975 if contrib.getType() is not None:
3976 cType=self.htmlText(contrib.getType().getName())
3977 status=contrib.getCurrentStatus()
3978 statusCaption=ContribStatusList().getCode(status.__class__)
3979 html = """
3980 <tr id="contributions%s" style="background-color: transparent;" onmouseout="javascript:onMouseOut('contributions%s')" onmouseover="javascript:onMouseOver('contributions%s')">
3981 <td valign="top" align="right" nowrap><input onchange="javascript:isSelected('contributions%s')" type="checkbox" name="contributions" value=%s></td>
3982 <td valign="top" nowrap class="CRLabstractDataCell">%s</td>
3983 <td valign="top" nowrap class="CRLabstractDataCell">%s</td>
3984 <td valign="top" nowrap class="CRLabstractDataCell">%s</td>
3985 <td valign="top" class="CRLabstractDataCell">%s</td>
3986 <td valign="top" class="CRLabstractDataCell">%s</td>
3987 <td valign="top" class="CRLabstractDataCell">%s</td>
3988 <td valign="top" class="CRLabstractDataCell">%s</td>
3989 <td valign="top" class="CRLabstractDataCell">%s</td>
3990 <td valign="top" class="CRLabstractDataCell">%s</td>
3991 <td valign="top" class="CRLabstractDataCell" nowrap>%s</td>
3992 </tr>
3993 """%(contrib.getId(), contrib.getId(), contrib.getId(),
3994 contrib.getId(), contrib.getId(),
3995 self.htmlText(contrib.getId()),
3996 sdate or "&nbsp;",strdur or "&nbsp;",cType or "&nbsp;",
3997 title or "&nbsp;",
3998 speaker or "&nbsp;",session or "&nbsp;",
3999 track or "&nbsp;",statusCaption or "&nbsp;",
4000 self._getMaterialsHTML(contrib) or "&nbsp;")
4001 return html
4003 def _getTypeItemsHTML(self):
4004 checked=""
4005 if self._filterCrit.getField("type").getShowNoValue():
4006 checked=" checked"
4007 res=[ i18nformat("""<input type="checkbox" name="typeShowNoValue" value="--none--"%s> --_("not specified")--""")%checked]
4008 for t in self._conf.getContribTypeList():
4009 checked=""
4010 if t.getId() in self._filterCrit.getField("type").getValues():
4011 checked=" checked"
4012 res.append("""<input type="checkbox" name="types" value=%s%s> %s"""%(quoteattr(str(t.getId())),checked,self.htmlText(t.getName())))
4013 return res
4015 def _getSessionItemsHTML(self):
4016 checked=""
4017 if self._filterCrit.getField("session").getShowNoValue():
4018 checked=" checked"
4019 res=[ i18nformat("""<input type="checkbox" name="sessionShowNoValue" value="--none--"%s> --_("not specified")--""")%checked]
4020 for s in self._conf.getSessionListSorted():
4021 checked=""
4022 l = self._filterCrit.getField("session").getValues()
4023 if not isinstance(l, list):
4024 l = [l]
4025 if s.getId() in l:
4026 checked=" checked"
4027 res.append("""<input type="checkbox" name="sessions" value=%s%s> (%s) %s"""%(quoteattr(str(s.getId())),checked,self.htmlText(s.getCode()),self.htmlText(s.getTitle())))
4028 return res
4030 def _getTrackItemsHTML(self):
4031 checked=""
4032 if self._filterCrit.getField("track").getShowNoValue():
4033 checked=" checked"
4034 res=[ i18nformat("""<input type="checkbox" name="trackShowNoValue" value="--none--"%s> --_("not specified")--""")%checked]
4035 for t in self._conf.getTrackList():
4036 checked=""
4037 if t.getId() in self._filterCrit.getField("track").getValues():
4038 checked=" checked"
4039 res.append("""<input type="checkbox" name="tracks" value=%s%s> (%s) %s"""%(quoteattr(str(t.getId())),checked,self.htmlText(t.getCode()),self.htmlText(t.getTitle())))
4040 return res
4042 def _getStatusItemsHTML(self):
4043 res=[]
4044 for st in ContribStatusList().getList():
4045 id=ContribStatusList().getId(st)
4046 checked=""
4047 if id in self._filterCrit.getField("status").getValues():
4048 checked=" checked"
4049 code=ContribStatusList().getCode(st)
4050 caption=ContribStatusList().getCaption(st)
4051 res.append("""<input type="checkbox" name="status" value=%s%s> (%s) %s"""%(quoteattr(str(id)),checked,self.htmlText(code),self.htmlText(caption)))
4052 return res
4054 def _getFilterMenu(self):
4056 options = [
4057 ('Types', {"title": _("Types"),
4058 "options": self._getTypeItemsHTML()}),
4059 ('Sessions', {"title": _("Sessions"),
4060 "options": self._getSessionItemsHTML()}),
4061 ('Tracks', {"title": _("Tracks"),
4062 "options": self._getTrackItemsHTML()}),
4063 ('Status', {"title": _("Status"),
4064 "options": self._getStatusItemsHTML()})
4067 extraInfo = i18nformat("""<table align="center" cellspacing="10" width="100%%">
4068 <tr>
4069 <td colspan="5" class="titleCellFormat"> _("Author search") <input type="text" name="authSearch" value=%s></td>
4070 </tr>
4071 </table>
4072 """)%(quoteattr(str(self._authSearch)))
4074 p = WFilterCriteriaContribs(options, None, extraInfo)
4076 return p.getHTML()
4078 def getVars( self ):
4079 vars = wcomponents.WTemplated.getVars( self )
4080 vars["filterUrl"] = str(self._filterUrl).replace('%', '%%')
4081 vars["quickSearchURL"]=quoteattr(str(urlHandlers.UHConfModContribQuickAccess.getURL(self._conf)))
4082 vars["filterPostURL"]=quoteattr(str(urlHandlers.UHConfModifContribList.getURL(self._conf)))
4083 self._authSearch=vars.get("authSearch","").strip()
4084 cl=self._conf.getContribsMatchingAuth(self._authSearch)
4086 sortingField = self._sortingCrit.getField()
4087 self._currentSorting=""
4089 if sortingField is not None:
4090 self._currentSorting=sortingField.getId()
4091 vars["currentSorting"]=""
4093 url=self._getURL()
4094 url.addParam("sortBy","number")
4095 vars["numberImg"]=""
4096 if self._currentSorting == "number":
4097 vars["currentSorting"] = i18nformat("""<input type="hidden" name="sortBy" value="_("number")">""")
4098 if self._order == "down":
4099 vars["numberImg"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4100 url.addParam("order","up")
4101 elif self._order == "up":
4102 vars["numberImg"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4103 url.addParam("order","down")
4104 vars["numberSortingURL"]=quoteattr(str(url))
4106 url = self._getURL()
4107 url.addParam("sortBy", "date")
4108 vars["dateImg"] = ""
4109 if self._currentSorting == "date":
4110 vars["currentSorting"]= i18nformat("""<input type="hidden" name="sortBy" value="_("date")">""")
4111 if self._order == "down":
4112 vars["dateImg"]="""<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4113 url.addParam("order","up")
4114 elif self._order == "up":
4115 vars["dateImg"]="""<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4116 url.addParam("order","down")
4117 vars["dateSortingURL"]=quoteattr(str(url))
4120 url = self._getURL()
4121 url.addParam("sortBy", "name")
4122 vars["titleImg"] = ""
4123 if self._currentSorting == "name":
4124 vars["currentSorting"]= i18nformat("""<input type="hidden" name="sortBy" value="_("name")">""")
4125 if self._order == "down":
4126 vars["titleImg"]="""<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4127 url.addParam("order","up")
4128 elif self._order == "up":
4129 vars["titleImg"]="""<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4130 url.addParam("order","down")
4131 vars["titleSortingURL"]=quoteattr(str(url))
4134 url = self._getURL()
4135 url.addParam("sortBy", "type")
4136 vars["typeImg"] = ""
4137 if self._currentSorting == "type":
4138 vars["currentSorting"]= i18nformat("""<input type="hidden" name="sortBy" value="_("type")">""")
4139 if self._order == "down":
4140 vars["typeImg"]="""<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4141 url.addParam("order","up")
4142 elif self._order == "up":
4143 vars["typeImg"]="""<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4144 url.addParam("order","down")
4145 vars["typeSortingURL"] = quoteattr( str( url ) )
4146 url = self._getURL()
4147 url.addParam("sortBy", "session")
4148 vars["sessionImg"] = ""
4149 if self._currentSorting == "session":
4150 vars["currentSorting"] = i18nformat("""<input type="hidden" name="sortBy" value='_("session")'>""")
4151 if self._order == "down":
4152 vars["sessionImg"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4153 url.addParam("order","up")
4154 elif self._order == "up":
4155 vars["sessionImg"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4156 url.addParam("order","down")
4157 vars["sessionSortingURL"] = quoteattr( str( url ) )
4158 url = self._getURL()
4159 url.addParam("sortBy", "speaker")
4160 vars["speakerImg"]=""
4161 if self._currentSorting=="speaker":
4162 vars["currentSorting"] = i18nformat("""<input type="hidden" name="sortBy" value="_("speaker")">""")
4163 if self._order == "down":
4164 vars["speakerImg"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4165 url.addParam("order","up")
4166 elif self._order == "up":
4167 vars["speakerImg"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4168 url.addParam("order","down")
4169 vars["speakerSortingURL"]=quoteattr( str( url ) )
4171 url = self._getURL()
4172 url.addParam("sortBy","track")
4173 vars["trackImg"] = ""
4174 if self._currentSorting == "track":
4175 vars["currentSorting"] = i18nformat("""<input type="hidden" name="sortBy" value="_("track")">""")
4176 if self._order == "down":
4177 vars["trackImg"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4178 url.addParam("order","up")
4179 elif self._order == "up":
4180 vars["trackImg"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4181 url.addParam("order","down")
4182 vars["trackSortingURL"] = quoteattr( str( url ) )
4184 f=filters.SimpleFilter(self._filterCrit,self._sortingCrit)
4185 filteredContribs = f.apply(cl)
4186 l = [self._getContribHTML(contrib) for contrib in filteredContribs]
4187 contribsToPrint = ["""<input type="hidden" name="contributions" value="%s">"""%contrib.getId() for contrib in filteredContribs]
4188 numContribs = len(filteredContribs)
4190 if self._order =="up":
4191 l.reverse()
4192 vars["contribsToPrint"] = "\n".join(contribsToPrint)
4193 vars["contributions"] = "".join(l)
4194 orginURL = urlHandlers.UHConfModifContribList.getURL(self._conf)
4195 vars["numContribs"]=str(numContribs)
4197 vars["totalNumContribs"] = str(len(self._conf.getContributionList()))
4198 vars["filterUsed"] = self._filterUsed
4200 vars["contributionsPDFURL"]=quoteattr(str(urlHandlers.UHContribsConfManagerDisplayMenuPDF.getURL(self._conf)))
4201 vars["contribSelectionAction"]=quoteattr(str(urlHandlers.UHContribConfSelectionAction.getURL(self._conf)))
4203 totaldur = self._totaldur
4204 days = totaldur.days
4205 hours = (totaldur.seconds)/3600
4206 dayhours = (days * 24)+hours
4207 mins = ((totaldur.seconds)/60)-(hours*60)
4208 vars["totaldur"] = """%sh%sm""" % (dayhours, mins)
4209 vars['rbActive'] = Config.getInstance().getIsRoomBookingActive()
4210 vars["bookings"] = Conversion.reservationsList(self._conf.getRoomBookingList())
4211 vars["filterMenu"] = self._getFilterMenu()
4212 vars["sortingOptions"]="""<input type="hidden" name="sortBy" value="%s">
4213 <input type="hidden" name="order" value="%s">"""%(self._sortingCrit.getField().getId(), self._order)
4214 vars["pdfIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("pdf")))
4215 vars["excelIconURL"] = quoteattr(str(Config.getInstance().getSystemIconURL("excel")))
4216 vars["xmlIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("xml")))
4217 return vars
4219 class WFilterCriteriaContribs(wcomponents.WFilterCriteria):
4221 Draws the options for a filter criteria object
4222 This means rendering the actual table that contains
4223 all the HTML for the several criteria
4226 def __init__(self, options, filterCrit, extraInfo=""):
4227 wcomponents.WFilterCriteria.__init__(self, options, filterCrit, extraInfo)
4229 def _drawFieldOptions(self, id, data):
4231 page = WFilterCriterionOptionsContribs(id, data)
4233 # TODO: remove when we have a better template system
4234 return page.getHTML().replace('%','%%')
4236 class WFilterCriterionOptionsContribs(wcomponents.WTemplated):
4238 def __init__(self, id, data):
4239 self._id = id
4240 self._data = data
4242 def getVars(self):
4244 vars = wcomponents.WTemplated.getVars( self )
4246 vars["id"] = self._id
4247 vars["title"] = self._data["title"]
4248 vars["options"] = self._data["options"]
4249 vars["selectFunc"] = self._data.get("selectFunc", True)
4251 return vars
4253 class WPModifContribList( WPConferenceModifBase ):
4255 _userData = ['favorite-user-list', 'favorite-user-ids']
4257 def __init__(self, rh, conference, filterUsed=False):
4258 WPConferenceModifBase.__init__(self, rh, conference)
4259 self._filterUsed = filterUsed
4261 def _setActiveSideMenuItem(self):
4262 self._contribListMenuItem.setActive(True)
4264 def _getPageContent( self, params ):
4265 filterCrit=params.get("filterCrit",None)
4266 sortingCrit=params.get("sortingCrit",None)
4267 order = params.get("order","down")
4269 filterParams = {}
4270 fields = getattr(filterCrit, '_fields')
4271 for field in fields.values():
4272 id = field.getId()
4273 showNoValue = field.getShowNoValue()
4274 values = field.getValues()
4275 if showNoValue:
4276 filterParams['%sShowNoValue' % id] = '--none--'
4277 filterParams[id] = values
4279 requestParams = self._rh.getRequestParams()
4281 operationType = requestParams.get('operationType')
4282 if operationType != 'resetFilters':
4283 operationType = 'filter'
4284 urlParams = dict(isBookmark='y', operationType=operationType)
4286 urlParams.update(self._rh.getRequestParams())
4287 urlParams.update(filterParams)
4288 filterUrl = self._rh._uh.getURL(None, **urlParams)
4290 wc = WConfModifContribList(self._conf,filterCrit, sortingCrit, order, self._filterUsed, filterUrl)
4291 p={"authSearch":params.get("authSearch","")}
4293 return wc.getHTML(p)
4295 class WPConfModifContribToPDFMenu( WPModifContribList ):
4297 def __init__(self, rh, conf, contribIds):
4298 WPModifContribList.__init__(self, rh, conf)
4299 self._contribIds = contribIds
4301 def _getPageContent(self, params):
4303 wc = WConfModifContribToPDFMenu(self._conf, self._contribIds)
4304 return wc.getHTML(params)
4306 class WConfModifContribToPDFMenu(wcomponents.WTemplated):
4307 def __init__(self, conf, contribIds):
4308 self._conf = conf
4309 self.contribIds = contribIds
4311 def getVars( self ):
4312 vars = wcomponents.WTemplated.getVars( self )
4313 vars["createPDFURL"] = urlHandlers.UHContribsConfManagerDisplayMenuPDF.getURL(self._conf)
4314 l = []
4315 for id in self.contribIds:
4316 l.append("""<input type="hidden" name="contributions" value="%s">"""%id)
4317 vars["contribIdsList"] = "\n".join(l)
4318 return vars
4321 class WConfModMoveContribsToSession(wcomponents.WTemplated):
4323 def __init__(self,conf,contribIdList=[]):
4324 self._conf=conf
4325 self._contribIdList=contribIdList
4327 def getVars(self):
4328 vars=wcomponents.WTemplated.getVars(self)
4329 vars["postURL"]=quoteattr(str(urlHandlers.UHConfModMoveContribsToSession.getURL(self._conf)))
4330 vars["contribs"]=",".join(self._contribIdList)
4331 s=["""<option value="--none--">--none--</option>"""]
4332 for session in self._conf.getSessionListSorted():
4333 if not session.isClosed():
4334 s.append("""<option value=%s>%s</option>"""%(
4335 quoteattr(str(session.getId())),
4336 self.htmlText(session.getTitle())))
4337 vars["sessions"]="".join(s)
4338 return vars
4341 class WPModMoveContribsToSession(WPModifContribList):
4343 def _getPageContent(self,params):
4344 wc=WConfModMoveContribsToSession(self._conf,params.get("contribIds",[]))
4345 return wc.getHTML()
4348 class WPModMoveContribsToSessionConfirmation(WPModifContribList):
4350 def _getPageContent(self,params):
4351 wc=wcomponents.WConfModMoveContribsToSessionConfirmation(self._conf,params.get("contribIds",[]),params.get("targetSession",None))
4352 p={"postURL":urlHandlers.UHConfModMoveContribsToSession.getURL(self._conf),}
4353 return wc.getHTML(p)
4356 class WPConfEditContribType(WPConferenceModifBase):
4358 def __init__(self, rh, ct):
4359 self._conf = ct.getConference()
4360 self._contribType = ct
4361 WPConferenceModifBase.__init__(self, rh, self._conf)
4363 def _setActiveSideMenuItem(self):
4364 self._generalSettingsMenuItem.setActive(True)
4366 def _getPageContent( self, params ):
4367 wc = WConfEditContribType(self._contribType)
4368 params["saveURL"] = quoteattr(str(urlHandlers.UHConfEditContribType.getURL(self._contribType)))
4369 return wc.getHTML(params)
4372 class WConfEditContribType(wcomponents.WTemplated):
4374 def __init__(self, contribType):
4375 self._contribType = contribType
4377 def getVars(self):
4378 vars = wcomponents.WTemplated.getVars(self)
4379 vars["ctName"] = self._contribType.getName()
4380 vars["ctDescription"] = self._contribType.getDescription()
4382 return vars
4384 class WPConfAddContribType(WPConferenceModifBase):
4386 def _setActiveSideMenuItem(self):
4387 self._generalSettingsMenuItem.setActive(True)
4389 def _getPageContent( self, params ):
4390 wc = WConfAddContribType()
4391 params["saveURL"] = quoteattr(str(urlHandlers.UHConfAddContribType.getURL(self._conf)))
4392 return wc.getHTML(params)
4395 class WConfAddContribType(wcomponents.WTemplated):
4397 def getVars(self):
4398 vars = wcomponents.WTemplated.getVars(self)
4399 return vars
4401 class WAbstractsParticipantList(wcomponents.WTemplated):
4403 def __init__(self, conf, emailList, displayedGroups, abstracts):
4404 self._emailList = emailList
4405 self._displayedGroups = displayedGroups
4406 self._conf = conf
4407 self._abstracts = abstracts
4409 def getVars(self):
4410 vars = wcomponents.WTemplated.getVars(self)
4412 vars["submitterEmails"] = ",".join(self._emailList["submitters"]["emails"])
4413 vars["primaryAuthorEmails"] = ",".join(self._emailList["primaryAuthors"]["emails"])
4414 vars["coAuthorEmails"] = ",".join(self._emailList["coAuthors"]["emails"])
4416 urlDisplayGroup = urlHandlers.UHAbstractsConfManagerDisplayParticipantList.getURL(self._conf)
4417 abstractsToPrint = []
4418 for abst in self._abstracts:
4419 abstractsToPrint.append("""<input type="hidden" name="abstracts" value="%s">"""%abst)
4420 abstractsList = "".join(abstractsToPrint)
4421 displayedGroups = []
4422 for dg in self._displayedGroups:
4423 displayedGroups.append("""<input type="hidden" name="displayedGroups" value="%s">"""%dg)
4424 groupsList = "".join(displayedGroups)
4426 # Submitters
4427 text = _("show list")
4428 vars["submitters"] = "<tr colspan=\"2\"><td>&nbsp;</td></tr>"
4429 if "submitters" in self._displayedGroups:
4430 l = []
4431 color = "white"
4432 text = _("close list")
4433 for subm in self._emailList["submitters"]["tree"].values():
4434 if color=="white":
4435 color="#F6F6F6"
4436 else:
4437 color="white"
4438 participant = "%s %s %s <%s>"%(subm.getTitle(), subm.getFirstName(), safe_upper(subm.getFamilyName()), subm.getEmail())
4439 l.append("<tr>\
4440 <td colspan=\"2\" nowrap bgcolor=\"%s\" class=\"blacktext\">\
4441 &nbsp;&nbsp;&nbsp;%s</td></tr>"%(color, self.htmlText(participant)))
4442 vars["submitters"] = "".join(l)
4443 urlDisplayGroup.addParam("clickedGroup", "submitters")
4444 vars["showSubmitters"] = """<form action="%s" method="post">\
4447 <input type="submit" class="btn" value="%s">
4448 </form>"""%(str(urlDisplayGroup), abstractsList,groupsList, text)
4450 # Primary authors
4451 text = _("show list")
4452 vars["primaryAuthors"] = "<tr colspan=\"2\"><td>&nbsp;</td></tr>"
4453 if "primaryAuthors" in self._displayedGroups:
4454 l = []
4455 color = "white"
4456 text = _("close list")
4457 for pAuth in self._emailList["primaryAuthors"]["tree"].values():
4458 if color=="white":
4459 color="#F6F6F6"
4460 else:
4461 color="white"
4462 participant = "%s <%s>"%(pAuth.getFullName(), pAuth.getEmail())
4463 l.append("<tr><td colspan=\"2\" nowrap bgcolor=\"%s\" \
4464 class=\"blacktext\">&nbsp;&nbsp;&nbsp;%s</td></tr>"%(color, self.htmlText(participant)))
4465 vars["primaryAuthors"] = "".join(l)
4466 urlDisplayGroup.addParam("clickedGroup", "primaryAuthors")
4467 vars["showPrimaryAuthors"] = """<form action="%s" method="post">\
4470 <input type="submit" class="btn" value="%s">
4471 </form>"""%(str(urlDisplayGroup), abstractsList,groupsList, text)
4473 # Co-Authors
4474 text = _("show list")
4475 vars["coAuthors"] = "<tr colspan=\"2\"><td>&nbsp;</td></tr>"
4476 if "coAuthors" in self._displayedGroups:
4477 l = []
4478 color = "white"
4479 text = _("close list")
4480 for cAuth in self._emailList["coAuthors"]["tree"].values():
4481 if color=="white":
4482 color="#F6F6F6"
4483 else:
4484 color="white"
4485 cAuthEmail = cAuth.getEmail()
4486 if cAuthEmail.strip() == "":
4487 participant = "%s"%cAuth.getFullName()
4488 else:
4489 participant = "%s <%s>"%(cAuth.getFullName(), cAuthEmail)
4490 l.append("<tr><td colspan=\"2\" nowrap bgcolor=\"%s\" class=\"blacktext\">\
4491 &nbsp;&nbsp;&nbsp;%s</td></tr>"%(color, self.htmlText(participant)))
4492 vars["coAuthors"] = "".join(l)
4493 urlDisplayGroup.addParam("clickedGroup", "coAuthors")
4494 vars["showCoAuthors"] = """<form action="%s" method="post">\
4497 <input type="submit" class="btn" value="%s">
4498 </form>"""%(str(urlDisplayGroup), abstractsList,groupsList, text)
4499 return vars
4501 class WContribParticipantList(wcomponents.WTemplated):
4503 def __init__(self, conf, emailList, displayedGroups, contribs):
4504 self._emailList = emailList
4505 self._displayedGroups = displayedGroups
4506 self._conf = conf
4507 self._contribs = contribs
4509 def getVars(self):
4510 vars = wcomponents.WTemplated.getVars(self)
4512 vars["speakerEmails"] = ", ".join(self._emailList["speakers"]["emails"])
4513 vars["primaryAuthorEmails"] = ", ".join(self._emailList["primaryAuthors"]["emails"])
4514 vars["coAuthorEmails"] = ", ".join(self._emailList["coAuthors"]["emails"])
4516 urlDisplayGroup = vars["urlDisplayGroup"]
4517 contribsToPrint = []
4518 for contrib in self._contribs:
4519 contribsToPrint.append("""<input type="hidden" name="contributions" value="%s">"""%contrib)
4520 contribsList = "".join(contribsToPrint)
4521 displayedGroups = []
4522 for dg in self._displayedGroups:
4523 displayedGroups.append("""<input type="hidden" name="displayedGroups" value="%s">"""%dg)
4524 groupsList = "".join(displayedGroups)
4526 # Speakers
4527 text = _("show list")
4528 vars["speakers"] = "<tr colspan=\"2\"><td>&nbsp;</td></tr>"
4529 if "speakers" in self._displayedGroups:
4530 l = []
4531 color = "white"
4532 text = _("close list")
4533 for speaker in self._emailList["speakers"]["tree"].values():
4534 if color=="white":
4535 color="#F6F6F6"
4536 else:
4537 color="white"
4538 participant = "%s <%s>"%(speaker.getFullName(), speaker.getEmail())
4539 l.append("<tr>\
4540 <td colspan=\"2\" nowrap bgcolor=\"%s\" class=\"blacktext\">\
4541 &nbsp;&nbsp;&nbsp;%s</td></tr>"%(color, self.htmlText(participant)))
4542 vars["speakers"] = "".join(l)
4543 urlDisplayGroup.addParam("clickedGroup", "speakers")
4544 vars["showSpeakers"] = """<form action="%s" method="post">\
4547 <input type="submit" class="btn" value="%s">
4548 </form>"""%(str(urlDisplayGroup), contribsList,groupsList, text)
4550 # Primary authors
4551 text = _("show list")
4552 vars["primaryAuthors"] = "<tr colspan=\"2\"><td>&nbsp;</td></tr>"
4553 if "primaryAuthors" in self._displayedGroups:
4554 l = []
4555 color = "white"
4556 text = _("close list")
4557 for pAuth in self._emailList["primaryAuthors"]["tree"].values():
4558 if color=="white":
4559 color="#F6F6F6"
4560 else:
4561 color="white"
4562 participant = "%s %s %s <%s>"%(pAuth.getTitle(), pAuth.getFirstName(), safe_upper(pAuth.getFamilyName()), pAuth.getEmail())
4563 l.append("<tr><td colspan=\"2\" nowrap bgcolor=\"%s\" \
4564 class=\"blacktext\">&nbsp;&nbsp;&nbsp;%s</td></tr>"%(color, self.htmlText(participant)))
4565 vars["primaryAuthors"] = "".join(l)
4566 urlDisplayGroup.addParam("clickedGroup", "primaryAuthors")
4567 vars["showPrimaryAuthors"] = """<form action="%s" method="post">\
4570 <input type="submit" class="btn" value="%s">
4571 </form>"""%(str(urlDisplayGroup), contribsList,groupsList, text)
4573 # Co-Authors
4574 text = _("show list")
4575 vars["coAuthors"] = "<tr colspan=\"2\"><td>&nbsp;</td></tr>"
4576 if "coAuthors" in self._displayedGroups:
4577 l = []
4578 color = "white"
4579 text = _("close list")
4580 for cAuth in self._emailList["coAuthors"]["tree"].values():
4581 if color=="white":
4582 color="#F6F6F6"
4583 else:
4584 color="white"
4585 cAuthEmail = cAuth.getEmail()
4586 if cAuthEmail.strip() == "":
4587 participant = "%s %s %s"%(cAuth.getTitle(), cAuth.getFirstName(), safe_upper(cAuth.getFamilyName()))
4588 else:
4589 participant = "%s %s %s <%s>"%(cAuth.getTitle(), cAuth.getFirstName(), safe_upper(cAuth.getFamilyName()), cAuthEmail)
4590 l.append("<tr><td colspan=\"2\" nowrap bgcolor=\"%s\" class=\"blacktext\">\
4591 &nbsp;&nbsp;&nbsp;%s</td></tr>"%(color, self.htmlText(participant)))
4592 vars["coAuthors"] = "".join(l)
4593 urlDisplayGroup.addParam("clickedGroup", "coAuthors")
4594 vars["showCoAuthors"] = """<form action="%s" method="post">\
4597 <input type="submit" class="btn" value="%s">
4598 </form>"""%(str(urlDisplayGroup), contribsList,groupsList, text)
4599 return vars
4602 class WPAbstractSendNotificationMail(WPConferenceBase):
4604 def __init__(self, rh, conf, count):
4605 WPConferenceBase.__init__(self, rh, conf)
4606 self._count = count
4608 def _getBody( self, params ):
4609 return i18nformat("""
4610 <table align="center"><tr><td align="center">
4611 <b> _("The submitters of the selected abstracts will nearly recieve the notification mail").<br>
4612 <br>
4613 _("You can now close this window.")</b>
4614 </td></tr></table>
4616 """)
4619 class WPContributionList( WPConferenceDefaultDisplayBase ):
4620 navigationEntry = navigation.NEContributionList
4622 def _getBody( self, params ):
4623 wc = WConfContributionList( self._getAW(), self._conf, params["filterCrit"], params.get("filterText",""))
4624 return wc.getHTML()
4626 def _defineSectionMenu( self ):
4627 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
4628 self._sectionMenu.setCurrentItem(self._contribListOpt)
4631 class WConfContributionList (WConfDisplayBodyBase):
4633 _linkname = "contributionList"
4635 def __init__(self, aw, conf, filterCrit, filterText):
4636 self._aw = aw
4637 self._conf = conf
4638 self._filterCrit = filterCrit
4639 self._filterText = filterText
4641 def getVars(self):
4642 wvars = wcomponents.WTemplated.getVars(self)
4644 wvars["body_title"] = self._getTitle()
4645 wvars["contributions"] = self._conf.getContributionListSorted(includeWithdrawn=False, key="title")
4646 wvars["showAttachedFiles"] = self._conf.getAbstractMgr().showAttachedFilesContribList()
4647 wvars["conf"] = self._conf
4648 wvars["accessWrapper"] = self._aw
4649 wvars["filterCriteria"] = self._filterCrit
4650 wvars["filterText"] = self._filterText
4651 wvars["formatDate"] = lambda date: format_date(date, "d MMM yyyy")
4652 wvars["formatTime"] = lambda time: format_time(time, format="short", timezone=timezone(DisplayTZ(self._aw, self._conf).getDisplayTZ()))
4653 return wvars
4656 class WConfAuthorIndex(WConfDisplayBodyBase):
4658 _linkname = "authorIndex"
4660 def __init__(self, conf):
4661 self._conf = conf
4663 def getVars(self):
4664 wvars = wcomponents.WTemplated.getVars(self)
4665 wvars["body_title"] = self._getTitle()
4666 wvars["items"] = dict(enumerate(self._getItems()))
4667 return wvars
4669 def _getItems(self):
4670 res = []
4672 for key, authors in self._conf.getAuthorIndex().iteritems():
4673 # get the first identity that matches the author
4674 if len(authors) == 0:
4675 continue
4676 else:
4677 auth = next((x for x in authors if x.getContribution() and x.getContribution().getConference()), None)
4678 if auth is None:
4679 continue
4681 authorURL = urlHandlers.UHContribAuthorDisplay.getURL(auth.getContribution(), authorId=auth.getId())
4682 contribs = []
4683 res.append({'fullName': auth.getFullNameNoTitle(),
4684 'affiliation': auth.getAffiliation(),
4685 'authorURL': authorURL,
4686 'contributions': contribs})
4688 for auth in authors:
4689 contrib = auth.getContribution()
4690 if contrib is not None and contrib.getConference() is not None:
4691 contribs.append({
4692 'title': contrib.getTitle(),
4693 'url': str(urlHandlers.UHContributionDisplay.getURL(auth.getContribution())),
4694 'attached_items': contrib.attached_items
4696 return res
4699 class WPAuthorIndex(WPConferenceDefaultDisplayBase):
4700 navigationEntry = navigation.NEAuthorIndex
4702 def getJSFiles(self):
4703 return WPConferenceDefaultDisplayBase.getJSFiles(self) + \
4704 self._asset_env['indico_authors'].urls()
4706 def _getBody(self, params):
4707 wc = WConfAuthorIndex(self._conf)
4708 return wc.getHTML()
4710 def _defineSectionMenu(self):
4711 WPConferenceDefaultDisplayBase._defineSectionMenu(self)
4712 self._sectionMenu.setCurrentItem(self._authorIndexOpt)
4715 class WConfSpeakerIndex(WConfDisplayBodyBase):
4717 _linkname = "speakerIndex"
4719 def __init__(self, conf):
4720 self._conf = conf
4722 def getVars(self):
4723 wvars = wcomponents.WTemplated.getVars(self)
4724 res = collections.defaultdict(list)
4725 for index, key in enumerate(self._conf.getSpeakerIndex().getParticipationKeys()):
4726 pl = self._conf.getSpeakerIndex().getById(key)
4727 try:
4728 speaker = pl[0]
4729 except IndexError:
4730 continue
4731 res[index].append({'fullName': speaker.getFullNameNoTitle(), 'affiliation': speaker.getAffiliation()})
4732 for speaker in pl:
4733 if isinstance(speaker, conference.SubContribParticipation):
4734 participation = speaker.getSubContrib()
4735 if participation is None:
4736 continue
4737 url = urlHandlers.UHSubContributionDisplay.getURL(participation)
4738 else:
4739 participation = speaker.getContribution()
4740 if participation is None:
4741 continue
4742 url = urlHandlers.UHContributionDisplay.getURL(participation)
4743 if participation.getConference() is not None:
4744 res[index].append({'title': participation.getTitle(),
4745 'url': str(url),
4746 'attached_items': participation.getContribution().attached_items})
4747 wvars["body_title"] = self._getTitle()
4748 wvars["items"] = res
4749 return wvars
4752 class WPSpeakerIndex(WPConferenceDefaultDisplayBase):
4753 navigationEntry = navigation.NESpeakerIndex
4755 def _getBody(self, params):
4756 wc=WConfSpeakerIndex(self._conf)
4757 return wc.getHTML()
4759 def getJSFiles(self):
4760 return WPConferenceDefaultDisplayBase.getJSFiles(self) + \
4761 self._asset_env['indico_authors'].urls()
4763 def _defineSectionMenu( self ):
4764 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
4765 self._sectionMenu.setCurrentItem(self._speakerIndexOpt)
4767 class WConfMyContributions(wcomponents.WTemplated):
4769 def __init__(self, aw, conf):
4770 self._aw=aw
4771 self._conf=conf
4773 def getHTML(self, params):
4774 return wcomponents.WTemplated.getHTML(self, params)
4776 def getVars(self):
4777 vars = wcomponents.WTemplated.getVars( self )
4778 vars["User"] = self._aw.getUser()
4779 vars["Conference"] = self._conf
4780 vars["ConfReviewingChoice"] = self._conf.getConfPaperReview().getChoice()
4781 return vars
4784 class WConfMyStuffMySessions(WConfDisplayBodyBase):
4786 _linkname = "mysessions"
4788 def __init__(self, aw, conf):
4789 self._aw = aw
4790 self._conf = conf
4792 def _getSessionsHTML(self):
4793 if self._aw.getUser() is None:
4794 return ""
4795 #ls=self._conf.getCoordinatedSessions(self._aw.getUser())+self._conf.getManagedSession(self._aw.getUser())
4796 ls = set(self._conf.getCoordinatedSessions(self._aw.getUser()))
4797 ls = list(ls | set(self._conf.getManagedSession(self._aw.getUser())))
4798 if len(ls) <= 0:
4799 return ""
4800 res = []
4801 iconURL = Config.getInstance().getSystemIconURL("conf_edit")
4802 for s in ls:
4803 modURL = urlHandlers.UHSessionModification.getURL(s)
4804 dispURL = urlHandlers.UHSessionDisplay.getURL(s)
4805 res.append("""
4806 <tr class="infoTR">
4807 <td class="infoTD" width="100%%">%s</td>
4808 <td nowrap class="infoTD"><a href=%s>%s</a><span class="horizontalSeparator">|</span><a href=%s>%s</a></td>
4809 </tr>""" % (self.htmlText(s.getTitle()),
4810 quoteattr(str(modURL)),
4811 _("Edit"),
4812 quoteattr(str(dispURL)),
4813 _("View")))
4814 return """
4815 <table class="infoTable" cellspacing="0" width="100%%">
4816 <tr>
4817 <td nowrap class="tableHeader"> %s </td>
4818 <td nowrap class="tableHeader" style="text-align:right;"> %s </td>
4819 </tr>
4820 <tr>
4821 <td>%s</td>
4822 </tr>
4823 </table>
4824 """ % (_("Session"),
4825 _("Actions"),
4826 "".join(res))
4828 def getVars(self):
4829 wvars = wcomponents.WTemplated.getVars(self)
4830 wvars["body_title"] = self._getTitle()
4831 wvars["items"] = self._getSessionsHTML()
4832 return wvars
4835 class WPConfMyStuffMySessions(WPConferenceDefaultDisplayBase):
4836 navigationEntry = navigation.NEMyStuff
4838 def _getBody(self,params):
4839 wc=WConfMyStuffMySessions(self._getAW(),self._conf)
4840 return wc.getHTML()
4842 def _defineSectionMenu( self ):
4843 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
4844 self._sectionMenu.setCurrentItem(self._myStuffOpt)
4847 class WConfMyStuffMyContributions(WConfDisplayBodyBase):
4849 _linkname = "mycontribs"
4851 def __init__(self, aw, conf):
4852 self._aw = aw
4853 self._conf = conf
4855 def _getContribsHTML(self):
4856 return WConfMyContributions(self._aw, self._conf).getHTML({})
4858 def getVars(self):
4859 wvars = wcomponents.WTemplated.getVars(self)
4860 wvars["body_title"] = self._getTitle()
4861 wvars["items"] = self._getContribsHTML()
4862 return wvars
4865 class WPConfMyStuffMyContributions(WPConferenceDefaultDisplayBase):
4866 navigationEntry = navigation.NEMyStuff
4868 def _getBody(self,params):
4869 wc=WConfMyStuffMyContributions(self._getAW(),self._conf)
4870 return wc.getHTML()
4872 def _defineSectionMenu( self ):
4873 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
4874 self._sectionMenu.setCurrentItem(self._myContribsOpt)
4877 class WConfMyStuffMyTracks(WConfDisplayBodyBase):
4879 _linkname = "mytracks"
4881 def __init__(self, aw, conf):
4882 self._aw = aw
4883 self._conf = conf
4885 def _getTracksHTML(self):
4886 if self._aw.getUser() is None or not self._conf.getAbstractMgr().isActive() or not self._conf.hasEnabledSection("cfa"):
4887 return ""
4888 lt = self._conf.getCoordinatedTracks(self._aw.getUser())
4889 if len(lt) <= 0:
4890 return ""
4891 res = []
4892 iconURL = Config.getInstance().getSystemIconURL("conf_edit")
4893 for t in lt:
4894 modURL = urlHandlers.UHTrackModifAbstracts.getURL(t)
4895 res.append("""
4896 <tr class="infoTR">
4897 <td class="infoTD" width="100%%">%s</td>
4898 <td nowrap class="infoTD"><a href=%s>%s</a></td>
4899 </tr>""" % (self.htmlText(t.getTitle()),
4900 quoteattr(str(modURL)),
4901 _("Edit")))
4902 return """
4903 <table class="infoTable" cellspacing="0" width="100%%">
4904 <tr>
4905 <td nowrap class="tableHeader"> %s </td>
4906 <td nowrap class="tableHeader" style="text-align:right;"> %s </td>
4907 </tr>
4908 <tr>
4909 <td>%s</td>
4910 </tr>
4911 </table>
4912 """ % (_("Track"),
4913 _("Actions"),
4914 "".join(res))
4916 def getVars(self):
4917 wvars = wcomponents.WTemplated.getVars(self)
4918 wvars["body_title"] = self._getTitle()
4919 wvars["items"] = self._getTracksHTML()
4920 return wvars
4922 class WPConfMyStuffMyTracks(WPConferenceDefaultDisplayBase):
4923 navigationEntry = navigation.NEMyStuff
4925 def _getBody(self,params):
4926 wc=WConfMyStuffMyTracks(self._getAW(),self._conf)
4927 return wc.getHTML()
4929 def _defineSectionMenu( self ):
4930 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
4931 self._sectionMenu.setCurrentItem(self._myTracksOpt)
4934 class WConfMyStuff(WConfDisplayBodyBase):
4936 _linkname = "mystuff"
4938 def __init__(self, aw, conf):
4939 self._aw = aw
4940 self._conf = conf
4942 def getVars(self):
4943 wvars = wcomponents.WTemplated.getVars(self)
4944 wvars["body_title"] = self._getTitle()
4945 return wvars
4948 class WPMyStuff(WPConferenceDefaultDisplayBase):
4949 navigationEntry = navigation.NEMyStuff
4951 def _getBody(self,params):
4952 wc=WConfMyStuff(self._getAW(),self._conf)
4953 return wc.getHTML()
4955 def _defineSectionMenu( self ):
4956 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
4957 self._sectionMenu.setCurrentItem(self._myStuffOpt)
4960 class WConfModAbstractBook(wcomponents.WTemplated):
4962 def __init__(self,conf):
4963 self._conf = conf
4965 def getVars(self):
4966 vars = wcomponents.WTemplated.getVars(self)
4967 boaConfig = self._conf.getBOAConfig()
4968 vars["sortByList"] = boaConfig.getSortByTypes()
4969 vars["modURL"] = quoteattr(str(urlHandlers.UHConfModAbstractBook.getURL(self._conf)))
4970 vars["previewURL"] = quoteattr(str(urlHandlers.UHConfAbstractBook.getURL(self._conf)))
4971 vars["sortBy"] = boaConfig.getSortBy()
4972 vars["boaConfig"] = boaConfig
4973 vars["urlToogleShowIds"] = str(urlHandlers.UHConfModAbstractBookToogleShowIds.getURL(self._conf))
4974 vars["conf"] = self._conf
4975 vars["bookOfAbstractsActive"] = self._conf.getAbstractMgr().getCFAStatus()
4976 vars["bookOfAbstractsMenuActive"] = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
4977 self._conf).getMenu().getLinkByName('abstractsBook').isEnabled()
4978 vars["correspondingAuthorList"] = boaConfig.getCorrespondingAuthorTypes()
4979 vars["correspondingAuthor"] = boaConfig.getCorrespondingAuthor()
4980 return vars
4983 class WPModAbstractBook(WPConferenceModifAbstractBase):
4985 def _setActiveTab(self):
4986 self._tabBOA.setActive()
4988 def _getTabContent(self, params):
4989 wc = WConfModAbstractBook(self._conf)
4990 return wc.getHTML()
4992 def getCSSFiles(self):
4993 return WPConferenceModifAbstractBase.getCSSFiles(self) + \
4994 self._asset_env['contributions_sass'].urls()
4996 def getJSFiles(self):
4997 return WPConferenceModifAbstractBase.getJSFiles(self) + \
4998 self._includeJSPackage('Management') + \
4999 self._asset_env['abstracts_js'].urls()
5001 def _getHeadContent(self):
5002 return WPConferenceModifAbstractBase._getHeadContent(self) + render('js/mathjax.config.js.tpl') + \
5003 '\n'.join(['<script src="{0}" type="text/javascript"></script>'.format(url)
5004 for url in self._asset_env['mathjax_js'].urls()])
5007 class WTimeTableCustomizePDF(wcomponents.WTemplated):
5009 def __init__(self, conf):
5010 self._conf = conf
5012 def getVars(self):
5013 vars = wcomponents.WTemplated.getVars(self)
5014 url = urlHandlers.UHConfTimeTablePDF.getURL(self._conf)
5015 vars["getPDFURL"] = quoteattr(str(url))
5016 vars["showDays"] = vars.get("showDays", "all")
5017 vars["showSessions"] = vars.get("showSessions", "all")
5019 wc = WConfCommonPDFOptions(self._conf)
5020 vars["commonPDFOptions"] = wc.getHTML()
5022 return vars
5025 class WPTimeTableCustomizePDF(WPConferenceDefaultDisplayBase):
5026 navigationEntry = navigation.NETimeTableCustomizePDF
5028 def _getBody(self, params):
5029 wc = WTimeTableCustomizePDF(self._conf)
5030 return wc.getHTML(params)
5032 def _defineSectionMenu(self):
5033 WPConferenceDefaultDisplayBase._defineSectionMenu(self)
5034 self._sectionMenu.setCurrentItem(self._timetableOpt)
5037 class WConfModifPendingQueuesList(wcomponents.WTemplated):
5039 def __init__(self, url, title, target, list, pType):
5040 self._postURL = url
5041 self._title = title
5042 self._target = target
5043 self._list = list
5044 self._pType = pType
5046 def _cmpByConfName(self, cp1, cp2):
5047 if cp1 is None and cp2 is not None:
5048 return -1
5049 elif cp1 is not None and cp2 is None:
5050 return 1
5051 elif cp1 is None and cp2 is None:
5052 return 0
5053 return cmp(cp1.getTitle(), cp2.getTitle())
5055 def _cmpByContribName(self, cp1, cp2):
5056 if cp1 is None and cp2 is not None:
5057 return -1
5058 elif cp1 is not None and cp2 is None:
5059 return 1
5060 elif cp1 is None and cp2 is None:
5061 return 0
5062 return cmp(cp1.getContribution().getTitle(), cp2.getContribution().getTitle())
5064 def _cmpBySessionName(self, cp1, cp2):
5065 if cp1 is None and cp2 is not None:
5066 return -1
5067 elif cp1 is not None and cp2 is None:
5068 return 1
5069 elif cp1 is None and cp2 is None:
5070 return 0
5071 return cmp(cp1.getSession().getTitle(), cp2.getSession().getTitle())
5073 def getVars(self):
5074 vars = wcomponents.WTemplated.getVars(self)
5076 vars["postURL"] = self._postURL
5077 vars["title"] = self._title
5078 vars["target"] = self._target
5079 vars["list"] = self._list
5080 vars["pType"] = self._pType
5082 return vars
5085 class WConfModifPendingQueues(wcomponents.WTemplated):
5087 def __init__(self, conf, aw, activeTab="submitters"):
5088 self._conf = conf
5089 self._aw = aw
5090 self._activeTab = activeTab
5091 self._pendingConfManagers = self._conf.getPendingQueuesMgr().getPendingConfManagers()
5092 self._pendingConfSubmitters = self._conf.getPendingQueuesMgr().getPendingConfSubmitters()
5093 self._pendingSubmitters = self._conf.getPendingQueuesMgr().getPendingSubmitters()
5094 self._pendingManagers = self._conf.getPendingQueuesMgr().getPendingManagers()
5095 self._pendingCoordinators = self._conf.getPendingQueuesMgr().getPendingCoordinators()
5097 def _createTabCtrl(self):
5098 self._tabCtrl = wcomponents.TabControl()
5099 url = urlHandlers.UHConfModifPendingQueues.getURL(self._conf)
5100 url.addParam("tab", "conf_submitters")
5101 self._tabConfSubmitters = self._tabCtrl.newTab("conf_submitters", \
5102 _("Pending Conference Submitters"),str(url))
5103 url.addParam("tab", "conf_managers")
5104 self._tabConfManagers = self._tabCtrl.newTab("conf_managers", \
5105 _("Pending Conference Managers"),str(url))
5106 url.addParam("tab", "submitters")
5107 self._tabSubmitters = self._tabCtrl.newTab("submitters", \
5108 _("Pending Contribution Submitters"),str(url))
5109 url.addParam("tab", "managers")
5110 self._tabManagers = self._tabCtrl.newTab("managers", \
5111 _("Pending Managers"),str(url))
5112 url.addParam("tab", "coordinators")
5113 self._tabCoordinators = self._tabCtrl.newTab("coordinators", \
5114 _("Pending Coordinators"),str(url))
5115 self._tabSubmitters.setEnabled(True)
5116 tab = self._tabCtrl.getTabById(self._activeTab)
5117 if tab is None:
5118 tab = self._tabCtrl.getTabById("conf_submitters")
5119 tab.setActive()
5121 def getVars(self):
5122 vars = wcomponents.WTemplated.getVars(self)
5123 self._createTabCtrl()
5124 list = []
5125 url = ""
5126 title = ""
5128 if self._tabConfSubmitters.isActive():
5129 # Pending conference submitters
5130 keys = self._conf.getPendingQueuesMgr().getPendingConfSubmittersKeys(True)
5132 url = urlHandlers.UHConfModifPendingQueuesActionConfSubm.getURL(self._conf)
5133 url.addParam("tab","conf_submitters")
5134 title = _("Pending chairpersons/speakers to become submitters")
5135 target = _("Conference")
5136 pType = "ConfSubmitters"
5138 for key in keys:
5139 list.append((key, self._pendingConfSubmitters[key][:]))
5141 elif self._tabConfManagers.isActive():
5142 # Pending conference managers
5143 keys = self._conf.getPendingQueuesMgr().getPendingConfManagersKeys(True)
5145 url = urlHandlers.UHConfModifPendingQueuesActionConfMgr.getURL(self._conf)
5146 url.addParam("tab","conf_managers")
5147 title = _("Pending chairpersons to become managers")
5148 target = _("Conference")
5149 pType = "ConfManagers"
5151 for key in keys:
5152 list.append((key, self._pendingConfManagers[key][:]))
5154 elif self._tabSubmitters.isActive():
5155 # Pending submitters
5156 keys = self._conf.getPendingQueuesMgr().getPendingSubmittersKeys(True)
5158 url = urlHandlers.UHConfModifPendingQueuesActionSubm.getURL(self._conf)
5159 url.addParam("tab", "submitters")
5160 title = _("Pending authors/speakers to become submitters")
5161 target = _("Contribution")
5162 pType = "Submitters"
5164 for key in keys:
5165 list.append((key, self._pendingSubmitters[key][:]))
5167 elif self._tabManagers.isActive():
5168 # Pending managers
5169 keys = self._conf.getPendingQueuesMgr().getPendingManagersKeys(True)
5171 url = urlHandlers.UHConfModifPendingQueuesActionMgr.getURL(self._conf)
5172 url.addParam("tab", "managers")
5173 title = _("Pending conveners to become managers")
5174 target = _("Session")
5175 pType = "Managers"
5177 for key in keys:
5178 list.append((key, self._pendingManagers[key][:]))
5179 #list.sort(conference.SessionChair._cmpFamilyName)
5181 elif self._tabCoordinators.isActive():
5182 # Pending coordinators
5183 keys = self._conf.getPendingQueuesMgr().getPendingCoordinatorsKeys(True)
5185 url = urlHandlers.UHConfModifPendingQueuesActionCoord.getURL(self._conf)
5186 url.addParam("tab", "coordinators")
5187 title = _("Pending conveners to become coordinators")
5188 target = _("Session")
5189 pType = "Coordinators"
5191 for key in keys:
5192 list.append((key, self._pendingCoordinators[key][:]))
5193 list.sort(conference.ConferenceParticipation._cmpFamilyName)
5195 html = WConfModifPendingQueuesList(str(url), title, target, list, pType).getHTML()
5196 vars["pendingQueue"] = wcomponents.WTabControl(self._tabCtrl, self._aw).getHTML(html)
5198 return vars
5201 class WPConfModifPendingQueuesBase(WPConfModifListings):
5203 def __init__(self, rh, conf, activeTab=""):
5204 WPConfModifListings.__init__(self, rh, conf)
5205 self._activeTab = activeTab
5207 def _setActiveSideMenuItem(self):
5208 self._listingsMenuItem.setActive(True)
5211 class WPConfModifPendingQueues(WPConfModifPendingQueuesBase):
5213 def _getTabContent(self, params):
5214 wc = WConfModifPendingQueues(self._conf, self._getAW(), self._activeTab)
5215 return wc.getHTML()
5218 class WPConfModifPendingQueuesRemoveConfMgrConfirm(WPConfModifPendingQueuesBase):
5220 def __init__(self, rh, conf, pendingConfMgrs):
5221 WPConfModifPendingQueuesBase.__init__(self, rh, conf)
5222 self._pendingConfMgrs = pendingConfMgrs
5224 def _getTabContent(self,params):
5225 wc = wcomponents.WConfirmation()
5226 psubs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingConfMgrs))
5228 msg = {'challenge': _("Are you sure you want to delete the following users pending to become conference managers?"),
5229 'target': "<ul>{0}</ul>".format(psubs),
5230 'subtext': _("Please note that they will still remain as user"),
5233 url = urlHandlers.UHConfModifPendingQueuesActionConfMgr.getURL(self._conf)
5234 return wc.getHTML(msg,url,{"pendingUsers":self._pendingConfMgrs, "remove": _("remove")})
5237 class WPConfModifPendingQueuesReminderConfMgrConfirm(WPConfModifPendingQueuesBase):
5239 def __init__(self, rh, conf, pendingConfMgrs):
5240 WPConfModifPendingQueuesBase.__init__(self, rh, conf)
5241 self._pendingConfMgrs = pendingConfMgrs
5243 def _getTabContent(self,params):
5244 wc = wcomponents.WConfirmation()
5245 psubs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingConfMgrs))
5247 msg = {'challenge': _("Are you sure that you want to send these users an email with a reminder to create an account in Indico?"),
5248 'target': "<ul>{0}</ul>".format(psubs)
5250 url = urlHandlers.UHConfModifPendingQueuesActionConfMgr.getURL(self._conf)
5251 return wc.getHTML(
5252 msg,
5253 url, {
5254 "pendingUsers": self._pendingConfMgrs,
5255 "reminder": _("reminder")
5257 severity='accept')
5260 class WPConfModifPendingQueuesRemoveConfSubmConfirm(WPConfModifPendingQueuesBase):
5262 def __init__(self, rh, conf, pendingConfSubms):
5263 WPConfModifPendingQueuesBase.__init__(self, rh, conf)
5264 self._pendingConfSubms = pendingConfSubms
5266 def _getTabContent(self,params):
5267 wc = wcomponents.WConfirmation()
5268 psubs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingConfSubms))
5270 msg = {'challenge': _("Are you sure you want to delete the following users pending to become submitters?"),
5271 'target': "<ul>{0}</ul>".format(psubs),
5272 'subtext': _("Please note that they will still remain as user"),
5275 url = urlHandlers.UHConfModifPendingQueuesActionConfSubm.getURL(self._conf)
5276 return wc.getHTML(msg,url,{"pendingUsers":self._pendingConfSubms, "remove": _("remove")})
5278 class WPConfModifPendingQueuesReminderConfSubmConfirm(WPConfModifPendingQueuesBase):
5280 def __init__(self, rh, conf, pendingConfSubms):
5281 WPConfModifPendingQueuesBase.__init__(self, rh, conf)
5282 self._pendingConfSubms = pendingConfSubms
5284 def _getTabContent(self,params):
5285 wc = wcomponents.WConfirmation()
5286 psubs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingConfSubms))
5288 msg = {'challenge': _("Are you sure that you want to send these users an email with a reminder to create an account in Indico?"),
5289 'target': "<ul>{0}</ul>".format(psubs)
5291 url = urlHandlers.UHConfModifPendingQueuesActionConfSubm.getURL(self._conf)
5292 return wc.getHTML(
5293 msg,
5294 url, {
5295 "pendingUsers": self._pendingConfSubms,
5296 "reminder": _("reminder")
5298 severity='accept')
5300 class WPConfModifPendingQueuesRemoveSubmConfirm(WPConfModifPendingQueuesBase):
5302 def __init__(self, rh, conf, pendingSubms):
5303 WPConfModifPendingQueuesBase.__init__(self, rh, conf)
5304 self._pendingSubms = pendingSubms
5306 def _getTabContent(self, params):
5307 wc = wcomponents.WConfirmation()
5308 psubs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingSubms))
5310 msg = {'challenge': _("Are you sure you want to delete the following participants pending to become submitters?"),
5311 'target': "<ul>{0}</ul>".format(psubs),
5312 'subtext': _("Please note that they will still remain as participants"),
5315 url = urlHandlers.UHConfModifPendingQueuesActionSubm.getURL(self._conf)
5316 return wc.getHTML(msg, url, {"pendingUsers": self._pendingSubms, "remove": _("remove")})
5319 class WPConfModifPendingQueuesReminderSubmConfirm( WPConfModifPendingQueuesBase ):
5321 def __init__(self,rh, conf, pendingSubms):
5322 WPConfModifPendingQueuesBase.__init__(self,rh,conf)
5323 self._pendingSubms = pendingSubms
5325 def _getTabContent(self,params):
5326 wc = wcomponents.WConfirmation()
5328 psubs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingSubms))
5330 msg = {'challenge': _("Are you sure that you want to send these users an email with a reminder to create an account in Indico?"),
5331 'target': "<ul>{0}</ul>".format(psubs)
5334 url = urlHandlers.UHConfModifPendingQueuesActionSubm.getURL(self._conf)
5335 return wc.getHTML(
5336 msg,
5337 url, {
5338 "pendingUsers": self._pendingSubms,
5339 "reminder": _("reminder")
5341 severity='accept')
5343 class WPConfModifPendingQueuesRemoveMgrConfirm( WPConfModifPendingQueuesBase ):
5345 def __init__(self,rh, conf, pendingMgrs):
5346 WPConfModifPendingQueuesBase.__init__(self,rh,conf)
5347 self._pendingMgrs = pendingMgrs
5349 def _getTabContent(self,params):
5350 wc = wcomponents.WConfirmation()
5352 pmgrs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingMgrs))
5354 msg = {'challenge': _("Are you sure you want to delete the following conveners pending to become managers?"),
5355 'target': "<ul>{0}</ul>".format(pmgrs),
5356 'subtext': _("Please note that they will still remain as conveners")
5359 url = urlHandlers.UHConfModifPendingQueuesActionMgr.getURL(self._conf)
5360 return wc.getHTML(msg,url,{"pendingUsers":self._pendingMgrs, "remove": _("remove")})
5362 class WPConfModifPendingQueuesReminderMgrConfirm( WPConfModifPendingQueuesBase ):
5364 def __init__(self,rh, conf, pendingMgrs):
5365 WPConfModifPendingQueuesBase.__init__(self,rh,conf)
5366 self._pendingMgrs = pendingMgrs
5368 def _getTabContent(self,params):
5369 wc = wcomponents.WConfirmation()
5371 pmgrs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingMgrs))
5373 msg = {'challenge': _("Are you sure that you want to send these users an email with a reminder to create an account in Indico?"),
5374 'target': "<ul>{0}</ul>".format(pmgrs)
5377 url = urlHandlers.UHConfModifPendingQueuesActionMgr.getURL(self._conf)
5378 return wc.getHTML(msg,url,{"pendingUsers":self._pendingMgrs, "reminder": _("reminder")})
5380 class WPConfModifPendingQueuesRemoveCoordConfirm( WPConfModifPendingQueuesBase ):
5382 def __init__(self,rh, conf, pendingCoords):
5383 WPConfModifPendingQueuesBase.__init__(self,rh,conf)
5384 self._pendingCoords = pendingCoords
5386 def _getTabContent(self,params):
5387 wc = wcomponents.WConfirmation()
5389 pcoords = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingMgrs))
5391 msg = {'challenge': _("Are you sure you want to delete the following conveners pending to become coordinators?"),
5392 'target': "<ul>{0}</ul>".format(pcoords),
5393 'subtext': _("Please note that they will still remain as conveners")
5396 url = urlHandlers.UHConfModifPendingQueuesActionCoord.getURL(self._conf)
5397 return wc.getHTML(msg, url,{
5398 "pendingUsers": self._pendingCoords,
5399 "remove": _("remove")
5402 class WPConfModifPendingQueuesReminderCoordConfirm( WPConfModifPendingQueuesBase ):
5404 def __init__(self,rh, conf, pendingCoords):
5405 WPConfModifPendingQueuesBase.__init__(self,rh,conf)
5406 self._pendingCoords = pendingCoords
5408 def _getTabContent(self,params):
5409 wc = wcomponents.WConfirmation()
5411 pcoords = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingMgrs))
5413 msg = {'challenge': _("Are you sure that you want to send these users an email with a reminder to create an account in Indico?"),
5414 'target': "<ul>{0}</ul>".format(pcoords)
5417 url = urlHandlers.UHConfModifPendingQueuesActionCoord.getURL(self._conf)
5418 return wc.getHTML(
5419 msg, url, {
5420 "pendingUsers": self._pendingCoords,
5421 "reminder": _("reminder")
5425 class WConfModifReschedule(wcomponents.WTemplated):
5427 def __init__(self, targetDay):
5428 self._targetDay = targetDay
5430 def getVars(self):
5431 vars = wcomponents.WTemplated.getVars(self)
5432 vars["targetDay"]=quoteattr(str(self._targetDay))
5433 return vars
5435 class WPConfModifReschedule(WPConferenceModifBase):
5437 def __init__(self, rh, conf, targetDay):
5438 WPConferenceModifBase.__init__(self, rh, conf)
5439 self._targetDay=targetDay
5441 def _getPageContent( self, params):
5442 wc=WConfModifReschedule(self._targetDay)
5443 p={"postURL":quoteattr(str(urlHandlers.UHConfModifReschedule.getURL(self._conf)))}
5444 return wc.getHTML(p)
5447 # ============================================================================
5448 # === Badges related =========================================================
5449 # ============================================================================
5451 ##------------------------------------------------------------------------------------------------------------
5453 Badge Printing classes
5455 class WConfModifBadgePrinting(wcomponents.WTemplated):
5456 """ This class corresponds to the screen where badge templates are
5457 listed and can be created, edited, deleted, and tried.
5460 def __init__(self, conference, user=None):
5461 self.__conf = conference
5462 self._user = user
5464 def _getBaseTemplateOptions(self):
5465 dconf = conference.CategoryManager().getDefaultConference()
5466 templates = dconf.getBadgeTemplateManager().getTemplates()
5468 options = [{'value': 'blank', 'label': _('Blank Page')}]
5470 for id, template in templates.iteritems():
5471 options.append({'value': id, 'label': template.getName()})
5473 return options
5475 def getVars(self):
5476 uh = urlHandlers
5477 templates = []
5478 sortedTemplates = self.__conf.getBadgeTemplateManager().getTemplates().items()
5479 sortedTemplates.sort(lambda x, y: cmp(x[1].getName(), y[1].getName()))
5481 for templateId, template in sortedTemplates:
5483 data = {
5484 'id': templateId,
5485 'name': template.getName(),
5486 'urlEdit': str(uh.UHConfModifBadgeDesign.getURL(self.__conf, templateId)),
5487 'urlDelete': str(uh.UHConfModifBadgePrinting.getURL(self.__conf, deleteTemplateId=templateId)),
5488 'urlCopy': str(uh.UHConfModifBadgePrinting.getURL(self.__conf, copyTemplateId=templateId))
5491 templates.append(data)
5493 wcPDFOptions = WConfModifBadgePDFOptions(self.__conf)
5494 vars = wcomponents.WTemplated.getVars(self)
5495 vars['NewTemplateURL'] = str(uh.UHConfModifBadgeDesign.getURL(self.__conf,
5496 self.__conf.getBadgeTemplateManager().getNewTemplateId(),new = True))
5497 vars['CreatePDFURL'] = str(uh.UHConfModifBadgePrintingPDF.getURL(self.__conf))
5498 vars['templateList'] = templates
5499 vars['PDFOptions'] = wcPDFOptions.getHTML()
5500 vars['baseTemplates'] = self._getBaseTemplateOptions()
5502 return vars
5505 class WConfModifBadgePDFOptions(wcomponents.WTemplated):
5507 def __init__(self, conference, showKeepValues=True, showTip=True):
5508 self.__conf = conference
5509 self.__showKeepValues = showKeepValues
5510 self.__showTip = showTip
5512 def getVars(self):
5513 vars = wcomponents.WTemplated.getVars(self)
5515 pagesizeNames = PDFSizes().PDFpagesizes.keys()
5516 pagesizeNames.sort()
5517 vars['PagesizeNames'] = pagesizeNames
5518 vars['PDFOptions'] = self.__conf.getBadgeTemplateManager().getPDFOptions()
5519 vars['ShowKeepValues'] = self.__showKeepValues
5520 vars['ShowTip'] = self.__showTip
5522 return vars
5525 class WPBadgeBase(WPConfModifToolsBase):
5527 def getCSSFiles(self):
5528 return WPConfModifToolsBase.getCSSFiles(self) + self._asset_env['indico_badges_css'].urls()
5530 def getJSFiles(self):
5531 return WPConfModifToolsBase.getJSFiles(self) + self._includeJSPackage('badges_js')
5534 class WPConfModifBadgePrinting(WPBadgeBase):
5536 def _setActiveTab(self):
5537 self._tabBadges.setActive()
5539 def _getTabContent(self, params):
5540 wc = WConfModifBadgePrinting(self._conf)
5541 return wc.getHTML()
5545 ##------------------------------------------------------------------------------------------------------------
5547 Badge Design classes
5549 class WConfModifBadgeDesign(wcomponents.WTemplated):
5550 """ This class corresponds to the screen where a template
5551 is designed inserting, dragging and editing items.
5554 def __init__(self, conference, templateId, new=False, user=None):
5555 self.__conf = conference
5556 self.__templateId = templateId
5557 self.__new = new
5558 self._user = user
5560 def getVars( self ):
5561 vars = wcomponents.WTemplated.getVars( self )
5562 vars["baseURL"] = Config.getInstance().getBaseURL() ##base url of the application, used for the ruler images
5563 vars["cancelURL"] = urlHandlers.UHConfModifBadgePrinting.getURL(self.__conf, templateId = self.__templateId, cancel = True)
5564 vars["saveBackgroundURL"] = urlHandlers.UHConfModifBadgeSaveBackground.getURL(self.__conf, self.__templateId)
5565 vars["loadingIconURL"] = quoteattr(str(Config.getInstance().getSystemIconURL("loading")))
5566 vars["templateId"] = self.__templateId
5568 badgeDesignConfiguration = BadgeDesignConfiguration()
5569 from MaKaC.services.interface.rpc.json import encode as jsonEncode
5570 vars["translateName"]= jsonEncode(dict([(key, value[0]) for key, value in badgeDesignConfiguration.items_actions.iteritems()]))
5572 cases = []
5573 for itemKey in badgeDesignConfiguration.items_actions.keys():
5574 case = []
5575 case.append('case "')
5576 case.append(itemKey)
5577 case.append('":')
5578 case.append('\n')
5579 case.append('items[itemId] = new Item(itemId, "')
5580 case.append(itemKey)
5581 case.append('");')
5582 case.append('\n')
5583 case.append('newDiv.html(items[itemId].toHTML());')
5584 case.append('\n')
5585 case.append('break;')
5586 cases.append("".join(case))
5588 vars['switchCases'] = "\n".join(cases)
5590 optgroups = []
5591 for optgroupName, options in badgeDesignConfiguration.groups:
5592 optgroup = []
5593 optgroup.append('<optgroup label="')
5594 optgroup.append(optgroupName)
5595 optgroup.append('">')
5596 optgroup.append('\n')
5597 for optionName in options:
5598 optgroup.append('<option value="%s">'%optionName)
5599 optgroup.append(badgeDesignConfiguration.items_actions[optionName][0])
5600 optgroup.append('</option>')
5601 optgroup.append('\n')
5602 optgroup.append('</optgroup>')
5603 optgroups.append("".join(optgroup))
5605 vars['selectOptions'] = "\n".join(optgroups)
5606 vars["backgroundPos"] = "Stretch"
5608 if self.__new:
5609 vars["saveTemplateURL"]=urlHandlers.UHConfModifBadgePrinting.getURL(self.__conf, new=True)
5610 vars["titleMessage"]= _("Creating new badge template")
5611 vars["editingTemplate"]="false"
5612 vars["templateData"]="[]"
5613 vars["hasBackground"]="false"
5614 vars["backgroundURL"]="false"
5615 vars["backgroundId"]=-1
5617 elif self.__templateId is None:
5618 vars["saveTemplateURL"]=urlHandlers.UHConfModifBadgePrinting.getURL(self.__conf)
5619 vars["titleMessage"]= _("No template id given")
5620 vars["editingTemplate"]="false"
5621 vars["templateData"]="[]"
5622 vars["hasBackground"]="false"
5623 vars["backgroundURL"]="false"
5624 vars["backgroundId"]=-1
5626 else:
5627 vars["saveTemplateURL"]=urlHandlers.UHConfModifBadgePrinting.getURL(self.__conf)
5628 vars["titleMessage"]= _("Editing badge template")
5629 vars["editingTemplate"]="true"
5631 templateDataString = jsonEncode(self.__conf.getBadgeTemplateManager().getTemplateData(self.__templateId))
5632 vars["templateData"]= templateDataString
5634 usedBackgroundId = self.__conf.getBadgeTemplateManager().getTemplateById(self.__templateId).getUsedBackgroundId()
5635 vars["backgroundId"] = usedBackgroundId
5636 if usedBackgroundId != -1:
5637 vars["hasBackground"]="true"
5638 vars["backgroundURL"]=str(urlHandlers.UHConfModifBadgeGetBackground.getURL(self.__conf, self.__templateId, usedBackgroundId))
5639 else:
5640 vars["hasBackground"]="false"
5641 vars["backgroundURL"]="false"
5644 return vars
5647 class WPConfModifBadgeDesign(WPBadgeBase):
5649 def __init__(self, rh, conf, templateId=None, new=False, baseTemplateId="blank"):
5650 WPBadgeBase.__init__(self, rh, conf)
5651 self.__templateId = templateId
5652 self.__new = new
5653 self.__baseTemplate = baseTemplateId
5655 if baseTemplateId != 'blank':
5656 dconf = conference.CategoryManager().getDefaultConference()
5657 templMan = conf.getBadgeTemplateManager()
5658 newId = templateId
5659 dconf.getBadgeTemplateManager().getTemplateById(baseTemplateId).clone(templMan, newId)
5660 # now, let's pretend nothing happened, and let the code
5661 # handle the template as if it existed before
5662 self.__new = False
5664 def _setActiveTab(self):
5665 self._tabBadges.setActive()
5667 def _getTabContent(self, params):
5668 wc = WConfModifBadgeDesign(self._conf, self.__templateId, self.__new)
5669 return wc.getHTML()
5671 ##------------------------------------------------------------------------------------------------------------
5673 Common PDF Options classes
5675 class WConfCommonPDFOptions( wcomponents.WTemplated ):
5676 """ This class corresponds to a section of options
5677 that are common to each PDF in Indico.
5680 def __init__( self, conference, user=None ):
5681 self.__conf = conference
5682 self._user=user
5684 def getVars(self):
5685 vars = wcomponents.WTemplated.getVars( self )
5687 pagesizeNames = PDFSizes().PDFpagesizes.keys()
5688 pagesizeNames.sort()
5689 pagesizeOptions = []
5690 for pagesizeName in pagesizeNames:
5691 pagesizeOptions.append('<option ')
5692 if pagesizeName == 'A4':
5693 pagesizeOptions.append('selected="selected"')
5694 pagesizeOptions.append('>')
5695 pagesizeOptions.append(pagesizeName)
5696 pagesizeOptions.append('</option>')
5698 vars['pagesizes'] = "".join(pagesizeOptions)
5700 fontsizeOptions = []
5701 for fontsizeName in PDFSizes().PDFfontsizes:
5702 fontsizeOptions.append('<option ')
5703 if fontsizeName == 'normal':
5704 fontsizeOptions.append('selected="selected"')
5705 fontsizeOptions.append('>')
5706 fontsizeOptions.append(fontsizeName)
5707 fontsizeOptions.append('</option>')
5709 vars['fontsizes'] = "".join(fontsizeOptions)
5711 return vars
5714 # ============================================================================
5715 # === Posters related ========================================================
5716 # ============================================================================
5718 ##------------------------------------------------------------------------------------------------------------
5720 Poster Printing classes
5722 class WConfModifPosterPrinting(wcomponents.WTemplated):
5723 """ This class corresponds to the screen where poster templates are
5724 listed and can be created, edited, deleted, and tried.
5727 def __init__(self, conference, user=None):
5728 self.__conf = conference
5729 self._user = user
5731 def _getFullTemplateListOptions(self):
5732 templates = {}
5733 templates['global'] = conference.CategoryManager().getDefaultConference().getPosterTemplateManager().getTemplates()
5734 templates['local'] = self.__conf.getPosterTemplateManager().getTemplates()
5735 options = []
5737 def _iterTemplatesToObjectList(key, templates):
5738 newList = []
5740 for id, template in templates.iteritems():
5741 pKey = ' (' + key + ')'
5742 # Only if the template is 'global' should it have the word prefixed.
5743 value = key + str(id) if key == 'global' else str(id)
5744 newList.append({'value': value,
5745 'label': template.getName() + pKey})
5747 return newList
5749 for k, v in templates.iteritems():
5750 options.extend(_iterTemplatesToObjectList(k, v))
5752 return options
5754 def _getBaseTemplateListOptions(self):
5755 templates = conference.CategoryManager().getDefaultConference().getPosterTemplateManager().getTemplates()
5756 options = [{'value': 'blank', 'label': _('Blank Page')}]
5758 for id, template in templates.iteritems():
5759 options.append({'value': id, 'label': template.getName()})
5761 return options
5763 def getVars(self):
5764 uh = urlHandlers
5765 templates = []
5766 wcPDFOptions = WConfModifPosterPDFOptions(self.__conf)
5767 sortedTemplates = self.__conf.getPosterTemplateManager().getTemplates().items()
5768 sortedTemplates.sort(lambda item1, item2: cmp(item1[1].getName(), item2[1].getName()))
5770 for templateId, template in sortedTemplates:
5772 data = {
5773 'id': templateId,
5774 'name': template.getName(),
5775 'urlEdit': str(uh.UHConfModifPosterDesign.getURL(self.__conf, templateId)),
5776 'urlDelete': str(uh.UHConfModifPosterPrinting.getURL(self.__conf, deleteTemplateId=templateId)),
5777 'urlCopy': str(uh.UHConfModifPosterPrinting.getURL(self.__conf, copyTemplateId=templateId))
5780 templates.append(data)
5782 vars = wcomponents.WTemplated.getVars(self)
5783 vars["NewTemplateURL"] = str(uh.UHConfModifPosterDesign.getURL(self.__conf, self.__conf.getPosterTemplateManager().getNewTemplateId(),new=True))
5784 vars["CreatePDFURL"]= str(uh.UHConfModifPosterPrintingPDF.getURL(self.__conf))
5785 vars["templateList"] = templates
5786 vars['PDFOptions'] = wcPDFOptions.getHTML()
5787 vars['baseTemplates'] = self._getBaseTemplateListOptions()
5788 vars['fullTemplateList'] = self._getFullTemplateListOptions()
5790 return vars
5792 class WConfModifPosterPDFOptions(wcomponents.WTemplated):
5794 def __init__(self, conference, user=None):
5795 self.__conf = conference
5796 self._user= user
5798 def getVars(self):
5799 vars = wcomponents.WTemplated.getVars(self)
5801 pagesizeNames = PDFSizes().PDFpagesizes.keys()
5802 pagesizeNames.sort()
5803 pagesizeOptions = []
5805 for pagesizeName in pagesizeNames:
5806 pagesizeOptions.append('<option ')
5808 if pagesizeName == 'A4':
5809 pagesizeOptions.append('selected="selected"')
5811 pagesizeOptions.append('>')
5812 pagesizeOptions.append(pagesizeName)
5813 pagesizeOptions.append('</option>')
5815 vars['pagesizes'] = "".join(pagesizeOptions)
5817 return vars
5819 class WPConfModifPosterPrinting(WPBadgeBase):
5821 def _setActiveTab(self):
5822 self._tabPosters.setActive()
5824 def _getTabContent(self, params):
5825 wc = WConfModifPosterPrinting(self._conf)
5826 return wc.getHTML()
5828 ##------------------------------------------------------------------------------------------------------------
5830 Poster Design classes
5832 class WConfModifPosterDesign( wcomponents.WTemplated ):
5833 """ This class corresponds to the screen where a template
5834 is designed inserting, dragging and editing items.
5837 def __init__(self, conference, templateId, new=False, user=None):
5838 self.__conf = conference
5839 self.__templateId = templateId
5840 self.__new = new
5841 self._user = user
5844 def getVars(self):
5845 vars = wcomponents.WTemplated.getVars( self )
5846 vars["baseURL"] = Config.getInstance().getBaseURL() # base url of the application, used for the ruler images
5847 vars["cancelURL"] = urlHandlers.UHConfModifPosterPrinting.getURL(self.__conf, templateId = self.__templateId, cancel = True)
5848 vars["saveBackgroundURL"] = urlHandlers.UHConfModifPosterSaveBackground.getURL(self.__conf, self.__templateId)
5849 vars["loadingIconURL"] = quoteattr(str(Config.getInstance().getSystemIconURL("loading")))
5850 vars["templateId"] = self.__templateId
5852 posterDesignConfiguration = PosterDesignConfiguration()
5853 from MaKaC.services.interface.rpc.json import encode as jsonEncode
5854 vars["translateName"]= jsonEncode(dict([(key, value[0]) for key, value in posterDesignConfiguration.items_actions.iteritems()]))
5856 cases = []
5857 for itemKey in posterDesignConfiguration.items_actions.keys():
5858 case = []
5859 case.append('case "')
5860 case.append(itemKey)
5861 case.append('":')
5862 case.append('\n')
5863 case.append('items[itemId] = new Item(itemId, "')
5864 case.append(itemKey)
5865 case.append('");')
5866 case.append('\n')
5867 case.append('newDiv.html(items[itemId].toHTML());')
5868 case.append('\n')
5869 case.append('break;')
5870 cases.append("".join(case))
5872 vars['switchCases'] = "\n".join(cases)
5874 optgroups = []
5875 for optgroupName, options in posterDesignConfiguration.groups:
5876 optgroup = []
5877 optgroup.append('<optgroup label="')
5878 optgroup.append(optgroupName)
5879 optgroup.append('">')
5880 optgroup.append('\n')
5881 for optionName in options:
5882 optgroup.append('<option value="%s">'%optionName)
5883 optgroup.append(posterDesignConfiguration.items_actions[optionName][0])
5884 optgroup.append('</option>')
5885 optgroup.append('\n')
5886 optgroup.append('</optgroup>')
5887 optgroups.append("".join(optgroup))
5889 vars['selectOptions'] = "\n".join(optgroups)
5891 if self.__new:
5892 vars["saveTemplateURL"]=urlHandlers.UHConfModifPosterPrinting.getURL(self.__conf, new=True)
5893 vars["titleMessage"]= _("Creating new poster template")
5894 vars["hasBackground"]="false"
5895 vars["backgroundURL"]="false"
5896 vars["backgroundId"]=-1
5897 vars["backgroundPos"]="Stretch"
5898 vars["templateData"]="[]"
5899 vars["editingTemplate"]="false"
5902 elif self.__templateId is None:
5903 vars["saveTemplateURL"]=urlHandlers.UHConfModifPosterPrinting.getURL(self.__conf)
5904 vars["titleMessage"]= _("No template id given")
5905 vars["hasBackground"]="false"
5906 vars["backgroundURL"]="false"
5907 vars["backgroundId"]=-1
5908 vars["backgroundPos"]="Stretch"
5909 vars["templateData"] = "[]"
5910 vars["editingTemplate"]="false"
5913 else:
5914 vars["saveTemplateURL"]=urlHandlers.UHConfModifPosterPrinting.getURL(self.__conf)
5915 vars["titleMessage"]= _("Editing poster template")
5916 vars["editingTemplate"]="true"
5917 templateDataString = jsonEncode(self.__conf.getPosterTemplateManager().getTemplateData(self.__templateId))
5918 vars["templateData"]= templateDataString
5920 usedBackgroundId = self.__conf.getPosterTemplateManager().getTemplateById(self.__templateId).getUsedBackgroundId()
5921 vars["backgroundId"] = usedBackgroundId
5923 if usedBackgroundId != -1:
5924 vars["hasBackground"]="true"
5925 vars["backgroundURL"]=str(urlHandlers.UHConfModifPosterGetBackground.getURL(self.__conf, self.__templateId, usedBackgroundId))
5926 vars["backgroundPos"]=self.__conf.getPosterTemplateManager().getTemplateById(self.__templateId).getBackgroundPosition(usedBackgroundId)
5927 else:
5928 vars["hasBackground"]="false"
5929 vars["backgroundURL"]="false"
5930 vars["backgroundPos"]="Stretch"
5932 return vars
5935 class WPConfModifPosterDesign(WPBadgeBase):
5937 def __init__(self, rh, conf, templateId=None, new=False, baseTemplateId="blank"):
5938 WPBadgeBase.__init__(self, rh, conf)
5939 self.__templateId = templateId
5940 self.__new = new
5941 self.__baseTemplate = baseTemplateId
5943 def _setActiveTab(self):
5944 self._tabPosters.setActive()
5946 def _getTabContent(self, params):
5947 wc = WConfModifPosterDesign(self._conf, self.__templateId, self.__new)
5948 return wc.getHTML()
5950 def sortByName(x,y):
5951 return cmp(x.getFamilyName(),y.getFamilyName())
5953 class WPConfModifPreviewCSS( WPConferenceDefaultDisplayBase ):
5955 def __init__( self, rh, conf, selectedCSSId):
5956 WPConferenceDefaultDisplayBase.__init__( self, rh, conf )
5958 self._conf = conf
5959 self._cssTplsModule = ModuleHolder().getById("cssTpls")
5960 self._styleMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getStyleManager()
5962 self._selectedCSS = None
5963 if selectedCSSId == "css": # local uploaded file choice
5964 self._selectedCSS = self._styleMgr.getLocalCSS()
5965 elif selectedCSSId:
5966 self._selectedCSS = self._cssTplsModule.getCssTplById(selectedCSSId)
5968 def _applyDecoration( self, body ):
5971 return "%s%s%s"%( self._getHeader(), body, self._getFooter() )
5973 def _getBody( self, params ):
5974 params["URL2Back"] = urlHandlers.UHConfModifDisplay.getURL(self._conf)
5975 params["cssurl"] = ""
5976 params['selectedCSSId'] = ""
5977 if self._selectedCSS:
5978 params["cssurl"] = self._selectedCSS.getURL()
5979 params['selectedCSSId'] = self._selectedCSS.getId()
5980 elif self._styleMgr.getCSS():
5981 params["cssurl"] = self._styleMgr.getCSS().getURL()
5982 params['selectedCSSId'] = self._styleMgr.getCSS().getId()
5983 params["saveCSS"]=urlHandlers.UHUseCSS.getURL(self._conf)
5984 params['confId'] = self._conf.getId()
5985 params["previewURL"]= urlHandlers.UHConfModifPreviewCSS.getURL(self._conf)
5986 params["templatesList"]=[]
5987 if self._styleMgr.getLocalCSS():
5988 params["templatesList"].append(self._styleMgr.getLocalCSS())
5989 params["templatesList"].extend(self._cssTplsModule.getCssTplsList())
5991 ###############################
5992 # injecting ConferenceDisplay #
5993 ###############################
5994 p = WPConferenceDisplay( self._rh, self._conf )
5995 p._defineSectionMenu()
5996 params["bodyConf"] = p._applyConfDisplayDecoration(p._getBody(params))
5997 ###############################
5998 ###############################
6000 wc = WPreviewPage()
6001 return wc.getHTML(params)
6003 def _getHeadContent( self ):
6004 path = Config.getInstance().getCssBaseURL()
6005 try:
6006 timestamp = os.stat(__file__).st_mtime
6007 except OSError:
6008 timestamp = 0
6009 printCSS = """
6010 <link rel="stylesheet" type="text/css" href="%s/Conf_Basic.css?%d" >
6011 """ % (path, timestamp)
6013 if self._selectedCSS:
6014 printCSS = printCSS + """<link rel="stylesheet" type="text/css" href="%s" >"""%self._selectedCSS.getURL()
6015 elif self._styleMgr.getCSS():
6016 printCSS = printCSS + """<link rel="stylesheet" type="text/css" href="%s" >"""%self._styleMgr.getCSS().getURL()
6017 return printCSS
6020 class WPreviewPage( wcomponents.WTemplated ):
6021 pass