Add "material package" to the attachment module
[cds-indico.git] / indico / MaKaC / webinterface / pages / conferences.py
blobc25857c4094c744d24760a890cc9e8e528f31606
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 random
21 import re
22 import time
23 import urllib
25 from datetime import timedelta, datetime
26 from xml.sax.saxutils import quoteattr, escape
28 import MaKaC.webinterface.wcomponents as wcomponents
29 import MaKaC.webinterface.urlHandlers as urlHandlers
30 import MaKaC.webinterface.displayMgr as displayMgr
31 import MaKaC.webinterface.timetable as timetable
32 import MaKaC.webinterface.linking as linking
33 import MaKaC.webinterface.navigation as navigation
34 import MaKaC.schedule as schedule
35 import MaKaC.conference as conference
36 import MaKaC.webinterface.materialFactories as materialFactories
37 import MaKaC.common.filters as filters
38 from MaKaC.common.utils import isStringHTML
39 import MaKaC.common.utils
40 import MaKaC.review as review
41 from MaKaC.review import AbstractTextField
42 from MaKaC.webinterface.pages.base import WPDecorated
43 from MaKaC.webinterface.common.tools import strip_ml_tags, escape_html
44 from MaKaC.webinterface.materialFactories import ConfMFRegistry, PaperFactory, SlidesFactory, PosterFactory
45 from MaKaC.webinterface.common.abstractStatusWrapper import AbstractStatusList
46 from MaKaC.webinterface.common.contribStatusWrapper import ContribStatusList
47 from MaKaC.common.output import outputGenerator
48 from MaKaC.webinterface.general import strfFileSize
49 from MaKaC.webinterface.common.timezones import TimezoneRegistry
50 from MaKaC.PDFinterface.base import PDFSizes
51 from pytz import timezone
52 from MaKaC.common.timezoneUtils import nowutc, DisplayTZ
53 from MaKaC.conference import EventCloner
54 from MaKaC.badgeDesignConf import BadgeDesignConfiguration
55 from MaKaC.posterDesignConf import PosterDesignConfiguration
56 from MaKaC.webinterface.pages import main
57 from MaKaC.webinterface.pages import base
58 from MaKaC.webinterface.materialFactories import MaterialFactoryRegistry
59 import MaKaC.common.info as info
60 from MaKaC.i18n import _
61 from indico.util.i18n import i18nformat
62 from indico.util.date_time import format_time, format_date, format_datetime
63 from indico.util.string import safe_upper
64 from MaKaC.common.fossilize import fossilize
65 from MaKaC.fossils.conference import IConferenceEventInfoFossil
66 from MaKaC.common.Conversion import Conversion
67 from indico.modules import ModuleHolder
68 from indico.modules.auth.util import url_for_logout
69 from MaKaC.paperReviewing import ConferencePaperReview as CPR
70 from MaKaC.conference import Session, Contribution, LocalFile
71 from indico.core.config import Config
72 from MaKaC.common.utils import formatDateTime
73 from MaKaC.user import AvatarHolder
74 from MaKaC.webinterface.general import WebFactory
75 from MaKaC.common.TemplateExec import render
77 from indico.core import signals
78 from indico.modules.attachments.util import get_attached_items
79 from indico.util import json
80 from indico.util.signals import values_from_signal
81 from indico.web.flask.util import url_for
83 LECTURE_SERIES_RE = re.compile(r'^part\d+$')
86 def stringToDate(str):
88 # Don't delete this dictionary inside comment. Its purpose is to
89 # add the dictionary in the language dictionary during the extraction!
90 # months = { _("January"): 1, _("February"): 2, _("March"): 3, _("April"): 4,
91 # _("May"): 5, _("June"): 6, _("July"): 7, _("August"): 8,
92 # _("September"): 9, _("October"): 10, _("November"): 11, _("December"): 12 }
94 months = {
95 "January": 1,
96 "February": 2,
97 "March": 3,
98 "April": 4,
99 "May": 5,
100 "June": 6,
101 "July": 7,
102 "August": 8,
103 "September": 9,
104 "October": 10,
105 "November": 11,
106 "December": 12
108 [day, month, year] = str.split("-")
109 return datetime(int(year), months[month], int(day))
112 class WPConferenceBase(base.WPDecorated):
114 def __init__(self, rh, conference, **kwargs):
115 WPDecorated.__init__(self, rh, **kwargs)
116 self._navigationTarget = self._conf = conference
117 tz = self._tz = DisplayTZ(rh._aw, self._conf).getDisplayTZ()
118 sDate = self.sDate = self._conf.getAdjustedScreenStartDate(tz)
119 eDate = self.eDate = self._conf.getAdjustedScreenEndDate(tz)
120 dates = " (%s)" % format_date(sDate, format='long')
121 if sDate.strftime("%d%B%Y") != eDate.strftime("%d%B%Y"):
122 if sDate.strftime("%B%Y") == eDate.strftime("%B%Y"):
123 dates = " (%s-%s)" % (sDate.strftime("%d"), format_date(eDate, format='long'))
124 else:
125 dates = " (%s - %s)" % (format_date(sDate, format='long'), format_date(eDate, format='long'))
126 self._setTitle("%s %s" % (strip_ml_tags(self._conf.getTitle()), dates))
128 def _getFooter(self):
131 wc = wcomponents.WFooter()
133 p = {"modificationDate": format_datetime(self._conf.getModificationDate(), format='d MMMM yyyy H:mm'),
134 "subArea": self._getSiteArea()
136 return wc.getHTML(p)
138 def getLogoutURL(self):
139 return url_for_logout(str(urlHandlers.UHConferenceDisplay.getURL(self._conf)))
142 class WPConferenceDisplayBase(WPConferenceBase):
143 pass
146 class WPConferenceDefaultDisplayBase( WPConferenceBase):
147 navigationEntry = None
149 def getJSFiles(self):
150 return (WPConferenceBase.getJSFiles(self) + self._includeJSPackage('Display') +
151 self._includeJSPackage('MaterialEditor'))
153 def _getFooter( self ):
154 wc = wcomponents.WFooter()
155 p = {"modificationDate": format_datetime(self._conf.getModificationDate(), format='d MMMM yyyy H:mm'),
156 "subArea": self._getSiteArea()}
158 cid = self._conf.getUrlTag().strip() or self._conf.getId()
159 p["shortURL"] = Config.getInstance().getShortEventURL() + cid
161 return wc.getHTML(p)
163 def _getHeader( self ):
166 wc = wcomponents.WConferenceHeader( self._getAW(), self._conf )
167 return wc.getHTML( { "loginURL": self.getLoginURL(),\
168 "logoutURL": self.getLogoutURL(),\
169 "confId": self._conf.getId(), \
170 "dark": True} )
172 def _defineSectionMenu( self ):
174 awUser = self._getAW().getUser()
175 self._sectionMenu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
176 self._overviewOpt = self._sectionMenu.getLinkByName("overview")
177 self._programOpt = self._sectionMenu.getLinkByName("programme")
178 link = self._programOpt
179 self._cfaOpt = self._sectionMenu.getLinkByName("CFA")
180 self._cfaNewSubmissionOpt = self._sectionMenu.getLinkByName("SubmitAbstract")
181 self._cfaViewSubmissionsOpt = self._sectionMenu.getLinkByName("ViewAbstracts")
182 self._abstractsBookOpt = self._sectionMenu.getLinkByName("abstractsBook")
183 if not self._conf.getAbstractMgr().isActive() or not self._conf.hasEnabledSection("cfa"):
184 self._cfaOpt.setVisible(False)
185 self._abstractsBookOpt.setVisible(False)
186 else:
187 self._cfaOpt.setVisible(True)
188 self._abstractsBookOpt.setVisible(True)
189 self._trackMgtOpt = self._sectionMenu.getLinkByName("manageTrack")
191 #registration form
192 self._regFormOpt = self._sectionMenu.getLinkByName("registrationForm")
193 self._registrantsListOpt = self._sectionMenu.getLinkByName("registrants")
194 if not self._conf.getRegistrationForm().isActivated() or not self._conf.hasEnabledSection("regForm"):
195 self._regFormOpt.setVisible(False)
196 self._registrantsListOpt.setVisible(False)
197 else:
198 self._regFormOpt.setVisible(True)
199 self._registrantsListOpt.setVisible(True)
201 #evaluation
202 evaluation = self._conf.getEvaluation()
203 self._evaluationOpt = self._sectionMenu.getLinkByName("evaluation")
204 self._newEvaluationOpt = self._sectionMenu.getLinkByName("newEvaluation")
205 self._viewEvaluationOpt = self._sectionMenu.getLinkByName("viewMyEvaluation")
206 self._evaluationOpt.setVisible(self._conf.hasEnabledSection("evaluation") and evaluation.isVisible() and evaluation.getNbOfQuestions()>0)
207 if awUser!=None and awUser.hasSubmittedEvaluation(evaluation):
208 self._newEvaluationOpt.setVisible(not awUser.hasSubmittedEvaluation(evaluation))
209 self._viewEvaluationOpt.setVisible(awUser.hasSubmittedEvaluation(evaluation))
210 else:
211 self._newEvaluationOpt.setVisible(True)
212 self._viewEvaluationOpt.setVisible(False)
216 self._sectionMenu.setCurrentItem(None)
218 self._timetableOpt = self._sectionMenu.getLinkByName("timetable")
219 self._contribListOpt = self._sectionMenu.getLinkByName("contributionList")
220 self._authorIndexOpt = self._sectionMenu.getLinkByName("authorIndex")
221 self._speakerIndexOpt = self._sectionMenu.getLinkByName("speakerIndex")
222 self._myStuffOpt=self._sectionMenu.getLinkByName("mystuff")
223 self._myStuffOpt.setVisible(awUser is not None)
224 self._mySessionsOpt=self._sectionMenu.getLinkByName("mysessions")
225 ls = set(self._conf.getCoordinatedSessions(awUser)) | set(self._conf.getManagedSession(awUser))
226 self._mySessionsOpt.setVisible(len(ls)>0)
227 self._myTracksOpt=self._sectionMenu.getLinkByName("mytracks")
228 lt=self._conf.getCoordinatedTracks(awUser)
229 self._myTracksOpt.setVisible(len(lt)>0)
230 if not self._conf.getAbstractMgr().isActive():
231 self._myTracksOpt.setVisible(False)
232 self._myContribsOpt=self._sectionMenu.getLinkByName("mycontribs")
233 lc=self._conf.getContribsForSubmitter(awUser)
234 self._myContribsOpt.setVisible(len(lc)>0)
235 self._trackMgtOpt.setVisible(len(lt)>0)
236 if not self._conf.getAbstractMgr().isActive():
237 self._trackMgtOpt.setVisible(False)
239 #paper reviewing related
240 self._paperReviewingOpt = self._sectionMenu.getLinkByName("paperreviewing")
241 self._paperReviewingMgtOpt=self._sectionMenu.getLinkByName("managepaperreviewing")
242 self._paperReviewingMgtOpt.setVisible(False)
244 self._assignContribOpt=self._sectionMenu.getLinkByName("assigncontributions")
245 self._assignContribOpt.setVisible(False)
247 self._judgeListOpt=self._sectionMenu.getLinkByName("judgelist")
248 self._judgeListOpt.setVisible(False)
249 self._judgereviewerListOpt=self._sectionMenu.getLinkByName("judgelistreviewer")
251 self._judgereviewerListOpt.setVisible(False)
252 self._judgeeditorListOpt=self._sectionMenu.getLinkByName("judgelisteditor")
253 self._judgeeditorListOpt.setVisible(False)
255 self._uploadPaperOpt = self._sectionMenu.getLinkByName("uploadpaper")
256 self._downloadTemplateOpt = self._sectionMenu.getLinkByName("downloadtemplate")
258 if self._conf.getConfPaperReview().hasReviewing():
259 self._paperReviewingOpt.setVisible(True)
260 # These options are shown if there is any contribution of this user
261 self._uploadPaperOpt.setVisible(len(lc)>0)
262 self._downloadTemplateOpt.setVisible(len(lc)>0)
263 else:
264 self._paperReviewingOpt.setVisible(False)
265 self._uploadPaperOpt.setVisible(False)
266 self._downloadTemplateOpt.setVisible(False)
268 if awUser is not None:
269 conferenceRoles = awUser.user.get_linked_roles('conference')
271 if "paperReviewManager" in conferenceRoles:
272 if self._conf in awUser.user.get_linked_objects('conference', 'paperReviewManager'):
273 self._paperReviewingMgtOpt.setVisible(True)
274 self._assignContribOpt.setVisible(True)
275 self._uploadPaperOpt.setVisible(len(lc)>0)
276 self._downloadTemplateOpt.setVisible(True)
278 if "referee" in conferenceRoles and "editor" in conferenceRoles and "reviewer" in conferenceRoles:
279 showrefereearea = self._conf in awUser.user.get_linked_objects('conference', 'referee')
280 showreviewerarea = self._conf in awUser.user.get_linked_objects('conference', 'reviewer')
281 showeditorarea = self._conf in awUser.user.get_linked_objects('conference', 'editor')
283 if showrefereearea and (self._conf.getConfPaperReview().getChoice() == CPR.CONTENT_REVIEWING or self._conf.getConfPaperReview().getChoice() == CPR.CONTENT_AND_LAYOUT_REVIEWING):
284 self._assignContribOpt.setVisible(True)
285 self._judgeListOpt.setVisible(True)
287 if showreviewerarea and (self._conf.getConfPaperReview().getChoice() == CPR.CONTENT_REVIEWING or self._conf.getConfPaperReview().getChoice() == CPR.CONTENT_AND_LAYOUT_REVIEWING):
288 self._judgereviewerListOpt.setVisible(True)
290 if showeditorarea and (self._conf.getConfPaperReview().getChoice() == CPR.LAYOUT_REVIEWING or self._conf.getConfPaperReview().getChoice() == CPR.CONTENT_AND_LAYOUT_REVIEWING):
291 self._judgeeditorListOpt.setVisible(True)
293 for item in values_from_signal(signals.event.sidemenu.send()):
294 if item.visible is not None:
295 link = self._sectionMenu.getLinkByName(item.name)
296 link.setVisible(item.visible(self._conf))
298 def _defineToolBar(self):
299 pass
301 def _display( self, params ):
302 self._defineSectionMenu()
303 self._toolBar=wcomponents.WebToolBar()
304 self._defineToolBar()
305 return WPConferenceBase._display(self,params)
307 def _getNavigationBarHTML(self):
308 item=None
309 if self.navigationEntry:
310 item = self.navigationEntry()
311 itemList = []
312 while item is not None:
313 if itemList == []:
314 itemList.insert(0, wcomponents.WTemplated.htmlText(item.getTitle()) )
315 else:
316 itemList.insert(0, """<a href=%s>%s</a>"""%( quoteattr(str(item.getURL(self._navigationTarget))), wcomponents.WTemplated.htmlText(item.getTitle()) ) )
317 item = item.getParent(self._navigationTarget)
318 itemList.insert(0, i18nformat("""<a href=%s> _("Home")</a>""")%quoteattr(str(urlHandlers.UHConferenceDisplay.getURL(self._conf))) )
319 return " &gt; ".join(itemList)
321 def _getToolBarHTML(self):
322 drawer=wcomponents.WConfTBDrawer(self._toolBar)
323 return drawer.getHTML()
325 def _applyConfDisplayDecoration( self, body ):
326 drawer = wcomponents.WConfTickerTapeDrawer(self._conf, self._tz)
327 frame = WConfDisplayFrame( self._getAW(), self._conf )
329 frameParams = {
330 "confModifURL": urlHandlers.UHConferenceModification.getURL(self._conf),
331 "logoURL": urlHandlers.UHConferenceLogo.getURL(self._conf),
332 "currentURL": request.url,
333 "nowHappening": drawer.getNowHappeningHTML(),
334 "simpleTextAnnouncement": drawer.getSimpleText(),
336 if self._conf.getLogo():
337 frameParams["logoURL"] = urlHandlers.UHConferenceLogo.getURL(self._conf)
339 body = """
340 <div class="confBodyBox clearfix">
342 <div>
343 <div></div>
344 <div class="breadcrumps">%s</div>
345 <div style="float:right;">%s</div>
346 </div>
347 <!--Main body-->
348 <div class="mainContent">
349 <div class="col2">
351 </div>
352 </div>
353 </div>""" % (
354 self._getNavigationBarHTML(),
355 self._getToolBarHTML().strip(),
356 body)
357 return frame.getHTML( self._sectionMenu, body, frameParams)
359 def _getHeadContent(self):
360 dmgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf)
361 path = self._getBaseURL()
362 timestamp = os.stat(__file__).st_mtime
363 printCSS = """
364 <link rel="stylesheet" type="text/css" href="%s/css/Conf_Basic.css?%d" >
365 """ % (path, timestamp)
366 confCSS = dmgr.getStyleManager().getCSS()
368 if confCSS:
369 printCSS = printCSS + """<link rel="stylesheet" type="text/css" href="%s">""" % (confCSS.getURL())
371 # Include MathJax
373 return '\n'.join([
374 printCSS,
375 WConfMetadata(self._conf).getHTML(), # confMetadata
376 render('js/mathjax.config.js.tpl'), # mathJax
377 '\n'.join('<script src="{0}" type="text/javascript"></script>'.format(url)
378 for url in self._asset_env['mathjax_js'].urls())
381 return printCSS
383 def _applyDecoration( self, body ):
384 body = self._applyConfDisplayDecoration( body )
385 return WPConferenceBase._applyDecoration( self, body )
388 class WConfMetadata(wcomponents.WTemplated):
389 def __init__(self, conf):
390 self._conf = conf
392 def getVars(self):
393 v = wcomponents.WTemplated.getVars( self )
394 minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
396 v['site_name'] = minfo.getTitle()
397 v['fb_config'] = minfo.getSocialAppConfig().get('facebook', {})
399 if self._conf.getLogo():
400 v['image'] = urlHandlers.UHConferenceLogo.getURL(self._conf)
401 else:
402 v['image'] = Config.getInstance().getSystemIconURL("indico_co")
404 v['description'] = strip_ml_tags(self._conf.getDescription()[:500])
405 return v
408 class WConfDisplayFrame(wcomponents.WTemplated):
410 def __init__(self, aw, conf):
411 self._aw = aw
412 self._conf = conf
414 def getHTML( self, menu, body, params ):
415 self._body = body
416 self._menu = menu
417 return wcomponents.WTemplated.getHTML( self, params )
419 def getVars(self):
420 vars = wcomponents.WTemplated.getVars( self )
421 vars["logo"] = ""
422 if self._conf.getLogo():
423 vars["logo"] = "<img src=\"%s\" alt=\"%s\" border=\"0\" class=\"confLogo\" >"%(vars["logoURL"], escape_html(self._conf.getTitle(), escape_quotes = True))
424 vars["confTitle"] = self._conf.getTitle()
425 vars["displayURL"] = urlHandlers.UHConferenceDisplay.getURL(self._conf)
426 vars["imgConferenceRoom"] = Config.getInstance().getSystemIconURL( "conferenceRoom" )
427 tz = DisplayTZ(self._aw,self._conf).getDisplayTZ()
428 adjusted_sDate = self._conf.getAdjustedScreenStartDate(tz)
429 adjusted_eDate = self._conf.getAdjustedScreenEndDate(tz)
431 vars["timezone"] = tz
432 vars["confDateInterval"] = i18nformat("""_("from") %s _("to") %s""") % (
433 format_date(adjusted_sDate, format='long'), format_date(adjusted_eDate, format='long'))
434 if adjusted_sDate.strftime("%d%B%Y") == \
435 adjusted_eDate.strftime("%d%B%Y"):
436 vars["confDateInterval"] = format_date(adjusted_sDate, format='long')
437 elif adjusted_sDate.strftime("%B%Y") == adjusted_eDate.strftime("%B%Y"):
438 vars["confDateInterval"] = "%s-%s %s"%(adjusted_sDate.day, adjusted_eDate.day, format_date(adjusted_sDate, format='MMMM yyyy'))
439 vars["confLocation"] = ""
440 if self._conf.getLocationList():
441 vars["confLocation"] = self._conf.getLocationList()[0].getName()
442 vars["body"] = self._body
443 vars["supportEmail"] = ""
444 vars["supportTelephone"] = ""
446 sinfo = self._conf.getSupportInfo()
448 p = {"menu": self._menu,
449 "support_info": sinfo,
450 "event": self._conf}
451 vars["menu"] = WConfDisplayMenu(self._menu).getHTML(p)
453 dm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf, False)
454 format = dm.getFormat()
455 vars["bgColorCode"] = format.getFormatOption("titleBgColor")["code"].replace("#","")
456 vars["textColorCode"] = format.getFormatOption("titleTextColor")["code"].replace("#","")
458 vars["confId"] = self._conf.getId()
459 vars["dm"] = dm
460 vars["conf"] = self._conf
461 return vars
464 class WConfDisplayMenu(wcomponents.WTemplated):
466 def __init__(self, menu):
467 wcomponents.WTemplated.__init__(self)
468 self._menu = menu
471 class WConfDetailsBase( wcomponents.WTemplated ):
473 def __init__(self, aw, conf):
474 self._conf = conf
475 self._aw = aw
477 def getVars( self ):
478 vars = wcomponents.WTemplated.getVars( self )
479 tz = DisplayTZ(self._aw,self._conf).getDisplayTZ()
480 vars["timezone"] = tz
482 description = self._conf.getDescription()
483 vars["description_html"] = isStringHTML(description)
484 vars["description"] = description
486 sdate, edate = self._conf.getAdjustedScreenStartDate(tz), self._conf.getAdjustedScreenEndDate(tz)
487 fsdate, fedate = format_date(sdate, format='medium'), format_date(edate, format='medium')
488 fstime, fetime = sdate.strftime("%H:%M"), edate.strftime("%H:%M")
490 vars["dateInterval"] = (fsdate, fstime, fedate, fetime)
492 vars["location"] = None
493 vars["address"] = None
494 vars["room"] = None
496 location = self._conf.getLocation()
497 if location:
498 vars["location"] = location.getName()
499 vars["address"] = location.getAddress()
501 room = self._conf.getRoom()
502 if room and room.getName():
503 roomLink = linking.RoomLinker().getHTMLLink(room, location)
504 vars["room"] = roomLink
506 vars["chairs"] = self._conf.getChairList()
507 vars["attachments"] = self._conf.attached_items
508 vars["conf"] = self._conf
510 info = self._conf.getContactInfo()
511 vars["moreInfo_html"] = isStringHTML(info)
512 vars["moreInfo"] = info
513 vars["actions"] = ''
514 vars["isSubmitter"] = self._conf.getAccessController().canUserSubmit(self._aw.getUser()) or self._conf.canModify(self._aw)
516 regform = self._conf.getRegistrationForm()
517 if regform:
518 vars["registration_enabled"] = regform.isActivated()
519 vars["in_registration_period"] = regform.inRegistrationPeriod(nowutc())
520 vars["in_modification_period"] = regform.inModificationPeriod()
521 vars["registration_deadline"] = format_date(regform.getEndRegistrationDate())
522 vars["modification_deadline"] = format_date(regform.getModificationEndDate())
523 vars["ticket_enabled"] = regform.getETicket().isEnabled()
524 if session.avatar:
525 vars["registrant"] = session.avatar.getRegistrantById(self._conf.getId())
526 return vars
529 class WConfDetailsFull(WConfDetailsBase):
530 pass
533 #---------------------------------------------------------------------------
536 class WConfDetails:
538 def __init__(self, aw, conf):
539 self._conf = conf
540 self._aw = aw
542 def getHTML( self, params ):
543 return WConfDetailsFull( self._aw, self._conf ).getHTML( params )
546 class WPConferenceDisplay(WPConferenceDefaultDisplayBase):
548 def getCSSFiles(self):
549 return (WPConferenceDefaultDisplayBase.getCSSFiles(self)
550 + self._asset_env['eventservices_sass'].urls()
551 + self._asset_env['event_display_sass'].urls())
553 def _getBody(self, params):
555 wc = WConfDetails(self._getAW(), self._conf)
556 pars = {"modifyURL": urlHandlers.UHConferenceModification.getURL(self._conf),
557 "sessionModifyURLGen": urlHandlers.UHSessionModification.getURL,
558 "contribModifyURLGen": urlHandlers.UHContributionModification.getURL,
559 "subContribModifyURLGen": urlHandlers.UHSubContribModification.getURL,
560 "materialURLGen": urlHandlers.UHMaterialDisplay.getURL}
561 return wc.getHTML(pars)
563 def _getFooter(self):
564 wc = wcomponents.WEventFooter(self._conf)
565 return wc.getHTML()
567 def _defineSectionMenu(self):
568 WPConferenceDefaultDisplayBase._defineSectionMenu(self)
569 self._sectionMenu.setCurrentItem(self._overviewOpt)
571 class WSentMail (wcomponents.WTemplated):
572 def __init__(self,conf):
573 self._conf = conf
575 def getVars(self):
576 vars = wcomponents.WTemplated.getVars( self )
577 vars["BackURL"]=urlHandlers.UHConferenceDisplay.getURL(self._conf)
578 return vars
581 class WPSentEmail( WPConferenceDefaultDisplayBase ):
582 def _getBody(self,params):
583 wc = WSentMail(self._conf)
584 return wc.getHTML()
586 class WEmail(wcomponents.WTemplated):
588 def __init__(self,conf,user,toUsers):
589 self._conf = conf
590 self._from = user
591 self._to = toUsers
593 def getVars(self):
594 vars = wcomponents.WTemplated.getVars( self )
595 if vars.get("from", None) is None :
596 vars["FromName"] = self._from
597 vars["fromUser"] = self._from
598 vars["toUsers"] = self._to
599 if vars.get("postURL",None) is None :
600 vars["postURL"]=urlHandlers.UHConferenceSendEmail.getURL(self._to)
601 if vars.get("subject", None) is None :
602 vars["subject"]=""
603 if vars.get("body", None) is None :
604 vars["body"]=""
605 return vars
607 class WPEMail ( WPConferenceDefaultDisplayBase ):
609 def _getBody(self,params):
610 toemail = params["emailto"]
611 wc = WEmail(self._conf, self._getAW().getUser(), toemail)
612 params["fromDisabled"] = True
613 params["toDisabled"] = True
614 params["ccDisabled"] = True
615 return wc.getHTML(params)
617 class WPXSLConferenceDisplay(WPConferenceBase):
619 Use this class just to transform to XML
622 def __init__(self, rh, conference, view, type, params):
623 WPConferenceBase.__init__(self, rh, conference)
624 self._params = params
625 self._view = view
626 self._conf = conference
627 self._type = type
628 self._firstDay = params.get("firstDay")
629 self._lastDay = params.get("lastDay")
630 self._daysPerRow = params.get("daysPerRow")
632 def _getFooter(self):
635 return ""
637 def _getHTMLHeader(self):
638 return ""
640 def _applyDecoration(self, body):
643 return body
645 def _getHTMLFooter(self):
646 return ""
648 def _getBodyVariables(self):
649 pars = { \
650 "modifyURL": urlHandlers.UHConferenceModification.getURL( self._conf ), \
651 "iCalURL": urlHandlers.UHConferenceToiCal.getURL(self._conf), \
652 "cloneURL": urlHandlers.UHConfClone.getURL( self._conf ), \
653 "sessionModifyURLGen": urlHandlers.UHSessionModification.getURL, \
654 "contribModifyURLGen": urlHandlers.UHContributionModification.getURL, \
655 "subContribModifyURLGen": urlHandlers.UHSubContribModification.getURL, \
656 "materialURLGen": urlHandlers.UHMaterialDisplay.getURL, \
657 "resourceURLGen": urlHandlers.UHFileAccess.getURL }
659 pars.update({ 'firstDay' : self._firstDay, 'lastDay' : self._lastDay, 'daysPerRow' : self._daysPerRow })
660 return pars
662 def _getBody(self, params):
663 body_vars = self._getBodyVariables()
664 view = self._view
665 outGen = outputGenerator(self._getAW())
666 styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
667 if styleMgr.existsXSLFile(self._view):
668 if self._params.get("detailLevel", "") == "contribution" or self._params.get("detailLevel", "") == "":
669 includeContribution = 1
670 else:
671 includeContribution = 0
672 body = outGen.getFormattedOutput(self._rh, self._conf, styleMgr.getXSLPath(self._view), body_vars, 1,
673 includeContribution, 1, 1, self._params.get("showSession", ""),
674 self._params.get("showDate", ""))
675 return body
676 else:
677 return _("Cannot find the %s stylesheet") % view
679 def _defineSectionMenu(self):
680 WPConferenceDefaultDisplayBase._defineSectionMenu(self)
681 self._sectionMenu.setCurrentItem(self._overviewOpt)
684 class WPTPLConferenceDisplay(WPXSLConferenceDisplay, object):
686 Overrides XSL related functions in WPXSLConferenceDisplay
687 class and re-implements them using normal Indico templates.
690 def __init__(self, rh, conference, view, type, params):
691 WPXSLConferenceDisplay.__init__(self, rh, conference, view, type, params)
692 imagesBaseURL = Config.getInstance().getImagesBaseURL()
693 self._types = {
694 "pdf" :{"mapsTo" : "pdf", "imgURL" : os.path.join(imagesBaseURL, "pdf_small.png"), "imgAlt" : "pdf file"},
695 "doc" :{"mapsTo" : "doc", "imgURL" : os.path.join(imagesBaseURL, "word.png"), "imgAlt" : "word file"},
696 "docx" :{"mapsTo" : "doc", "imgURL" : os.path.join(imagesBaseURL, "word.png"), "imgAlt" : "word file"},
697 "ppt" :{"mapsTo" : "ppt", "imgURL" : os.path.join(imagesBaseURL, "powerpoint.png"), "imgAlt" : "powerpoint file"},
698 "pptx" :{"mapsTo" : "ppt", "imgURL" : os.path.join(imagesBaseURL, "powerpoint.png"), "imgAlt" : "powerpoint file"},
699 "xls" :{"mapsTo" : "xls", "imgURL" : os.path.join(imagesBaseURL, "excel.png"), "imgAlt" : "excel file"},
700 "xlsx" :{"mapsTo" : "xls", "imgURL" : os.path.join(imagesBaseURL, "excel.png"), "imgAlt" : "excel file"},
701 "sxi" :{"mapsTo" : "odp", "imgURL" : os.path.join(imagesBaseURL, "impress.png"), "imgAlt" : "presentation file"},
702 "odp" :{"mapsTo" : "odp", "imgURL" : os.path.join(imagesBaseURL, "impress.png"), "imgAlt" : "presentation file"},
703 "sxw" :{"mapsTo" : "odt", "imgURL" : os.path.join(imagesBaseURL, "writer.png"), "imgAlt" : "writer file"},
704 "odt" :{"mapsTo" : "odt", "imgURL" : os.path.join(imagesBaseURL, "writer.png"), "imgAlt" : "writer file"},
705 "sxc" :{"mapsTo" : "ods", "imgURL" : os.path.join(imagesBaseURL, "calc.png"), "imgAlt" : "spreadsheet file"},
706 "ods" :{"mapsTo" : "ods", "imgURL" : os.path.join(imagesBaseURL, "calc.png"), "imgAlt" : "spreadsheet file"},
707 "other" :{"mapsTo" : "other", "imgURL" : os.path.join(imagesBaseURL, "file_small.png"), "imgAlt" : "unknown type file"},
708 "link" :{"mapsTo" : "link", "imgURL" : os.path.join(imagesBaseURL, "link.png"), "imgAlt" : "link"}
711 def _getVariables(self, conf):
712 wvars = {}
713 styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
714 wvars['INCLUDE'] = '../include'
716 wvars['accessWrapper'] = accessWrapper = self._rh._aw
717 wvars['conf'] = conf
718 if conf.getOwnerList():
719 wvars['category'] = conf.getOwnerList()[0].getName()
720 else:
721 wvars['category'] = ''
723 timezoneUtil = DisplayTZ(accessWrapper, conf)
724 tz = timezoneUtil.getDisplayTZ()
725 wvars['startDate'] = conf.getAdjustedStartDate(tz)
726 wvars['endDate'] = conf.getAdjustedEndDate(tz)
727 wvars['timezone'] = tz
729 if conf.getParticipation().displayParticipantList() :
730 wvars['participants'] = conf.getParticipation().getPresentParticipantListText()
732 attached_items = conf.attached_items
734 lectures, folders = [], []
736 for folder in attached_items.get('folders', []):
737 if LECTURE_SERIES_RE.match(folder.title):
738 lectures.append(folder)
739 elif folder.title != "Internal Page Files":
740 folders.append(folder)
742 cmp_title_number = lambda x, y: int(x.title[4:]) - int(y.title[4:])
744 wvars.update({
745 'files': attached_items.get('files', []),
746 'folders': folders,
747 'lectures': sorted(lectures, cmp=cmp_title_number)
750 if (conf.getType() in ("meeting", "simple_event")
751 and conf.getParticipation().isAllowedForApplying()
752 and conf.getStartDate() > nowutc()
753 and not conf.getParticipation().isFull()):
754 wvars['registrationOpen'] = True
755 evaluation = conf.getEvaluation()
756 if evaluation.isVisible() and evaluation.inEvaluationPeriod() and evaluation.getNbOfQuestions() > 0:
757 wvars['evaluationLink'] = urlHandlers.UHConfEvaluationDisplay.getURL(conf)
758 wvars['supportEmailCaption'] = conf.getSupportInfo().getCaption()
760 wvars['types'] = self._types
762 wvars['entries'] = []
763 confSchedule = conf.getSchedule()
764 showSession = self._params.get("showSession","all")
765 detailLevel = self._params.get("detailLevel", "contribution")
766 showDate = self._params.get("showDate", "all")
767 # Filter by day
768 if showDate == "all":
769 entrylist = confSchedule.getEntries()
770 else:
771 entrylist = confSchedule.getEntriesOnDay(timezone(tz).localize(stringToDate(showDate)))
772 # Check entries filters and access rights
773 for entry in entrylist:
774 sessionCand = entry.getOwner().getOwner()
775 # Filter by session
776 if isinstance(sessionCand, Session) and (showSession != "all" and sessionCand.getId() != showSession):
777 continue
778 # Hide/Show contributions
779 if isinstance(entry.getOwner(), Contribution) and detailLevel != "contribution":
780 continue
781 if entry.getOwner().canView(accessWrapper):
782 if type(entry) is schedule.BreakTimeSchEntry:
783 newItem = entry
784 else:
785 newItem = entry.getOwner()
786 wvars['entries'].append(newItem)
788 wvars['entries'].sort(key=lambda entry: entry.getEndDate(), reverse=True)
789 wvars['entries'].sort(key=lambda entry: (entry.getStartDate(),
790 entry.getFullTitle() if hasattr(entry, 'getFullTitle') else None))
791 wvars["daysPerRow"] = self._daysPerRow
792 wvars["firstDay"] = self._firstDay
793 wvars["lastDay"] = self._lastDay
794 wvars["currentUser"] = self._rh._aw.getUser()
795 wvars["reportNumberSystems"] = Config.getInstance().getReportNumberSystems()
796 return wvars
798 def _getMaterialFiles(self, material):
799 files = []
800 for res in material.getResourceList():
801 if isinstance(res, LocalFile):
802 fileType = res.getFileType().lower()
803 try:
804 fileType = self._types[fileType]["mapsTo"]
805 except KeyError:
806 fileType = "other"
807 filename = res.getName() or res.getFileName()
808 fileURL = str(urlHandlers.UHFileAccess.getURL(res))
809 else:
810 filename, fileType, fileURL = str(res.getName() or res.getURL()), "link", str(res.getURL())
811 files.append({'id': res.getId(),
812 'name': filename,
813 'description': res.getDescription(),
814 'type': fileType,
815 'url': fileURL,
816 'pdfConversionStatus': res.getPDFConversionStatus()})
817 return files
819 def _getItemType(self, item):
820 itemClass = item.__class__.__name__
821 if itemClass == 'BreakTimeSchEntry':
822 return 'Break'
823 elif itemClass == 'SessionSlot':
824 return 'Session'
825 elif itemClass == 'AcceptedContribution':
826 return 'Contribution'
827 else:
828 # return Conference, Contribution or SubContribution
829 return itemClass
831 def _generateMaterialList(self, obj):
833 Generates a list containing all the materials, with the
834 corresponding Ids for those that already exist
836 # yes, this may look a bit redundant, but materialRegistry isn't
837 # bound to a particular target
838 materialRegistry = obj.getMaterialRegistry()
839 return materialRegistry.getMaterialList(obj.getConference())
841 def _extractInfoForButton(self, item):
842 info = {}
843 for key in ['sessId', 'slotId', 'contId', 'subContId']:
844 info[key] = 'null'
845 info['confId'] = self._conf.getId()
847 itemType = self._getItemType(item)
848 info['uploadURL'] = 'Indico.Urls.UploadAction.%s' % itemType.lower()
850 if itemType != 'Session':
851 info['materialList'] = self._generateMaterialList(item)
852 else:
853 info['materialList'] = self._generateMaterialList(item.getSession())
855 if itemType == 'Conference':
856 info['parentProtection'] = item.getAccessController().isProtected()
857 if item.canModify(self._rh._aw):
858 info["modifyLink"] = urlHandlers.UHConferenceModification.getURL(item)
859 info["minutesLink"] = True
860 info["materialLink"] = True
861 info["cloneLink"] = urlHandlers.UHConfClone.getURL(item)
862 if item.getAccessController().canUserSubmit(self._rh._aw.getUser()):
863 info["minutesLink"] = True
864 info["materialLink"] = True
866 elif itemType == 'Session':
867 session = item.getSession()
868 info['parentProtection'] = session.getAccessController().isProtected()
869 if session.canModify(self._rh._aw) or session.canCoordinate(self._rh._aw):
870 info["modifyLink"] = urlHandlers.UHSessionModification.getURL(item)
871 info['slotId'] = item.getId()
872 info['sessId'] = session.getId()
873 if session.canModify(self._rh._aw) or session.canCoordinate(self._rh._aw):
874 info["minutesLink"] = True
875 info["materialLink"] = True
876 url = urlHandlers.UHSessionModifSchedule.getURL(session)
877 ttLink = "%s#%s.s%sl%s" % (url, session.getStartDate().strftime('%Y%m%d'), session.getId(), info['slotId'])
878 info["sessionTimetableLink"] = ttLink
880 elif itemType == 'Contribution':
881 info['parentProtection'] = item.getAccessController().isProtected()
882 if item.canModify(self._rh._aw):
883 info["modifyLink"] = urlHandlers.UHContributionModification.getURL(item)
884 if item.canModify(self._rh._aw) or item.canUserSubmit(self._rh._aw.getUser()):
885 info["minutesLink"] = True
886 info["materialLink"] = True
887 info["contId"] = item.getId()
888 owner = item.getOwner()
889 if self._getItemType(owner) == 'Session':
890 info['sessId'] = owner.getId()
892 elif itemType == 'SubContribution':
893 info['parentProtection'] = item.getContribution().getAccessController().isProtected()
894 if item.canModify(self._rh._aw):
895 info["modifyLink"] = urlHandlers.UHSubContributionModification.getURL(item)
896 if item.canModify(self._rh._aw) or item.canUserSubmit(self._rh._aw.getUser()):
897 info["minutesLink"] = True
898 info["materialLink"] = True
899 info["subContId"] = item.getId()
900 info["contId"] = item.getContribution().getId()
901 owner = item.getOwner()
902 if self._getItemType(owner) == 'Session':
903 info['sessId'] = owner.getId()
905 return info
907 def _getHTMLHeader( self ):
908 return WPConferenceBase._getHTMLHeader(self)
910 def _getHeadContent( self ):
911 config = Config.getInstance()
912 styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
913 htdocs = config.getHtdocsDir()
914 baseurl = self._getBaseURL()
915 # First include the default Indico stylesheet
916 timestamp = os.stat(__file__).st_mtime
917 styleText = """<link rel="stylesheet" href="%s/css/%s?%d">\n""" % \
918 (baseurl, Config.getInstance().getCssStylesheetName(), timestamp)
919 # Then the common event display stylesheet
920 if os.path.exists("%s/css/events/common.css" % htdocs):
921 styleText += """ <link rel="stylesheet" href="%s/css/events/common.css?%d">\n""" % (baseurl,
922 timestamp)
924 # And finally the specific display stylesheet
925 if styleMgr.existsCSSFile(self._view):
926 cssPath = os.path.join(baseurl, 'css', 'events', styleMgr.getCSSFilename(self._view))
927 styleText += """ <link rel="stylesheet" href="%s?%d">\n""" % (cssPath, timestamp)
929 confMetadata = WConfMetadata(self._conf).getHTML()
931 mathJax = render('js/mathjax.config.js.tpl') + \
932 '\n'.join(['<script src="{0}" type="text/javascript"></script>'.format(url) for url in
933 self._asset_env['mathjax_js'].urls()])
935 return styleText + confMetadata + mathJax
937 def _getFooter( self ):
940 wc = wcomponents.WEventFooter(self._conf)
941 p = {"modificationDate":format_datetime(self._conf.getModificationDate(), format='d MMMM yyyy H:mm'),"subArea": self._getSiteArea(),"dark":True}
942 if Config.getInstance().getShortEventURL():
943 id=self._conf.getUrlTag().strip()
944 if not id:
945 id = self._conf.getId()
946 p["shortURL"] = Config.getInstance().getShortEventURL() + id
947 return wc.getHTML(p)
949 def _getHeader( self ):
952 if self._type == "simple_event":
953 wc = wcomponents.WMenuSimpleEventHeader( self._getAW(), self._conf )
954 elif self._type == "meeting":
955 wc = wcomponents.WMenuMeetingHeader( self._getAW(), self._conf )
956 else:
957 wc = wcomponents.WMenuConferenceHeader( self._getAW(), self._conf )
958 return wc.getHTML( { "loginURL": self.getLoginURL(),\
959 "logoutURL": self.getLogoutURL(),\
960 "confId": self._conf.getId(),\
961 "currentView": self._view,\
962 "type": self._type,\
963 "selectedDate": self._params.get("showDate",""),\
964 "selectedSession": self._params.get("showSession",""),\
965 "detailLevel": self._params.get("detailLevel",""),\
966 "filterActive": self._params.get("filterActive",""),\
967 "dark": True } )
969 def getCSSFiles(self):
970 return (WPConferenceBase.getCSSFiles(self) +
971 self._asset_env['eventservices_sass'].urls() +
972 self._asset_env['event_display_sass'].urls())
974 def getJSFiles(self):
975 modules = WPConferenceBase.getJSFiles(self)
977 # TODO: find way to check if the user is able to manage
978 # anything inside the conference (sessions, ...)
979 modules += (self._includeJSPackage('Management') +
980 self._includeJSPackage('MaterialEditor') +
981 self._includeJSPackage('Display') +
982 self._asset_env['modules_vc_js'].urls() +
983 self._asset_env['modules_event_display_js'].urls() +
984 self._asset_env['zero_clipboard_js'].urls())
985 return modules
987 def _applyDecoration( self, body ):
990 if self._params.get("frame","")=="no" or self._params.get("fr","")=="no":
991 return WPrintPageFrame().getHTML({"content":body})
992 return WPConferenceBase._applyDecoration(self, body)
994 def _getHTMLFooter( self ):
995 if self._params.get("frame","")=="no" or self._params.get("fr","")=="no":
996 return ""
997 return WPConferenceBase._getHTMLFooter(self)
999 @staticmethod
1000 def getLocationInfo(item, roomLink=True, fullName=False):
1001 """Return a tuple (location, room, url) containing
1002 information about the location of the item."""
1003 minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
1004 location = item.getLocation().getName() if item.getLocation() else ""
1005 customRoom = item.getRoom()
1006 if not customRoom:
1007 roomName = ''
1008 elif fullName and location and Config.getInstance().getIsRoomBookingActive():
1009 # if we want the full name and we have a RB DB to search in
1010 roomName = customRoom.getFullName()
1011 if not roomName:
1012 customRoom.retrieveFullName(location) # try to fetch the full name
1013 roomName = customRoom.getFullName() or customRoom.getName()
1014 else:
1015 roomName = customRoom.getName()
1016 # TODO check if the following if is required
1017 if roomName in ['', '0--', 'Select:']:
1018 roomName = ''
1019 if roomLink:
1020 url = linking.RoomLinker().getURL(item.getRoom(), item.getLocation())
1021 else:
1022 url = ""
1023 return (location, roomName, url)
1025 def _getBody(self, params):
1026 """Return main information about the event."""
1028 if self._view != 'xml':
1029 vars = self._getVariables(self._conf)
1030 vars['getTime'] = lambda date : format_time(date.time(), format="HH:mm")
1031 vars['isTime0H0M'] = lambda date : (date.hour, date.minute) == (0,0)
1032 vars['getDate'] = lambda date : format_date(date, format='yyyy-MM-dd')
1033 vars['prettyDate'] = lambda date : format_date(date, format='full')
1034 vars['prettyDuration'] = MaKaC.common.utils.prettyDuration
1035 vars['parseDate'] = MaKaC.common.utils.parseDate
1036 vars['isStringHTML'] = MaKaC.common.utils.isStringHTML
1037 vars['getMaterialFiles'] = lambda material : self._getMaterialFiles(material)
1038 vars['extractInfoForButton'] = lambda item : self._extractInfoForButton(item)
1039 vars['getItemType'] = lambda item : self._getItemType(item)
1040 vars['getLocationInfo'] = WPTPLConferenceDisplay.getLocationInfo
1041 vars['dumps'] = json.dumps
1042 vars['timedelta'] = timedelta
1043 else:
1044 outGen = outputGenerator(self._rh._aw)
1045 varsForGenerator = self._getBodyVariables()
1046 vars = {}
1047 vars['xml'] = outGen._getBasicXML(self._conf, varsForGenerator, 1, 1, 1, 1)
1049 styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
1050 if styleMgr.existsTPLFile(self._view):
1051 fileName = os.path.splitext(styleMgr.getTemplateFilename(self._view))[0]
1052 body = wcomponents.WTemplated(os.path.join("events", fileName)).getHTML(vars)
1053 else:
1054 return _("Template could not be found.")
1055 return body
1058 class WPrintPageFrame (wcomponents.WTemplated):
1059 pass
1062 class WText(wcomponents.WTemplated):
1064 def __init__(self):
1065 wcomponents.WTemplated("events/Text")
1068 class WConfDisplayBodyBase(wcomponents.WTemplated):
1070 def _getTitle(self):
1071 default_caption = displayMgr.SystemLinkData().getLinkData()[self._linkname]["caption"]
1072 caption = self._conf.getDisplayMgr().getMenu().getLinkByName(self._linkname).getCaption()
1073 return _(caption) if caption == default_caption else caption
1076 class WConfProgram(WConfDisplayBodyBase):
1078 _linkname = "programme"
1080 def __init__(self, aw, conf):
1081 self._conf = conf
1082 self._aw = aw
1084 def buildTrackData(self, track):
1086 Returns a dict representing the data of the track and its Sub-tracks
1087 should it have any.
1089 description = track.getDescription()
1091 formattedTrack = {
1092 'title': track.getTitle(),
1093 'description': description
1096 if track.getConference().getAbstractMgr().isActive() and \
1097 track.getConference().hasEnabledSection("cfa") and \
1098 track.canCoordinate(self._aw):
1100 if track.getConference().canModify(self._aw):
1101 formattedTrack['url'] = urlHandlers.UHTrackModification.getURL(track)
1102 else:
1103 formattedTrack['url'] = urlHandlers.UHTrackModifAbstracts.getURL(track)
1105 return formattedTrack
1107 def getVars(self):
1108 pvars = wcomponents.WTemplated.getVars(self)
1109 pvars["body_title"] = self._getTitle()
1110 pvars['description'] = self._conf.getProgramDescription()
1111 pvars['program'] = [self.buildTrackData(t) for t in self._conf.getTrackList()]
1112 pvars['pdf_url'] = urlHandlers.UHConferenceProgramPDF.getURL(self._conf)
1114 return pvars
1117 class WPConferenceProgram(WPConferenceDefaultDisplayBase):
1119 def _getBody(self, params):
1120 wc = WConfProgram(self._getAW(), self._conf)
1121 return wc.getHTML()
1123 def _defineSectionMenu(self):
1124 WPConferenceDefaultDisplayBase._defineSectionMenu(self)
1125 self._sectionMenu.setCurrentItem(self._programOpt)
1128 class WInternalPageDisplay(wcomponents.WTemplated):
1130 def __init__(self, conf, page):
1131 self._conf = conf
1132 self._page=page
1134 def getVars( self ):
1135 vars = wcomponents.WTemplated.getVars( self )
1136 vars["content"] = self._page.getContent()
1137 return vars
1139 class WPInternalPageDisplay( WPConferenceDefaultDisplayBase ):
1141 def __init__( self, rh, conference, page ):
1142 WPConferenceDefaultDisplayBase.__init__( self, rh, conference )
1143 self._page = page
1145 def _getBody( self, params ):
1146 wc = WInternalPageDisplay( self._conf, self._page )
1147 return wc.getHTML()
1149 def _defineSectionMenu( self ):
1150 WPConferenceDefaultDisplayBase._defineSectionMenu(self)
1152 for link in self._sectionMenu.getAllLinks():
1153 if link.getType() == 'page' and link.getPage().getId() == self._page.getId():
1154 self._sectionMenu.setCurrentItem(link)
1155 break
1158 class WConferenceTimeTable(WConfDisplayBodyBase):
1160 _linkname = "timetable"
1162 def __init__(self, conference, aw):
1163 self._conf = conference
1164 self._aw = aw
1166 def getVars(self):
1167 wvars = wcomponents.WTemplated.getVars(self)
1168 tz = DisplayTZ(self._aw, self._conf).getDisplayTZ()
1169 sf = schedule.ScheduleToJson.process(self._conf.getSchedule(),
1170 tz, self._aw,
1171 useAttrCache=True,
1172 hideWeekends=True)
1173 # TODO: Move to beginning of file when proved useful
1174 try:
1175 import ujson
1176 jsonf = ujson.encode
1177 except ImportError:
1178 jsonf = json.dumps
1179 wvars["ttdata"] = jsonf(sf)
1180 eventInfo = fossilize(self._conf, IConferenceEventInfoFossil, tz=tz)
1181 eventInfo['isCFAEnabled'] = self._conf.getAbstractMgr().isActive()
1182 wvars['eventInfo'] = eventInfo
1183 wvars['timetableLayout'] = wvars.get('ttLyt', '')
1184 return wvars
1187 class WPConferenceTimeTable(WPConferenceDefaultDisplayBase):
1188 navigationEntry = navigation.NEConferenceTimeTable
1190 def getJSFiles(self):
1191 return WPConferenceDefaultDisplayBase.getJSFiles(self) + \
1192 self._includeJSPackage('Timetable')
1194 def _getHeadContent(self):
1195 content = WPConferenceDefaultDisplayBase._getHeadContent(self)
1196 return content + '<link rel="stylesheet" type="text/css" href="{}/css/timetable.css">'.format(
1197 self._getBaseURL())
1199 def _getBody( self, params ):
1200 wc = WConferenceTimeTable( self._conf, self._getAW() )
1201 return wc.getHTML(params)
1203 def _defineSectionMenu( self ):
1204 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
1205 self._sectionMenu.setCurrentItem(self._timetableOpt)
1208 class WPMeetingTimeTable( WPTPLConferenceDisplay ):
1210 def getJSFiles(self):
1211 return WPXSLConferenceDisplay.getJSFiles(self) + \
1212 self._includeJSPackage('Timetable')
1214 def _getBody( self, params ):
1215 wc = WConferenceTimeTable( self._conf, self._getAW() )
1216 return wc.getHTML(params)
1219 class WPConferenceModifBase(main.WPMainBase):
1221 _userData = ['favorite-user-ids']
1223 def __init__(self, rh, conference, **kwargs):
1224 main.WPMainBase.__init__(self, rh, **kwargs)
1225 self._navigationTarget = self._conf = conference
1227 def getJSFiles(self):
1228 return main.WPMainBase.getJSFiles(self) + \
1229 self._includeJSPackage('Management') + \
1230 self._includeJSPackage('MaterialEditor')
1232 def _getSiteArea(self):
1233 return "ModificationArea"
1235 def _getHeader( self ):
1238 wc = wcomponents.WHeader( self._getAW() )
1239 return wc.getHTML( { "subArea": self._getSiteArea(), \
1240 "loginURL": self._escapeChars(str(self.getLoginURL())),\
1241 "logoutURL": self._escapeChars(str(self.getLogoutURL())) } )
1243 def _getNavigationDrawer(self):
1244 pars = {"target": self._conf, "isModif": True }
1245 return wcomponents.WNavigationDrawer( pars, bgColor="white" )
1247 def _createSideMenu(self):
1248 self._sideMenu = wcomponents.ManagementSideMenu()
1250 # The main section containing most menu items
1251 self._generalSection = wcomponents.SideMenuSection()
1253 self._generalSettingsMenuItem = wcomponents.SideMenuItem(_("General settings"),
1254 urlHandlers.UHConferenceModification.getURL( self._conf ))
1255 self._generalSection.addItem( self._generalSettingsMenuItem)
1257 self._timetableMenuItem = wcomponents.SideMenuItem(_("Timetable"),
1258 urlHandlers.UHConfModifSchedule.getURL( self._conf ))
1259 self._generalSection.addItem( self._timetableMenuItem)
1261 self._roomBookingMenuItem = wcomponents.SideMenuItem(_("Room booking"),
1262 url_for('event_mgmt.rooms_booking_list', self._conf))
1263 self._generalSection.addItem( self._roomBookingMenuItem)
1265 self._programMenuItem = wcomponents.SideMenuItem(_("Programme"),
1266 urlHandlers.UHConfModifProgram.getURL( self._conf ))
1267 self._generalSection.addItem( self._programMenuItem)
1269 self._regFormMenuItem = wcomponents.SideMenuItem(_("Registration"),
1270 urlHandlers.UHConfModifRegForm.getURL( self._conf ))
1271 self._generalSection.addItem( self._regFormMenuItem)
1273 self._abstractMenuItem = wcomponents.SideMenuItem(_("Abstracts"),
1274 urlHandlers.UHConfModifCFA.getURL( self._conf ))
1275 self._generalSection.addItem( self._abstractMenuItem)
1277 self._contribListMenuItem = wcomponents.SideMenuItem(_("Contributions"),
1278 urlHandlers.UHConfModifContribList.getURL( self._conf ))
1279 self._generalSection.addItem( self._contribListMenuItem)
1281 self._reviewingMenuItem = wcomponents.SideMenuItem(_("Paper Reviewing"),
1282 urlHandlers.UHConfModifReviewingAccess.getURL( target = self._conf ) )
1283 self._generalSection.addItem( self._reviewingMenuItem)
1285 self._participantsMenuItem = wcomponents.SideMenuItem(_("Participants"),
1286 urlHandlers.UHConfModifParticipants.getURL( self._conf ) )
1287 self._generalSection.addItem( self._participantsMenuItem)
1289 self._evaluationMenuItem = wcomponents.SideMenuItem(_("Evaluation"),
1290 urlHandlers.UHConfModifEvaluation.getURL( self._conf ) )
1291 self._generalSection.addItem( self._evaluationMenuItem)
1293 self.extra_menu_items = {}
1294 for name, item in sorted(values_from_signal(signals.event_management.sidemenu.send(self._conf)),
1295 key=lambda x: x[1]._title):
1296 self.extra_menu_items[name] = item
1297 self._generalSection.addItem(item)
1299 self._sideMenu.addSection(self._generalSection)
1301 # The section containing all advanced options
1302 self._advancedOptionsSection = wcomponents.SideMenuSection(_("Advanced options"))
1304 self._listingsMenuItem = wcomponents.SideMenuItem(_("Lists"),
1305 urlHandlers.UHConfAllSpeakers.getURL( self._conf ) )
1306 self._advancedOptionsSection.addItem( self._listingsMenuItem)
1308 self._ACMenuItem = wcomponents.SideMenuItem(_("Protection"),
1309 urlHandlers.UHConfModifAC.getURL( self._conf ) )
1310 self._advancedOptionsSection.addItem( self._ACMenuItem)
1312 self._toolsMenuItem = wcomponents.SideMenuItem(_("Tools"),
1313 urlHandlers.UHConfModifTools.getURL( self._conf ) )
1314 self._advancedOptionsSection.addItem( self._toolsMenuItem)
1316 self._layoutMenuItem = wcomponents.SideMenuItem(_("Layout"),
1317 urlHandlers.UHConfModifDisplay.getURL(self._conf))
1318 self._advancedOptionsSection.addItem( self._layoutMenuItem)
1320 self.extra_menu_items_advanced = {}
1321 for name, item in sorted(values_from_signal(signals.event_management.sidemenu_advanced.send(self._conf)),
1322 key=lambda x: x[1]._title):
1323 self.extra_menu_items_advanced[name] = item
1324 self._advancedOptionsSection.addItem(item)
1326 self._sideMenu.addSection(self._advancedOptionsSection)
1328 #we decide which side menu item appear and which don't
1329 from MaKaC.webinterface.rh.reviewingModif import RCPaperReviewManager, RCReviewingStaff
1331 canModify = self._conf.canModify(self._rh.getAW())
1332 isReviewingStaff = RCReviewingStaff.hasRights(self._rh)
1333 isPRM = RCPaperReviewManager.hasRights(self._rh)
1334 #isAM = RCAbstractManager.hasRights(self._rh)
1335 isRegistrar = self._conf.canManageRegistration(self._rh.getAW().getUser())
1337 if not canModify:
1338 self._generalSettingsMenuItem.setVisible(False)
1339 self._timetableMenuItem.setVisible(False)
1340 self._programMenuItem.setVisible(False)
1341 self._participantsMenuItem.setVisible(False)
1342 self._listingsMenuItem.setVisible(False)
1343 self._layoutMenuItem.setVisible(False)
1344 self._ACMenuItem.setVisible(False)
1345 self._toolsMenuItem.setVisible(False)
1346 self._evaluationMenuItem.setVisible(False)
1348 if not (Config.getInstance().getIsRoomBookingActive() and canModify):
1349 self._roomBookingMenuItem.setVisible(False)
1351 #if not (self._conf.hasEnabledSection("cfa") and (canModify or isAM)):
1352 if not (self._conf.hasEnabledSection("cfa") and (canModify)):
1353 self._abstractMenuItem.setVisible(False)
1355 if not (canModify or isPRM):
1356 self._contribListMenuItem.setVisible(False)
1358 if not (self._conf.hasEnabledSection("regForm") and (canModify or isRegistrar)):
1359 self._regFormMenuItem.setVisible(False)
1361 if not (self._conf.getType() == "conference" and (canModify or isReviewingStaff)):
1362 self._reviewingMenuItem.setVisible(False)
1363 else: #reviewing tab is enabled
1364 if isReviewingStaff and not canModify:
1365 self._reviewingMenuItem.setVisible(True)
1366 # For now we don't want the paper reviewing to be displayed
1367 #self._reviewingMenuItem.setVisible(False)
1369 #we hide the Advanced Options section if it has no items
1370 if not self._advancedOptionsSection.hasVisibleItems():
1371 self._advancedOptionsSection.setVisible(False)
1373 # we disable the Participants section for events of type conference
1374 if self._conf.getType() == 'conference':
1375 self._participantsMenuItem.setVisible(False)
1377 wf = self._rh.getWebFactory()
1378 if wf:
1379 wf.customiseSideMenu( self )
1381 def _setActiveSideMenuItem( self ):
1382 pass
1384 def _applyFrame( self, body ):
1385 frame = wcomponents.WConferenceModifFrame( self._conf, self._getAW())
1387 sideMenu = self._sideMenu.getHTML()
1389 p = { "categDisplayURLGen": urlHandlers.UHCategoryDisplay.getURL, \
1390 "confDisplayURLGen": urlHandlers.UHConferenceDisplay.getURL, \
1391 "event": "Conference",
1392 "sideMenu": sideMenu }
1393 wf = self._rh.getWebFactory()
1394 if wf:
1395 p["event"]=wf.getName()
1396 return frame.getHTML( body, **p )
1398 def _getBody( self, params ):
1399 self._createSideMenu()
1400 self._setActiveSideMenuItem()
1402 return self._applyFrame( self._getPageContent( params ) )
1404 def _getTabContent( self, params ):
1405 return "nothing"
1407 def _getPageContent( self, params ):
1408 return "nothing"
1410 class WPConferenceModifAbstractBase( WPConferenceModifBase ):
1412 def __init__(self, rh, conf):
1413 WPConferenceModifBase.__init__(self, rh, conf)
1415 def _createTabCtrl(self):
1416 self._tabCtrl = wcomponents.TabControl()
1418 self._tabCFA = self._tabCtrl.newTab( "cfasetup", _("Setup"), urlHandlers.UHConfModifCFA.getURL( self._conf ) )
1419 self._tabCFAPreview = self._tabCtrl.newTab("cfapreview", _("Preview"), urlHandlers.UHConfModifCFAPreview.getURL(self._conf))
1420 self._tabAbstractList = self._tabCtrl.newTab( "abstractList", _("List of Abstracts"), urlHandlers.UHConfAbstractList.getURL( self._conf ) )
1421 self._tabBOA = self._tabCtrl.newTab("boa", _("Book of Abstracts Setup"), urlHandlers.UHConfModAbstractBook.getURL(self._conf))
1422 self._tabCFAR = self._tabCtrl.newTab("reviewing", _("Reviewing"), urlHandlers.UHAbstractReviewingSetup.getURL(self._conf))
1424 # Create subtabs for the reviewing
1425 self._subTabARSetup = self._tabCFAR.newSubTab( "revsetup", _("Settings"),\
1426 urlHandlers.UHAbstractReviewingSetup.getURL(self._conf))
1427 self._subTabARTeam = self._tabCFAR.newSubTab( "revteam", _("Team"),\
1428 urlHandlers.UHAbstractReviewingTeam.getURL(self._conf))
1429 self._subTabARNotifTpl = self._tabCFAR.newSubTab( "notiftpl", _("Notification templates"),\
1430 urlHandlers.UHAbstractReviewingNotifTpl.getURL(self._conf))
1432 if not self._conf.hasEnabledSection("cfa"):
1433 self._tabBOA.disable()
1434 self._tabCFA.disable()
1435 self._tabAbstractList.disable()
1436 self._tabCFAPreview.disable()
1437 self._tabCFAR.disable()
1439 self._setActiveTab()
1441 def _getPageContent(self, params):
1442 self._createTabCtrl()
1444 return wcomponents.WTabControl( self._tabCtrl, self._getAW() ).getHTML( self._getTabContent( params ) )
1446 def _setActiveSideMenuItem(self):
1447 self._abstractMenuItem.setActive()
1449 def _getTabContent(self, params):
1450 return "nothing"
1452 def _setActiveTab(self):
1453 pass
1456 class WConfModifMainData(wcomponents.WTemplated):
1458 def __init__(self,conference,mfRegistry,ct,rh):
1459 self._conf=conference
1460 self.__mfr=mfRegistry
1461 self._ct=ct
1462 self._rh = rh
1464 def _getChairPersonsList(self):
1465 result = fossilize(self._conf.getChairList())
1466 for chair in result:
1467 av = AvatarHolder().match({"email": chair['email']},
1468 searchInAuthenticators=False, exact=True)
1469 chair['showManagerCB'] = True
1470 chair['showSubmitterCB'] = True
1471 if not av:
1472 if self._conf.getPendingQueuesMgr().getPendingConfSubmittersByEmail(chair['email']):
1473 chair['showSubmitterCB'] = False
1474 elif (av[0] in self._conf.getAccessController().getSubmitterList()):
1475 chair['showSubmitterCB'] = False
1476 if (av and self._conf.getAccessController().canModify(av[0])) or chair['email'] in self._conf.getAccessController().getModificationEmail():
1477 chair['showManagerCB'] = False
1478 return result
1480 def getVars(self):
1481 vars = wcomponents.WTemplated.getVars(self)
1482 type = vars["type"]
1483 vars["defaultStyle"] = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getDefaultStyle()
1484 vars["visibility"] = self._conf.getVisibility()
1485 vars["dataModificationURL"]=quoteattr(str(urlHandlers.UHConfDataModif.getURL(self._conf)))
1486 vars["addTypeURL"]=urlHandlers.UHConfAddContribType.getURL(self._conf)
1487 vars["removeTypeURL"]=urlHandlers.UHConfRemoveContribType.getURL(self._conf)
1488 vars["title"]=self._conf.getTitle()
1489 if isStringHTML(self._conf.getDescription()):
1490 vars["description"] = self._conf.getDescription()
1491 elif self._conf.getDescription():
1492 vars["description"] = self._conf.getDescription()
1493 else:
1494 vars["description"] = ""
1496 ###################################
1497 # Fermi timezone awareness #
1498 ###################################
1499 tz = self._conf.getTimezone()
1500 vars["timezone"] = tz
1501 vars["startDate"]=formatDateTime(self._conf.getAdjustedStartDate())
1502 vars["endDate"]=formatDateTime(self._conf.getAdjustedEndDate())
1503 ###################################
1504 # Fermi timezone awareness(end) #
1505 ###################################
1506 vars["chairText"] = self.htmlText(self._conf.getChairmanText())
1507 place=self._conf.getLocation()
1509 vars["locationName"]=vars["locationAddress"]=""
1510 if place:
1511 vars["locationName"]=self.htmlText(place.getName())
1512 vars["locationAddress"]=self.htmlText(place.getAddress())
1513 room=self._conf.getRoom()
1514 vars["locationRoom"]=""
1515 if room:
1516 vars["locationRoom"]=self.htmlText(room.getName())
1517 if isStringHTML(self._conf.getContactInfo()):
1518 vars["contactInfo"]=self._conf.getContactInfo()
1519 else:
1520 vars["contactInfo"] = """<table class="tablepre"><tr><td><pre>%s</pre></td></tr></table>""" % self._conf.getContactInfo()
1521 vars["supportEmailCaption"] = self._conf.getSupportInfo().getCaption()
1522 vars["supportEmail"] = i18nformat("""--_("not set")--""")
1523 if self._conf.getSupportInfo().hasEmail():
1524 vars["supportEmail"] = self.htmlText(self._conf.getSupportInfo().getEmail())
1525 typeList = []
1526 for type in self._conf.getContribTypeList():
1527 typeList.append("""<input type="checkbox" name="types" value="%s"><a href="%s">%s</a><br>
1528 <table><tr><td width="30"></td><td><font><pre>%s</pre></font></td></tr></table>"""%( \
1529 type.getId(), \
1530 str(urlHandlers.UHConfEditContribType.getURL(type)), \
1531 type.getName(), \
1532 type.getDescription()))
1533 vars["typeList"] = "".join(typeList)
1534 #------------------------------------------------------
1535 vars["reportNumbersTable"]=wcomponents.WReportNumbersTable(self._conf).getHTML()
1536 vars["eventType"] = self._conf.getType()
1537 vars["keywords"] = self._conf.getKeywords()
1538 vars["shortURLBase"] = Config.getInstance().getShortEventURL()
1539 vars["shortURLTag"] = self._conf.getUrlTag()
1540 vars["screenDatesURL"] = urlHandlers.UHConfScreenDatesEdit.getURL(self._conf)
1541 ssdate = format_datetime(self._conf.getAdjustedScreenStartDate(), format='EEEE d MMMM yyyy H:mm')
1542 if self._conf.getScreenStartDate() == self._conf.getStartDate():
1543 ssdate += i18nformat(""" <i> _("(normal)")</i>""")
1544 else:
1545 ssdate += i18nformat(""" <font color='red'>_("(modified)")</font>""")
1546 sedate = format_datetime(self._conf.getAdjustedScreenEndDate(), format='EEEE d MMMM yyyy H:mm')
1547 if self._conf.getScreenEndDate() == self._conf.getEndDate():
1548 sedate += i18nformat(""" <i> _("(normal)")</i>""")
1549 else:
1550 sedate += i18nformat(""" <font color='red'> _("(modified)")</font>""")
1551 vars['rbActive'] = Config.getInstance().getIsRoomBookingActive()
1552 vars["screenDates"] = "%s -> %s" % (ssdate, sedate)
1553 vars["timezoneList"] = TimezoneRegistry.getList()
1554 vars["chairpersons"] = self._getChairPersonsList()
1556 loc = self._conf.getLocation()
1557 room = self._conf.getRoom()
1558 vars["currentLocation"] = { 'location': loc.getName() if loc else "",
1559 'room': room.name if room else "",
1560 'address': loc.getAddress() if loc else "" }
1561 return vars
1563 class WPConferenceModificationClosed( WPConferenceModifBase ):
1565 def __init__(self, rh, target):
1566 WPConferenceModifBase.__init__(self, rh, target)
1568 def _getPageContent( self, params ):
1569 message = _("The event is currently locked and you cannot modify it in this status. ")
1570 if self._conf.canModify(self._rh.getAW()):
1571 message += _("If you unlock the event, you will be able to modify its details again.")
1572 return wcomponents.WClosed().getHTML({"message": message,
1573 "postURL": urlHandlers.UHConferenceOpen.getURL(self._conf),
1574 "showUnlockButton": self._conf.canModify(self._rh.getAW()),
1575 "unlockButtonCaption": _("Unlock event")})
1578 class WPConferenceModification( WPConferenceModifBase ):
1580 def __init__(self, rh, target, ct=None):
1581 WPConferenceModifBase.__init__(self, rh, target)
1582 self._ct = ct
1584 def _setActiveSideMenuItem( self ):
1585 self._generalSettingsMenuItem.setActive()
1587 def _getPageContent( self, params ):
1588 wc = WConfModifMainData( self._conf, ConfMFRegistry(), self._ct, self._rh )
1589 pars = { "type": params.get("type","") , "conferenceId": self._conf.getId()}
1590 return wc.getHTML( pars )
1592 class WConfModScreenDatesEdit(wcomponents.WTemplated):
1594 def __init__(self,conf):
1595 self._conf=conf
1597 def getVars(self):
1598 vars=wcomponents.WTemplated.getVars(self)
1599 vars["postURL"]=quoteattr(str(urlHandlers.UHConfScreenDatesEdit.getURL(self._conf)))
1600 ###################################
1601 # Fermi timezone awareness #
1602 ###################################
1603 csd = self._conf.getAdjustedStartDate()
1604 ced = self._conf.getAdjustedEndDate()
1605 ###################################
1606 # Fermi timezone awareness(end) #
1607 ###################################
1608 vars["conf_start_date"]=self.htmlText(format_datetime(csd, format='EEEE d MMMM yyyy H:mm'))
1609 vars["conf_end_date"]=self.htmlText(format_datetime(ced, format='EEEE d MMMM yyyy H:mm'))
1610 vars["start_date_own_sel"]=""
1611 vars["start_date_conf_sel"]=" checked"
1612 vars["sDay"],vars["sMonth"],vars["sYear"]=csd.day,csd.month,csd.year
1613 vars["sHour"],vars["sMin"]=csd.hour,csd.minute
1614 if self._conf.getScreenStartDate() != self._conf.getStartDate():
1615 vars["start_date_own_sel"]=" checked"
1616 vars["start_date_conf_sel"]=""
1617 sd=self._conf.getAdjustedScreenStartDate()
1618 vars["sDay"]=quoteattr(str(sd.day))
1619 vars["sMonth"]=quoteattr(str(sd.month))
1620 vars["sYear"]=quoteattr(str(sd.year))
1621 vars["sHour"]=quoteattr(str(sd.hour))
1622 vars["sMin"]=quoteattr(str(sd.minute))
1623 vars["end_date_own_sel"]=""
1624 vars["end_date_conf_sel"]=" checked"
1625 vars["eDay"],vars["eMonth"],vars["eYear"]=ced.day,ced.month,ced.year
1626 vars["eHour"],vars["eMin"]=ced.hour,ced.minute
1627 if self._conf.getScreenEndDate() != self._conf.getEndDate():
1628 vars["end_date_own_sel"]=" checked"
1629 vars["end_date_conf_sel"]=""
1630 ed=self._conf.getAdjustedScreenEndDate()
1631 vars["eDay"]=quoteattr(str(ed.day))
1632 vars["eMonth"]=quoteattr(str(ed.month))
1633 vars["eYear"]=quoteattr(str(ed.year))
1634 vars["eHour"]=quoteattr(str(ed.hour))
1635 vars["eMin"]=quoteattr(str(ed.minute))
1636 return vars
1638 class WPScreenDatesEdit(WPConferenceModification):
1640 def _getPageContent( self, params ):
1641 wc = WConfModScreenDatesEdit(self._conf)
1642 return wc.getHTML()
1644 class WConferenceDataModificationAdditionalInfo(wcomponents.WTemplated):
1646 def __init__( self, conference ):
1647 self._conf = conference
1649 def getVars(self):
1650 vars = wcomponents.WTemplated.getVars( self )
1651 vars["contactInfo"] = self._conf.getContactInfo()
1652 return vars
1655 class WConferenceDataModification(wcomponents.WTemplated):
1657 def __init__( self, conference, rh ):
1658 self._conf = conference
1659 self._rh = rh
1661 def _getVisibilityHTML(self):
1662 visibility = self._conf.getVisibility()
1663 topcat = self._conf.getOwnerList()[0]
1664 level = 0
1665 selected = ""
1666 if visibility == 0:
1667 selected = "selected"
1668 vis = [ i18nformat("""<option value="0" %s> _("Nowhere")</option>""") % selected]
1669 while topcat:
1670 level += 1
1671 selected = ""
1672 if level == visibility:
1673 selected = "selected"
1674 if topcat.getId() != "0":
1675 from MaKaC.common.TemplateExec import truncateTitle
1676 vis.append("""<option value="%s" %s>%s</option>""" % (level, selected, truncateTitle(topcat.getName(), 120)))
1677 topcat = topcat.getOwner()
1678 selected = ""
1679 if visibility > level:
1680 selected = "selected"
1681 vis.append( i18nformat("""<option value="999" %s> _("Everywhere")</option>""") % selected)
1682 vis.reverse()
1683 return "".join(vis)
1685 def getVars(self):
1686 vars = wcomponents.WTemplated.getVars( self )
1687 minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
1689 navigator = ""
1690 styleMgr = info.HelperMaKaCInfo.getMaKaCInfoInstance().getStyleManager()
1691 type = self._conf.getType()
1692 vars["timezoneOptions"] = TimezoneRegistry.getShortSelectItemsHTML(self._conf.getTimezone())
1693 styles=styleMgr.getExistingStylesForEventType(type)
1694 styleoptions = ""
1695 defStyle = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getDefaultStyle()
1696 if defStyle not in styles:
1697 defStyle = ""
1698 for styleId in styles:
1699 if styleId == defStyle or (defStyle == "" and styleId == "static"):
1700 selected = "selected"
1701 else:
1702 selected = ""
1703 styleoptions += "<option value=\"%s\" %s>%s</option>" % (styleId,selected,styleMgr.getStyleName(styleId))
1704 vars["conference"] = self._conf
1705 vars["useRoomBookingModule"] = Config.getInstance().getIsRoomBookingActive()
1706 vars["styleOptions"] = styleoptions
1707 import MaKaC.webinterface.webFactoryRegistry as webFactoryRegistry
1708 wr = webFactoryRegistry.WebFactoryRegistry()
1709 types = [ "conference" ]
1710 for fact in wr.getFactoryList():
1711 types.append(fact.getId())
1712 vars["types"] = ""
1713 for id in types:
1714 typetext = id
1715 if typetext == "simple_event":
1716 typetext = "lecture"
1717 if self._conf.getType() == id:
1718 vars["types"] += "<option value=\"%s\" selected>%s" % (id,typetext)
1719 else:
1720 vars["types"] += "<option value=\"%s\">%s" % (id,typetext)
1721 vars["title"] = quoteattr( self._conf.getTitle() )
1722 vars["description"] = self._conf.getDescription()
1723 vars["keywords"] = self._conf.getKeywords()
1724 tz = self._conf.getTimezone()
1725 vars["sDay"] = str( self._conf.getAdjustedStartDate(tz).day )
1726 vars["sMonth"] = str( self._conf.getAdjustedStartDate(tz).month )
1727 vars["sYear"] = str( self._conf.getAdjustedStartDate(tz).year )
1728 vars["sHour"] = str( self._conf.getAdjustedStartDate(tz).hour )
1729 vars["sMinute"] = str( self._conf.getAdjustedStartDate(tz).minute )
1730 vars["eDay"] = str( self._conf.getAdjustedEndDate(tz).day )
1731 vars["eMonth"] = str( self._conf.getAdjustedEndDate(tz).month )
1732 vars["eYear"] = str( self._conf.getAdjustedEndDate(tz).year )
1733 vars["eHour"] = str( self._conf.getAdjustedEndDate(tz).hour )
1734 vars["eMinute"] = str( self._conf.getAdjustedEndDate(tz).minute )
1735 vars["chairText"] = quoteattr( self._conf.getChairmanText() )
1736 vars["orgText"] = quoteattr( self._conf.getOrgText() )
1737 vars["visibility"] = self._getVisibilityHTML()
1738 vars["shortURLTag"] = quoteattr( self._conf.getUrlTag() )
1739 locName, locAddress, locRoom = "", "", ""
1740 location = self._conf.getLocation()
1741 if location:
1742 locName = location.getName()
1743 locAddress = location.getAddress()
1744 room = self._conf.getRoom()
1745 if room:
1746 locRoom = room.getName()
1747 vars["locator"] = self._conf.getLocator().getWebForm()
1749 vars["locationAddress"] = locAddress
1751 vars["supportCaption"] = quoteattr(self._conf.getSupportInfo().getCaption())
1752 vars["supportEmail"] = quoteattr( self._conf.getSupportInfo().getEmail() )
1753 vars["locator"] = self._conf.getLocator().getWebForm()
1754 vars["event_type"] = ""
1755 vars["navigator"] = navigator
1756 eventType = self._conf.getType()
1757 if eventType == "conference":
1758 vars["additionalInfo"] = WConferenceDataModificationAdditionalInfo(self._conf).getHTML(vars)
1759 else:
1760 vars["additionalInfo"] = ""
1761 return vars
1764 class WPConfDataModif( WPConferenceModification ):
1766 def _getPageContent( self, params ):
1767 p = WConferenceDataModification( self._conf, self._rh )
1768 pars = {
1769 "postURL": urlHandlers.UHConfPerformDataModif.getURL(self._conf),
1770 "type": params.get("type")
1772 return p.getHTML( pars )
1775 class WConfModifScheduleGraphic(wcomponents.WTemplated):
1777 def __init__(self, conference, customLinks, **params):
1778 wcomponents.WTemplated.__init__(self, **params)
1779 self._conf = conference
1780 self._customLinks = customLinks
1782 def getVars( self ):
1783 vars=wcomponents.WTemplated.getVars(self)
1784 ################################
1785 # Fermi timezone awareness #
1786 ################################
1787 tz = self._conf.getTimezone()
1788 vars["timezone"]= tz
1789 vars["start_date"]=self._conf.getAdjustedStartDate().strftime("%a %d/%m")
1790 vars["end_date"]=self._conf.getAdjustedEndDate().strftime("%a %d/%m")
1791 #################################
1792 # Fermi timezone awareness(end) #
1793 #################################
1794 vars["editURL"]=quoteattr(str(urlHandlers.UHConfModScheduleDataEdit.getURL(self._conf)))
1796 vars['ttdata'] = schedule.ScheduleToJson.process(self._conf.getSchedule(), tz, None,
1797 days = None, mgmtMode = True)
1799 vars['customLinks'] = self._customLinks
1801 eventInfo = fossilize(self._conf, IConferenceEventInfoFossil, tz = tz)
1802 eventInfo['isCFAEnabled'] = self._conf.getAbstractMgr().isActive()
1803 vars['eventInfo'] = eventInfo
1805 return vars
1807 class WPConfModifScheduleGraphic( WPConferenceModifBase ):
1809 _userData = ['favorite-user-list', 'favorite-user-ids']
1811 def __init__(self, rh, conf):
1812 WPConferenceModifBase.__init__(self, rh, conf)
1813 self._contrib = None
1815 def _setActiveSideMenuItem( self ):
1816 self._timetableMenuItem.setActive()
1818 def getJSFiles(self):
1819 return WPConferenceModifBase.getJSFiles(self) + self._includeJSPackage('Timetable')
1821 def _getSchedule(self):
1822 custom_links = dict(values_from_signal(signals.event.timetable_buttons.send(self)))
1823 return WConfModifScheduleGraphic(self._conf, custom_links)
1825 def _getTTPage( self, params ):
1826 wc = self._getSchedule()
1827 return wc.getHTML(params)
1829 def _getPageContent(self, params):
1830 return self._getTTPage(params)
1832 #------------------------------------------------------------------------------
1833 class WPConfModifSchedule( WPConferenceModifBase ):
1835 def _setActiveTab( self ):
1836 self._tabSchedule.setActive()
1838 #------------------------------------------------------------------------------
1839 class WConfModScheduleDataEdit(wcomponents.WTemplated):
1841 def __init__(self,conf):
1842 self._conf=conf
1844 def getVars(self):
1845 vars=wcomponents.WTemplated.getVars(self)
1846 vars["postURL"]=quoteattr(str(urlHandlers.UHConfModScheduleDataEdit.getURL(self._conf)))
1847 #######################################
1848 # Fermi timezone awareness #
1849 #######################################
1850 csd = self._conf.getAdjustedStartDate()
1851 ced = self._conf.getAdjustedEndDate()
1852 #######################################
1853 # Fermi timezone awareness(end) #
1854 #######################################
1855 vars["sDay"],vars["sMonth"],vars["sYear"]=str(csd.day),str(csd.month),str(csd.year)
1856 vars["sHour"],vars["sMin"]=str(csd.hour),str(csd.minute)
1857 vars["eDay"],vars["eMonth"],vars["eYear"]=str(ced.day),str(ced.month),str(ced.year)
1858 vars["eHour"],vars["eMin"]=str(ced.hour),str(ced.minute)
1859 return vars
1861 class WPModScheduleDataEdit(WPConfModifSchedule):
1863 def _getPageContent( self, params ):
1864 wc = WConfModScheduleDataEdit(self._conf)
1865 return wc.getHTML()
1868 class WConfModifACSessionCoordinatorRights(wcomponents.WTemplated):
1870 def __init__(self,conf):
1871 self._conf = conf
1873 def getVars( self ):
1874 vars = wcomponents.WTemplated.getVars(self)
1875 url = urlHandlers.UHConfModifCoordinatorRights.getURL(self._conf)
1876 html=[]
1877 scr = conference.SessionCoordinatorRights()
1878 for rightKey in scr.getRightKeys():
1879 url = urlHandlers.UHConfModifCoordinatorRights.getURL(self._conf)
1880 url.addParam("rightId", rightKey)
1881 if self._conf.hasSessionCoordinatorRight(rightKey):
1882 imgurl=Config.getInstance().getSystemIconURL("tick")
1883 else:
1884 imgurl=Config.getInstance().getSystemIconURL("cross")
1885 html.append("""
1886 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=%s><img class="imglink" src=%s></a> %s
1887 """%(quoteattr(str(url)), quoteattr(str(imgurl)), scr.getRight(rightKey)))
1888 vars["optionalRights"]="<br>".join(html)
1889 return vars
1892 class WConfModifAC:
1894 def __init__(self, conference, eventType, user):
1895 self.__conf = conference
1896 self._eventType = eventType
1897 self.__user = user
1899 def getHTML( self, params ):
1900 ac = wcomponents.WConfAccessControlFrame().getHTML( self.__conf,\
1901 params["setVisibilityURL"])
1902 dc = ""
1903 if not self.__conf.isProtected():
1904 dc = "<br>%s"%wcomponents.WDomainControlFrame( self.__conf ).getHTML()
1906 mc = wcomponents.WConfModificationControlFrame().getHTML( self.__conf) + "<br>"
1908 if self._eventType == "conference":
1909 rc = wcomponents.WConfRegistrarsControlFrame().getHTML(self.__conf) + "<br>"
1910 else:
1911 rc = ""
1913 tf = ""
1914 if self._eventType in ["conference", "meeting"]:
1915 tf = "<br>%s" % wcomponents.WConfProtectionToolsFrame(self.__conf).getHTML()
1916 cr = ""
1917 if self._eventType == "conference":
1918 cr = "<br>%s" % WConfModifACSessionCoordinatorRights(self.__conf).getHTML()
1920 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)
1923 class WPConfModifAC(WPConferenceModifBase):
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()
1930 self._user = self._rh._getUser()
1932 def _setActiveSideMenuItem(self):
1933 self._ACMenuItem.setActive()
1935 def _getPageContent(self, params):
1936 wc = WConfModifAC(self._conf, self._eventType, self._user)
1937 p = {
1938 'setVisibilityURL': urlHandlers.UHConfSetVisibility.getURL(self._conf)
1940 return wc.getHTML(p)
1942 class WPConfModifToolsBase(WPConferenceModifBase):
1944 def _setActiveSideMenuItem(self):
1945 self._toolsMenuItem.setActive()
1947 def _createTabCtrl(self):
1948 self._tabCtrl = wcomponents.TabControl()
1950 self._tabReminders = self._tabCtrl.newTab('reminders', _("Reminders"),
1951 url_for('event_reminders.list', self._conf))
1952 self._tabCloneEvent = self._tabCtrl.newTab("clone", _("Clone Event"), \
1953 urlHandlers.UHConfClone.getURL(self._conf))
1954 self._tabPosters = self._tabCtrl.newTab("posters", _("Posters"), \
1955 urlHandlers.UHConfModifPosterPrinting.getURL(self._conf))
1956 self._tabBadges = self._tabCtrl.newTab("badges", _("Badges/Tablesigns"), \
1957 urlHandlers.UHConfModifBadgePrinting.getURL(self._conf))
1958 self._tabClose = self._tabCtrl.newTab("close", _("Lock"), \
1959 urlHandlers.UHConferenceClose.getURL(self._conf))
1960 self._tabDelete = self._tabCtrl.newTab("delete", _("Delete"), \
1961 urlHandlers.UHConfDeletion.getURL(self._conf))
1962 self._tabMatPackage = self._tabCtrl.newTab("matPackage", _("Material Package"),
1963 url_for('attachments.package_management', self._conf))
1965 if Config.getInstance().getOfflineStore():
1966 self._tabOffline = self._tabCtrl.newTab("offline", _("Offline copy"),
1967 url_for('static_site.list', self._conf))
1969 self._setActiveTab()
1971 wf = self._rh.getWebFactory()
1972 if wf:
1973 wf.customiseToolsTabCtrl(self._tabCtrl)
1975 def _getPageContent(self, params):
1976 self._createTabCtrl()
1978 html = wcomponents.WTabControl(self._tabCtrl, self._getAW()).getHTML(self._getTabContent(params))
1979 return html
1981 def _setActiveTab(self):
1982 pass
1984 def _getTabContent(self, params):
1985 return "nothing"
1988 class WPConfClosing(WPConfModifToolsBase):
1990 def __init__(self, rh, conf):
1991 WPConferenceModifBase.__init__(self, rh, conf)
1992 self._eventType = "conference"
1993 if self._rh.getWebFactory() is not None:
1994 self._eventType = self._rh.getWebFactory().getId()
1996 def _setActiveTab(self):
1997 self._tabClose.setActive()
1999 def _getTabContent(self, params):
2000 msg = {'challenge': _("Are you sure that you want to lock the event?"),
2001 'target': self._conf.getTitle(),
2002 'subtext': _("Note that if you lock the event, you will not be able to change its details any more. "
2003 "Only the creator of the event or an administrator of the system / category can unlock an event."),
2006 wc = wcomponents.WConfirmation()
2007 return wc.getHTML(msg,
2008 urlHandlers.UHConferenceClose.getURL(self._conf),
2010 severity="warning",
2011 confirmButtonCaption=_("Yes, lock this event"),
2012 cancelButtonCaption=_("No"))
2015 class WPConfDeletion(WPConfModifToolsBase):
2017 def _setActiveTab(self):
2018 self._tabDelete.setActive()
2020 def _getTabContent(self, params):
2021 msg = {'challenge': _("Are you sure that you want to delete the conference?"),
2022 'target': self._conf.getTitle(),
2023 'subtext': _("Note that if you delete the conference, all the items below it will also be deleted")
2026 wc = wcomponents.WConfirmation()
2027 return wc.getHTML(msg,
2028 urlHandlers.UHConfDeletion.getURL(self._conf),
2030 severity="danger",
2031 confirmButtonCaption=_("Yes, I am sure"),
2032 cancelButtonCaption=_("No"))
2035 class WPConfCloneConfirm(WPConfModifToolsBase):
2037 def __init__(self, rh, conf, nbClones):
2038 WPConfModifToolsBase.__init__(self, rh, conf)
2039 self._nbClones = nbClones
2041 def _setActiveTab(self):
2042 self._tabCloneEvent.setActive()
2044 def _getTabContent(self, params):
2046 msg = _("This action will create {0} new events. Are you sure you want to proceed").format(self._nbClones)
2048 wc = wcomponents.WConfirmation()
2049 url = urlHandlers.UHConfPerformCloning.getURL(self._conf)
2050 params = self._rh._getRequestParams()
2051 for key in params.keys():
2052 url.addParam(key, params[key])
2053 return wc.getHTML( msg, \
2054 url, {}, True, \
2055 confirmButtonCaption=_("Yes"), cancelButtonCaption=_("No"))
2057 #---------------------------------------------------------------------------
2060 class WPConferenceModifParticipantBase(WPConferenceModifBase):
2062 def __init__(self, rh, conf):
2063 WPConferenceModifBase.__init__(self, rh, conf)
2065 def _createTabCtrl(self):
2066 self._tabCtrl = wcomponents.TabControl()
2068 self._tabParticipantsSetup = self._tabCtrl.newTab("participantsetup", _("Setup"), urlHandlers.UHConfModifParticipantsSetup.getURL(self._conf))
2069 self._tabParticipantsList = self._tabCtrl.newTab("participantsList", _("Participants"), urlHandlers.UHConfModifParticipants.getURL(self._conf))
2070 self._tabStatistics = self._tabCtrl.newTab("statistics", _("Statistics"), urlHandlers.UHConfModifParticipantsStatistics.getURL(self._conf))
2071 if self._conf.getParticipation().getPendingParticipantList() and nowutc() < self._conf.getStartDate():
2072 self._tabParticipantsPendingList = self._tabCtrl.newTab("pendingList", _("Pending"), urlHandlers.UHConfModifParticipantsPending.getURL(self._conf), className="pendingTab")
2073 if self._conf.getParticipation().getDeclinedParticipantList():
2074 self._tabParticipantsDeclinedList = self._tabCtrl.newTab("declinedList", _("Declined"), urlHandlers.UHConfModifParticipantsDeclined.getURL(self._conf))
2076 self._setActiveTab()
2078 def _getPageContent(self, params):
2079 self._createTabCtrl()
2081 return wcomponents.WTabControl(self._tabCtrl, self._getAW()).getHTML(self._getTabContent(params))
2083 def getJSFiles(self):
2084 return WPConferenceModifBase.getJSFiles(self) + \
2085 self._includeJSPackage('Display')
2087 def _setActiveSideMenuItem(self):
2088 self._participantsMenuItem.setActive()
2090 def _getTabContent(self, params):
2091 return "nothing"
2093 def _setActiveTab(self):
2094 pass
2097 class WConferenceParticipant(wcomponents.WTemplated):
2099 def __init__(self, conference, participant):
2100 self._conf = conference
2101 self._participant = participant
2103 def getVars(self):
2104 vars = wcomponents.WTemplated.getVars(self)
2105 vars["conference"] = self._conf
2106 vars["participant"] = self._participant
2107 return vars
2110 class WConferenceParticipantPending(wcomponents.WTemplated):
2112 def __init__(self, conference, id, pending):
2113 self._conf = conference
2114 self._id = id
2115 self._pending = pending
2117 def getVars(self):
2118 vars = wcomponents.WTemplated.getVars(self)
2119 vars["conference"] = self._conf
2120 vars["id"] = self._id
2121 vars["pending"] = self._pending
2122 return vars
2125 class WConferenceParticipantsSetup(wcomponents.WTemplated):
2127 def __init__(self, conference):
2128 self._conf = conference
2130 def getVars(self):
2131 vars = wcomponents.WTemplated.getVars(self)
2132 vars["confId"] = self._conf.getId()
2133 vars["isObligatory"] = self._conf.getParticipation().isObligatory()
2134 vars["allowDisplay"] = self._conf.getParticipation().displayParticipantList()
2135 vars["addedInfo"] = self._conf.getParticipation().isAddedInfo()
2136 vars["allowForApply"] = self._conf.getParticipation().isAllowedForApplying()
2137 vars["autoAccept"] = self._conf.getParticipation().isAutoAccept()
2138 vars["numMaxParticipants"] = self._conf.getParticipation().getNumMaxParticipants()
2139 vars["notifyMgrNewParticipant"] = self._conf.getParticipation().isNotifyMgrNewParticipant()
2140 return vars
2143 class WPConfModifParticipantsSetup(WPConferenceModifParticipantBase):
2145 def _setActiveTab(self):
2146 self._tabParticipantsSetup.setActive()
2148 def _getTabContent(self, params):
2149 p = WConferenceParticipantsSetup(self._conf)
2150 return p.getHTML(params)
2153 class WConferenceParticipants(wcomponents.WTemplated):
2155 def __init__(self, conference):
2156 self._conf = conference
2158 def getVars(self):
2159 vars = wcomponents.WTemplated.getVars(self)
2161 vars["selectAll"] = Config.getInstance().getSystemIconURL("checkAll")
2162 vars["deselectAll"] = Config.getInstance().getSystemIconURL("uncheckAll")
2164 vars["participantsAction"] = str(urlHandlers.UHConfModifParticipantsAction.getURL(self._conf))
2165 vars["hasStarted"] = nowutc() < self._conf.getStartDate()
2166 vars["currentUser"] = self._rh._aw.getUser()
2167 vars["numberParticipants"] = len(self._conf.getParticipation().getParticipantList())
2168 vars["conf"] = self._conf
2169 vars["excelIconURL"] = quoteattr(str(Config.getInstance().getSystemIconURL("excel")))
2171 return vars
2174 class WPConfModifParticipants(WPConferenceModifParticipantBase):
2176 def _setActiveTab(self):
2177 self._tabParticipantsList.setActive()
2179 def _getTabContent(self, params):
2180 p = WConferenceParticipants(self._conf)
2181 return p.getHTML(params)
2184 class WConferenceParticipantsPending(wcomponents.WTemplated):
2186 def __init__(self, conference):
2187 self._conf = conference
2189 def getVars(self):
2190 vars = wcomponents.WTemplated.getVars(self)
2192 vars["selectAll"] = Config.getInstance().getSystemIconURL("checkAll")
2193 vars["deselectAll"] = Config.getInstance().getSystemIconURL("uncheckAll")
2194 vars["pending"] = self._getPendingParticipantsList()
2195 vars["numberPending"] = self._conf.getParticipation().getPendingNumber()
2196 vars["conf"] = self._conf
2197 vars["conferenceStarted"] = nowutc() > self._conf.getStartDate()
2198 vars["currentUser"] = self._rh._aw.getUser()
2200 return vars
2202 def _getPendingParticipantsList(self):
2203 l = []
2205 for k in self._conf.getParticipation().getPendingParticipantList().keys():
2206 p = self._conf.getParticipation().getPendingParticipantByKey(k)
2207 l.append((k, p))
2208 return l
2211 class WPConfModifParticipantsPending(WPConferenceModifParticipantBase):
2213 def _setActiveTab(self):
2214 self._tabParticipantsPendingList.setActive()
2216 def _getTabContent(self, params):
2217 p = WConferenceParticipantsPending(self._conf)
2218 return p.getHTML()
2221 class WConferenceParticipantsDeclined(wcomponents.WTemplated):
2223 def __init__(self, conference):
2224 self._conf = conference
2226 def getVars(self):
2228 vars = wcomponents.WTemplated.getVars(self)
2229 vars["declined"] = self._getDeclinedParticipantsList()
2230 vars["numberDeclined"] = self._conf.getParticipation().getDeclinedNumber()
2231 return vars
2233 def _getDeclinedParticipantsList(self):
2234 l = []
2236 for k in self._conf.getParticipation().getDeclinedParticipantList().keys():
2237 p = self._conf.getParticipation().getDeclinedParticipantByKey(k)
2238 l.append((k, p))
2239 return l
2242 class WPConfModifParticipantsDeclined(WPConferenceModifParticipantBase):
2244 def _setActiveTab(self):
2245 self._tabParticipantsDeclinedList.setActive()
2247 def _getTabContent(self, params):
2248 p = WConferenceParticipantsDeclined(self._conf)
2249 return p.getHTML()
2252 class WConferenceParticipantsStatistics(wcomponents.WTemplated):
2254 def __init__(self, conference):
2255 self._conf = conference
2257 def getVars(self):
2259 vars = wcomponents.WTemplated.getVars(self)
2260 vars["invited"] = self._conf.getParticipation().getInvitedNumber()
2261 vars["rejected"] = self._conf.getParticipation().getRejectedNumber()
2262 vars["added"] = self._conf.getParticipation().getAddedNumber()
2263 vars["refused"] = self._conf.getParticipation().getRefusedNumber()
2264 vars["pending"] = self._conf.getParticipation().getPendingNumber()
2265 vars["declined"] = self._conf.getParticipation().getDeclinedNumber()
2266 vars["conferenceStarted"] = nowutc() > self._conf.getStartDate()
2267 vars["present"] = self._conf.getParticipation().getPresentNumber()
2268 vars["absent"] = self._conf.getParticipation().getAbsentNumber()
2269 vars["excused"] = self._conf.getParticipation().getExcusedNumber()
2270 return vars
2273 class WPConfModifParticipantsStatistics(WPConferenceModifParticipantBase):
2275 def _setActiveTab(self):
2276 self._tabStatistics.setActive()
2278 def _getTabContent(self, params):
2279 p = WConferenceParticipantsStatistics(self._conf)
2280 return p.getHTML(params)
2283 class WPConfModifParticipantsInvitationBase(WPConferenceDisplayBase):
2285 def _getHeader(self):
2288 wc = wcomponents.WMenuSimpleEventHeader(self._getAW(), self._conf)
2289 return wc.getHTML({"loginURL": self.getLoginURL(),\
2290 "logoutURL": self.getLogoutURL(),\
2291 "confId": self._conf.getId(),\
2292 "currentView": "static",\
2293 "type": WebFactory.getId(),\
2294 "dark": True})
2296 def _getBody(self, params):
2297 return '<div style="margin:10px">{0}</div>'.format(self._getContent(params))
2300 class WPConfModifParticipantsInvite(WPConfModifParticipantsInvitationBase):
2302 def _getContent(self, params):
2303 msg = _("Please indicate whether you want to accept or reject the invitation to '{0}'").format(self._conf.getTitle())
2304 wc = wcomponents.WConfirmation()
2305 url = urlHandlers.UHConfParticipantsInvitation.getURL(self._conf)
2306 url.addParam("participantId",params["participantId"])
2307 return wc.getHTML(msg,
2308 url,
2310 confirmButtonCaption=_("Accept"),
2311 cancelButtonCaption=_("Reject"),
2312 severity="accept")
2314 #---------------------------------------------------------------------------
2316 class WPConfModifParticipantsRefuse(WPConfModifParticipantsInvitationBase):
2318 def _getContent( self, params ):
2319 msg = i18nformat("""
2320 <font size="+2"> _("Are you sure you want to refuse to attend the '%s'")?</font>
2321 """)%(self._conf.getTitle())
2322 wc = wcomponents.WConfirmation()
2323 url = urlHandlers.UHConfParticipantsRefusal.getURL( self._conf )
2324 url.addParam("participantId",params["participantId"])
2325 return wc.getHTML( msg, url, {}, \
2326 confirmButtonCaption= _("Refuse"), cancelButtonCaption= _("Cancel") )
2328 #---------------------------------------------------------------------------
2330 class WConfModifListings( wcomponents.WTemplated ):
2332 def __init__( self, conference ):
2333 self.__conf = conference
2335 def getVars( self ):
2336 vars = wcomponents.WTemplated.getVars( self )
2337 vars["pendingQueuesIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("listing")))
2338 vars["pendingQueuesURL"]=quoteattr(str(urlHandlers.UHConfModifPendingQueues.getURL( self.__conf )))
2339 vars["allSessionsConvenersIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("listing")))
2340 vars["allSessionsConvenersURL"]=quoteattr(str(urlHandlers.UHConfAllSessionsConveners.getURL( self.__conf )))
2341 vars["allSpeakersIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("listing")))
2342 vars["allSpeakersURL"]=quoteattr(str(urlHandlers.UHConfAllSpeakers.getURL( self.__conf )))
2343 return vars
2346 class WPConfModifListings(WPConferenceModifBase):
2348 def __init__(self, rh, conference):
2349 WPConferenceModifBase.__init__(self, rh, conference)
2350 self._createTabCtrl()
2352 def _setActiveSideMenuItem(self):
2353 self._listingsMenuItem.setActive()
2355 def _createTabCtrl(self):
2356 self._tabCtrl = wcomponents.TabControl()
2357 self._subTabSpeakers = self._tabCtrl.newTab('speakers',
2358 _('All Contribution Speakers'),
2359 urlHandlers.UHConfAllSpeakers.getURL(self._conf))
2360 self._subTabConveners = self._tabCtrl.newTab('conveners',
2361 _('All Session Conveners'),
2362 urlHandlers.UHConfAllSessionsConveners.getURL(self._conf))
2363 self._subTabUsers = self._tabCtrl.newTab('users',
2364 _('People Pending'),
2365 urlHandlers.UHConfModifPendingQueues.getURL(self._conf))
2367 def _getPageContent(self, params):
2368 self._setActiveTab()
2369 return wcomponents.WTabControl(self._tabCtrl, self._getAW()).getHTML(self._getTabContent(params))
2371 def _setActiveTab(self):
2372 self._subTabUsers.setActive()
2374 #---------------------------------------------------------------------------
2375 #---------------------------------------------------------------------------
2377 class WConferenceClone(wcomponents.WTemplated):
2379 def __init__(self, conference):
2380 self.__conf = conference
2382 def _getSelectDay(self):
2383 sd = ""
2384 for i in range(31) :
2385 selected = ""
2386 if datetime.today().day == (i+1) :
2387 selected = "selected=\"selected\""
2388 sd += "<OPTION VALUE=\"%d\" %s>%d\n"%(i+1, selected, i+1)
2389 return sd
2391 def _getSelectMonth(self):
2392 sm = ""
2393 month = [ "January", "February", "March", "April", "May", "June",
2394 "July", "August", "September", "October", "November", "December"]
2395 for i in range(12) :
2396 selected = ""
2397 if datetime.today().month == (i+1) :
2398 selected = "selected=\"selected\""
2399 sm += "\t<OPTION VALUE=\"%d\" %s>%s\n"%(i+1, selected, _(month[i]))
2400 return sm
2402 def _getSelectYear(self):
2403 sy = ""
2404 i = 1995
2405 while i < 2015 :
2406 selected = ""
2407 if datetime.today().year == i :
2408 selected = "selected=\"selected\""
2409 sy += "\t<OPTION VALUE=\"%d\" %s>%d\n"%(i, selected, i)
2410 i += 1
2411 return sy
2414 def getVars(self):
2415 vars = wcomponents.WTemplated.getVars(self)
2416 vars["confTitle"] = self.__conf.getTitle()
2417 vars["confId"] = self.__conf.getId()
2418 vars["selectDay"] = self._getSelectDay()
2419 vars["selectMonth"] = self._getSelectMonth()
2420 vars["selectYear"] = self._getSelectYear()
2421 return vars
2424 class WPConfClone(WPConfModifToolsBase):
2426 def _setActiveTab( self ):
2427 self._tabCloneEvent.setActive()
2429 def _getTabContent( self, params ):
2430 p = WConferenceClone( self._conf )
2431 pars = {"cancelURL": urlHandlers.UHConfModifTools.getURL(self._conf),
2432 "cloning": urlHandlers.UHConfPerformCloning.getURL(self._conf),
2433 "cloneOptions": i18nformat("""<li><input type="checkbox" name="cloneTracks" id="cloneTracks" value="1" />_("Tracks")</li>
2434 <li><input type="checkbox" name="cloneTimetable" id="cloneTimetable" value="1" />_("Full timetable")</li>
2435 <li><ul style="list-style-type: none;"><li><input type="checkbox" name="cloneSessions" id="cloneSessions" value="1" />_("Sessions")</li></ul></li>
2436 <li><input type="checkbox" name="cloneRegistration" id="cloneRegistration" value="1" >_("Registration")</li>
2437 <li><input type="checkbox" name="cloneEvaluation" id="cloneEvaluation" value="1" />_("Evaluation")</li>""") }
2438 pars['cloneOptions'] += EventCloner.get_plugin_items(self._conf)
2439 return p.getHTML(pars)
2442 class WConferenceAllSessionsConveners(wcomponents.WTemplated):
2444 def __init__(self, conference):
2445 self.__conf = conference
2447 def getVars(self):
2448 vars = wcomponents.WTemplated.getVars(self)
2449 vars["confTitle"] = self.__conf.getTitle()
2450 vars["confId"] = self.__conf.getId()
2451 vars["convenerSelectionAction"] = quoteattr(str(urlHandlers.UHConfAllSessionsConvenersAction.getURL(self.__conf)))
2452 vars["contribSetIndex"] = 'index'
2453 vars["convenerNumber"] = str(len(self.__conf.getAllSessionsConvenerList()))
2454 vars["conveners"] = self._getAllConveners()
2455 return vars
2457 def _getTimetableURL(self, convener):
2458 url = urlHandlers.UHSessionModifSchedule.getURL(self.__conf)
2459 url.addParam("sessionId", convener.getSession().getId())
2460 if hasattr(convener, "getSlot"):
2461 timetable = "#" + str(convener.getSlot().getStartDate().strftime("%Y%m%d")) + ".s%sl%s" % (convener.getSession().getId(), convener.getSlot().getId())
2462 else:
2463 timetable = "#" + str(convener.getSession().getStartDate().strftime("%Y%m%d"))
2465 return "%s%s" % (url, timetable)
2467 def _getAllConveners(self):
2468 convenersFormatted = []
2469 convenersDict = self.__conf.getAllSessionsConvenerList()
2471 for key, conveners in convenersDict.iteritems():
2472 data = None
2474 for convener in convenersDict[key]:
2476 if not data:
2477 data = {
2478 'email': convener.getEmail(),
2479 'name': convener.getFullName() or '',
2480 'sessions': []
2483 sessionData = {
2484 'title': '',
2485 'urlTimetable': self._getTimetableURL(convener),
2486 'urlSessionModif': None
2489 if isinstance(convener, conference.SlotChair):
2490 title = convener.getSlot().getTitle() or "Block %s" % convener.getSlot().getId()
2491 sessionData['title'] = convener.getSession().getTitle() + ': ' + title
2492 else:
2493 url = urlHandlers.UHSessionModification.getURL(self.__conf)
2494 url.addParam('sessionId', convener.getSession().getId())
2496 sessionData['urlSessionModif'] = str(url)
2497 sessionData['title'] = convener.getSession().getTitle() or ''
2499 data['sessions'].append(sessionData)
2501 convenersFormatted.append(data)
2503 return convenersFormatted
2506 class WPConfAllSessionsConveners(WPConfModifListings):
2508 def _setActiveTab(self):
2509 self._subTabConveners.setActive()
2511 def _getTabContent(self, params):
2512 p = WConferenceAllSessionsConveners(self._conf)
2513 return p.getHTML()
2515 #---------------------------------------------------------------------------------------
2518 class WConfModifAllContribParticipants(wcomponents.WTemplated):
2520 def __init__(self, conference, partIndex):
2521 self._title = _("All participants list")
2522 self._conf = conference
2523 self._order = ""
2524 self._dispopts = ["Email", "Contributions"]
2525 self._partIndex = partIndex
2527 def getVars(self):
2528 vars = wcomponents.WTemplated.getVars(self)
2529 self._url = vars["participantMainPageURL"]
2530 vars["speakers"] = self._getAllParticipants()
2531 vars["participantNumber"] = str(len(self._partIndex.getParticipationKeys()))
2533 return vars
2535 def _getAllParticipants(self):
2536 speakers = []
2538 for key in self._partIndex.getParticipationKeys():
2539 participationList = self._partIndex.getById(key)
2541 if participationList:
2542 participant = participationList[0]
2544 pData = {
2545 'name': participant.getFullName(),
2546 'email': participant.getEmail(),
2547 'contributions': []
2550 for participation in participationList:
2551 contribution = participation.getContribution()
2553 if contribution:
2554 pData['contributions'].append({
2555 'title': contribution.getTitle(),
2556 'url': str(urlHandlers.UHContributionModification.getURL(contribution))
2559 speakers.append(pData)
2561 return speakers
2563 def _getURL(self):
2564 return self._url
2567 class WPConfAllSpeakers(WPConfModifListings):
2569 def _setActiveTab(self):
2570 self._subTabSpeakers.setActive()
2572 def _getTabContent(self, params):
2573 p = WConfModifAllContribParticipants( self._conf, self._conf.getSpeakerIndex() )
2574 return p.getHTML({"title": _("All speakers list"), \
2575 "participantMainPageURL":urlHandlers.UHConfAllSpeakers.getURL(self._conf), \
2576 "participantSelectionAction":quoteattr(str(urlHandlers.UHConfAllSpeakersAction.getURL(self._conf)))})
2579 class WPEMailContribParticipants ( WPConfModifListings):
2580 def __init__(self, rh, conf, participantList):
2581 WPConfModifListings.__init__(self, rh, conf)
2582 self._participantList = participantList
2584 def _getPageContent(self,params):
2585 wc = WEmailToContribParticipants(self._conf, self._getAW().getUser(), self._participantList)
2586 return wc.getHTML()
2588 class WEmailToContribParticipants(wcomponents.WTemplated):
2589 def __init__(self,conf,user,contribParticipantList):
2590 self._conf = conf
2591 try:
2592 self._fromemail = user.getEmail()
2593 except:
2594 self._fromemail = ""
2595 self._contribParticipantList = contribParticipantList
2597 def getVars(self):
2598 vars = wcomponents.WTemplated.getVars( self )
2599 toEmails=[]
2600 toIds=[]
2601 for email in self._contribParticipantList:
2602 if len(email) > 0 :
2603 toEmails.append(email)
2604 vars["From"] = self._fromemail
2605 vars["toEmails"]= ", ".join(toEmails)
2606 vars["emails"]= ",".join(toEmails)
2607 vars["postURL"]=urlHandlers.UHContribParticipantsSendEmail.getURL(self._conf)
2608 vars["subject"]=""
2609 vars["body"]=""
2610 return vars
2611 #---------------------------------------------------------------------------------------
2613 class WPEMailConveners ( WPConfModifListings):
2614 def __init__(self, rh, conf, convenerList):
2615 WPConfModifListings.__init__(self, rh, conf)
2616 self._convenerList = convenerList
2618 def _getPageContent(self,params):
2619 wc = WEmailToConveners(self._conf, self._getAW().getUser(), self._convenerList)
2620 return wc.getHTML()
2622 class WEmailToConveners(wcomponents.WTemplated):
2623 def __init__(self,conf,user,convenerList):
2624 self._conf = conf
2625 try:
2626 self._fromemail = user.getEmail()
2627 except:
2628 self._fromemail = ""
2629 self._convenerList = convenerList
2631 def getVars(self):
2632 vars = wcomponents.WTemplated.getVars( self )
2633 toEmails=[]
2634 toIds=[]
2635 for email in self._convenerList:
2636 if len(email) > 0 :
2637 toEmails.append(email)
2638 vars["From"] = self._fromemail
2639 vars["toEmails"]= ", ".join(toEmails)
2640 vars["emails"]= ",".join(toEmails)
2641 vars["postURL"]=urlHandlers.UHConvenersSendEmail.getURL(self._conf)
2642 vars["subject"]=""
2643 vars["body"]=""
2644 return vars
2646 class WPConfAllParticipants( WPConfModifListings ):
2648 def _getTabContent( self, params ):
2649 p = wcomponents.WConferenceAllParticipants( self._conf )
2650 return p.getHTML()
2652 #---------------------------------------------------------------------------------------
2655 class WConvenerSentMail (wcomponents.WTemplated):
2656 def __init__(self,conf):
2657 self._conf = conf
2659 def getVars(self):
2660 vars = wcomponents.WTemplated.getVars( self )
2661 vars["BackURL"]=quoteattr(str(urlHandlers.UHConfAllSessionsConveners.getURL(self._conf)))
2662 return vars
2664 class WPConvenerSentEmail( WPConfModifListings ):
2665 def _getTabContent(self,params):
2666 wc = WConvenerSentMail(self._conf)
2667 return wc.getHTML()
2670 class WContribParticipationSentMail(wcomponents.WTemplated):
2671 def __init__(self,conf):
2672 self._conf = conf
2674 def getVars(self):
2675 vars = wcomponents.WTemplated.getVars( self )
2676 vars["BackURL"]=quoteattr(str(urlHandlers.UHConfAllSpeakers.getURL(self._conf)))
2677 return vars
2680 class WPContribParticipationSentEmail( WPConfModifListings ):
2681 def _getTabContent(self,params):
2682 wc = WContribParticipationSentMail(self._conf)
2683 return wc.getHTML()
2686 class WConfModifCFA(wcomponents.WTemplated):
2688 def __init__(self, conference):
2689 self._conf = conference
2691 def _getAbstractFieldsHTML(self, vars):
2692 abMgr = self._conf.getAbstractMgr()
2693 enabledText = _("Click to disable")
2694 disabledText = _("Click to enable")
2695 laf = []
2696 urlRemove = str(urlHandlers.UHConfModifCFARemoveOptFld.getURL(self._conf))
2697 laf.append("""<form action="" method="POST">""")
2698 for af in abMgr.getAbstractFieldsMgr().getFields():
2699 urlUp = urlHandlers.UHConfModifCFAAbsFieldUp.getURL(self._conf)
2700 urlUp.addParam("fieldId", af.getId())
2701 urlDown = urlHandlers.UHConfModifCFAAbsFieldDown.getURL(self._conf)
2702 urlDown.addParam("fieldId", af.getId())
2703 if af.isMandatory():
2704 mandatoryText = _("mandatory")
2705 else:
2706 mandatoryText = _("optional")
2707 maxCharText = ""
2708 if isinstance(af, AbstractTextField):
2709 maxCharText = " - "
2710 if int(af.getMaxLength()) != 0:
2711 maxCharText += _("max: %s %s.") % (af.getMaxLength(), af.getLimitation())
2712 else:
2713 maxCharText += _("not limited")
2714 addInfo = "(%s%s)" % (mandatoryText, maxCharText)
2715 url = urlHandlers.UHConfModifCFAOptFld.getURL(self._conf)
2716 url.addParam("fieldId", af.getId())
2717 url = quoteattr("%s#optional" % str(url))
2718 if self._conf.getAbstractMgr().hasEnabledAbstractField(af.getId()):
2719 icon = vars["enablePic"]
2720 textIcon = enabledText
2721 else:
2722 icon = vars["disablePic"]
2723 textIcon = disabledText
2724 if af.getId() == "content":
2725 removeButton = ""
2726 else:
2727 removeButton = "<input type=\"checkbox\" name=\"fieldId\" value=\"%s\">" % af.getId()
2728 laf.append("""
2729 <tr>
2730 <td>
2731 <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>
2732 </td>
2733 <td width="1%%">%s</td>
2734 <td>
2735 &nbsp;<a class="edit-field" href="#" data-id=%s data-fieldType=%s>%s</a> %s
2736 </td>
2737 </tr>
2738 """ % (
2739 url,
2740 icon,
2741 textIcon,
2742 quoteattr(str(urlUp)),
2743 quoteattr(str(Config.getInstance().getSystemIconURL("upArrow"))),
2744 quoteattr(str(urlDown)),
2745 quoteattr(str(Config.getInstance().getSystemIconURL("downArrow"))),
2746 removeButton,
2747 af.getId(),
2748 af.getType(),
2749 af.getCaption(),
2750 addInfo))
2751 laf.append(i18nformat("""
2752 <tr>
2753 <td align="right" colspan="3">
2754 <input type="submit" value="_("remove")" onClick="this.form.action='%s';" class="btn">
2755 <input id="add-field-button" type="submit" value="_("add")" class="btn">
2756 </td>
2757 </tr>
2758 </form>""") % urlRemove)
2759 laf.append("</form>")
2760 return "".join(laf)
2762 def getVars(self):
2763 vars = wcomponents.WTemplated.getVars(self)
2764 abMgr = self._conf.getAbstractMgr()
2766 vars["iconDisabled"] = str(Config.getInstance().getSystemIconURL("disabledSection"))
2767 vars["iconEnabled"] = str(Config.getInstance().getSystemIconURL("enabledSection"))
2769 vars["multipleTracks"] = abMgr.getMultipleTracks()
2770 vars["areTracksMandatory"] = abMgr.areTracksMandatory()
2771 vars["canAttachFiles"] = abMgr.canAttachFiles()
2772 vars["showSelectAsSpeaker"] = abMgr.showSelectAsSpeaker()
2773 vars["isSelectSpeakerMandatory"] = abMgr.isSelectSpeakerMandatory()
2774 vars["showAttachedFilesContribList"] = abMgr.showAttachedFilesContribList()
2776 vars["multipleUrl"] = urlHandlers.UHConfCFASwitchMultipleTracks.getURL(self._conf)
2777 vars["mandatoryUrl"] = urlHandlers.UHConfCFAMakeTracksMandatory.getURL(self._conf)
2778 vars["attachUrl"] = urlHandlers.UHConfCFAAllowAttachFiles.getURL(self._conf)
2779 vars["showSpeakerUrl"] = urlHandlers.UHConfCFAShowSelectAsSpeaker.getURL(self._conf)
2780 vars["speakerMandatoryUrl"] = urlHandlers.UHConfCFASelectSpeakerMandatory.getURL(self._conf)
2781 vars["showAttachedFilesUrl"] = urlHandlers.UHConfCFAAttachedFilesContribList.getURL(self._conf)
2783 vars["setStatusURL"] = urlHandlers.UHConfCFAChangeStatus.getURL(self._conf)
2784 vars["dataModificationURL"] = urlHandlers.UHCFADataModification.getURL(self._conf)
2785 if abMgr.getCFAStatus():
2786 vars["changeTo"] = "False"
2787 vars["status"] = _("ENABLED")
2788 vars["changeStatus"] = _("DISABLE")
2789 vars["startDate"] = format_date(abMgr.getStartSubmissionDate(), format='full')
2790 vars["endDate"] = format_date(abMgr.getEndSubmissionDate(), format='full')
2791 vars["announcement"] = abMgr.getAnnouncement()
2792 vars["disabled"] = ""
2793 modifDL = abMgr.getModificationDeadline()
2794 vars["modifDL"] = i18nformat("""--_("not specified")--""")
2795 if modifDL:
2796 vars["modifDL"] = format_date(modifDL, format='full')
2797 vars["notification"] = i18nformat("""
2798 <table align="left">
2799 <tr>
2800 <td align="right"><b> _("To List"):</b></td>
2801 <td align="left">%s</td>
2802 </tr>
2803 <tr>
2804 <td align="right"><b> _("Cc List"):</b></td>
2805 <td align="left">%s</td>
2806 </tr>
2807 </table>
2808 """) % (", ".join(abMgr.getSubmissionNotification().getToList()) or i18nformat("""--_("no TO list")--"""), ", ".join(abMgr.getSubmissionNotification().getCCList()) or i18nformat("""--_("no CC list")--"""))
2809 else:
2810 vars["changeTo"] = "True"
2811 vars["status"] = _("DISABLED")
2812 vars["changeStatus"] = _("ENABLE")
2813 vars["startDate"] = ""
2814 vars["endDate"] = ""
2815 vars["announcement"] = ""
2816 vars["manage"] = ""
2817 vars["type"] = ""
2818 vars["disabled"] = "disabled"
2819 vars["modifDL"] = ""
2820 vars["submitters"] = ""
2821 vars["notification"] = ""
2822 vars["enablePic"] = quoteattr(str(Config.getInstance().getSystemIconURL("enabledSection")))
2823 vars["disablePic"] = quoteattr(str(Config.getInstance().getSystemIconURL("disabledSection")))
2824 vars["abstractFields"] = self._getAbstractFieldsHTML(vars)
2825 vars["addNotifTplURL"] = urlHandlers.UHAbstractModNotifTplNew.getURL(self._conf)
2826 vars["remNotifTplURL"] = urlHandlers.UHAbstractModNotifTplRem.getURL(self._conf)
2827 vars["confId"] = self._conf.getId()
2828 vars["lateAuthUsers"] = fossilize(self._conf.getAbstractMgr().getAuthorizedSubmitterList())
2829 return vars
2832 class WPConfModifCFAPreview(WPConferenceModifAbstractBase):
2834 def _setActiveTab(self):
2835 self._tabCFAPreview.setActive()
2837 def _getHeadContent(self):
2838 return WPConferenceModifAbstractBase._getHeadContent(self) + render('js/mathjax.config.js.tpl') + \
2839 '\n'.join(['<script src="{0}" type="text/javascript"></script>'.format(url)
2840 for url in self._asset_env['mathjax_js'].urls()])
2842 def getCSSFiles(self):
2843 return WPConferenceModifAbstractBase.getCSSFiles(self) + \
2844 self._asset_env['contributions_sass'].urls()
2846 def getJSFiles(self):
2847 return WPConferenceModifAbstractBase.getJSFiles(self) + \
2848 self._asset_env['abstracts_js'].urls()
2850 def _getTabContent(self, params):
2851 import MaKaC.webinterface.pages.abstracts as abstracts
2852 wc = abstracts.WAbstractDataModification(self._conf)
2853 # Simulate fake abstract
2854 from MaKaC.webinterface.common.abstractDataWrapper import AbstractData
2855 ad = AbstractData(self._conf.getAbstractMgr(), {}, 9999)
2856 params = ad.toDict()
2857 params["postURL"] = ""
2858 params["origin"] = "management"
2859 return wc.getHTML(params)
2862 class WPConfModifCFA(WPConferenceModifAbstractBase):
2864 def _setActiveTab(self):
2865 self._tabCFA.setActive()
2867 def _getTabContent(self, params):
2868 wc = WConfModifCFA(self._conf)
2869 return wc.getHTML()
2872 class WCFADataModification(wcomponents.WTemplated):
2874 def __init__(self, conf):
2875 self._conf = conf
2877 def getVars(self):
2878 vars = wcomponents.WTemplated.getVars(self)
2879 abMgr = self._conf.getAbstractMgr()
2880 vars["sDay"] = abMgr.getStartSubmissionDate().day
2881 vars["sMonth"] = abMgr.getStartSubmissionDate().month
2882 vars["sYear"] = abMgr.getStartSubmissionDate().year
2884 vars["eDay"] = abMgr.getEndSubmissionDate().day
2885 vars["eMonth"] = abMgr.getEndSubmissionDate().month
2886 vars["eYear"] = abMgr.getEndSubmissionDate().year
2888 vars["mDay"] = ""
2889 vars["mMonth"] = ""
2890 vars["mYear"] = ""
2891 if abMgr.getModificationDeadline():
2892 vars["mDay"] = str(abMgr.getModificationDeadline().day)
2893 vars["mMonth"] = str(abMgr.getModificationDeadline().month)
2894 vars["mYear"] = str(abMgr.getModificationDeadline().year)
2896 vars["announcement"] = abMgr.getAnnouncement()
2897 vars["toList"] = ", ".join(abMgr.getSubmissionNotification().getToList())
2898 vars["ccList"] = ", ".join(abMgr.getSubmissionNotification().getCCList())
2899 vars["postURL"] = urlHandlers.UHCFAPerformDataModification.getURL(self._conf)
2900 return vars
2903 class WPCFADataModification(WPConferenceModifAbstractBase):
2905 def _setActiveTab(self):
2906 self._tabCFA.setActive()
2908 def _getTabContent(self, params):
2909 p = WCFADataModification(self._conf)
2910 return p.getHTML()
2913 class WConfModifProgram(wcomponents.WTemplated):
2915 def __init__( self, conference ):
2916 self._conf = conference
2918 def getVars( self ):
2919 vars = wcomponents.WTemplated.getVars(self)
2920 vars["deleteItemsURL"]=urlHandlers.UHConfDelTracks.getURL(self._conf)
2921 vars["addTrackURL"]=urlHandlers.UHConfAddTrack.getURL( self._conf )
2922 vars["conf"] = self._conf
2923 return vars
2926 class WPConfModifProgram( WPConferenceModifBase ):
2928 def _setActiveSideMenuItem( self ):
2929 self._programMenuItem.setActive()
2931 def _getPageContent( self, params ):
2932 wc = WConfModifProgram( self._conf )
2933 return wc.getHTML()
2936 class WTrackCreation( wcomponents.WTemplated ):
2938 def __init__( self, targetConf ):
2939 self.__conf = targetConf
2941 def getVars( self ):
2942 vars = wcomponents.WTemplated.getVars(self)
2943 vars['title'] = ''
2944 vars['description'] = ''
2945 return vars
2949 class WPConfAddTrack( WPConfModifProgram ):
2951 def _setActiveSideMenuItem(self):
2952 self._programMenuItem.setActive()
2954 def _getPageContent( self, params ):
2955 p = WTrackCreation( self._conf )
2956 pars = {"postURL": urlHandlers.UHConfPerformAddTrack.getURL(self._conf)}
2957 return p.getHTML( pars )
2959 class WFilterCriteriaAbstracts(wcomponents.WFilterCriteria):
2961 Draws the options for a filter criteria object
2962 This means rendering the actual table that contains
2963 all the HTML for the several criteria
2966 def __init__(self, options, filterCrit, extraInfo=""):
2967 wcomponents.WFilterCriteria.__init__(self, options, filterCrit, extraInfo)
2969 def _drawFieldOptions(self, id, data):
2970 page = WFilterCriterionOptionsAbstracts(id, data)
2972 # TODO: remove when we have a better template system
2973 return page.getHTML()
2975 class WFilterCriterionOptionsAbstracts(wcomponents.WTemplated):
2977 def __init__(self, id, data):
2978 self._id = id
2979 self._data = data
2981 def getVars(self):
2983 vars = wcomponents.WTemplated.getVars( self )
2985 vars["id"] = self._id
2986 vars["title"] = self._data["title"]
2987 vars["options"] = self._data["options"]
2988 vars["selectFunc"] = self._data.get("selectFunc", True)
2990 return vars
2992 class WAbstracts( wcomponents.WTemplated ):
2994 # available columns
2995 COLUMNS = ["ID", "Title", "PrimaryAuthor", "Tracks", "Type", "Status", "Rating", "AccTrack", "AccType", "SubmissionDate", "ModificationDate"]
2997 def __init__( self, conference, filterCrit, sortingCrit, order, display, filterUsed):
2998 self._conf = conference
2999 self._filterCrit = filterCrit
3000 self._sortingCrit = sortingCrit
3001 self._order = order
3002 self._display = display
3003 self._filterUsed = filterUsed
3005 def _getURL( self, sortingField, column ):
3006 url = urlHandlers.UHConfAbstractManagment.getURL(self._conf)
3007 url.addParam("sortBy", column)
3008 if sortingField and sortingField.getId() == column:
3009 if self._order == "down":
3010 url.addParam("order","up")
3011 elif self._order == "up":
3012 url.addParam("order","down")
3013 return url
3016 def _getTrackFilterItemList( self ):
3017 checked = ""
3018 field=self._filterCrit.getField("track")
3019 if field is not None and field.getShowNoValue():
3020 checked = " checked"
3021 l = [ i18nformat("""<input type="checkbox" name="trackShowNoValue"%s> --_("not specified")--""")%checked]
3022 for t in self._conf.getTrackList():
3023 checked = ""
3024 if field is not None and t.getId() in field.getValues():
3025 checked = " checked"
3026 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())))
3027 return l
3029 def _getContribTypeFilterItemList( self ):
3030 checked = ""
3031 field=self._filterCrit.getField("type")
3032 if field is not None and field.getShowNoValue():
3033 checked = " checked"
3034 l = [ i18nformat("""<input type="checkbox" name="typeShowNoValue"%s> --_("not specified")--""")%checked]
3035 for contribType in self._conf.getContribTypeList():
3036 checked = ""
3037 if field is not None and contribType.getId() in field.getValues():
3038 checked = " checked"
3039 l.append( """<input type="checkbox" name="type" value=%s%s> %s"""%(quoteattr(contribType.getId()), checked, self.htmlText(contribType.getName())) )
3040 return l
3042 def _getAccTrackFilterItemList( self ):
3043 checked = ""
3044 field=self._filterCrit.getField("acc_track")
3045 if field is not None and field.getShowNoValue():
3046 checked = " checked"
3047 l = [ i18nformat("""<input type="checkbox" name="accTrackShowNoValue"%s> --_("not specified")--""")%checked]
3048 for t in self._conf.getTrackList():
3049 checked = ""
3050 if field is not None and t.getId() in field.getValues():
3051 checked=" checked"
3052 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())))
3053 return l
3055 def _getAccContribTypeFilterItemList( self ):
3056 checked = ""
3057 field=self._filterCrit.getField("acc_type")
3058 if field is not None and field.getShowNoValue():
3059 checked = " checked"
3060 l = [ i18nformat("""<input type="checkbox" name="accTypeShowNoValue"%s> --_("not specified")--""")%checked]
3061 for contribType in self._conf.getContribTypeList():
3062 checked = ""
3063 if field is not None and contribType.getId() in field.getValues():
3064 checked = " checked"
3065 l.append( """<input type="checkbox" name="acc_type" value=%s%s> %s"""%(quoteattr(contribType.getId()),checked,self.htmlText(contribType.getName())))
3066 return l
3068 def _getStatusFilterItemList( self ):
3069 l = []
3070 for status in AbstractStatusList.getInstance().getStatusList():
3071 checked = ""
3072 statusId = AbstractStatusList.getInstance().getId( status )
3073 statusCaption = AbstractStatusList.getInstance().getCaption( status )
3074 statusCode=AbstractStatusList.getInstance().getCode(status)
3075 statusIconURL= AbstractStatusList.getInstance().getIconURL( status )
3076 field=self._filterCrit.getField("status")
3077 if field is not None and statusId in field.getValues():
3078 checked = "checked"
3079 imgHTML = """<img src=%s border="0" alt="">"""%(quoteattr(str(statusIconURL)))
3080 l.append( """<input type="checkbox" name="status" value=%s%s>%s (%s) %s"""%(quoteattr(statusId),checked,imgHTML,self.htmlText(statusCode),self.htmlText(statusCaption)))
3081 return l
3083 def _getOthersFilterItemList( self ):
3084 checkedShowMultiple, checkedShowComments = "", ""
3085 track_field=self._filterCrit.getField("track")
3086 if track_field is not None and track_field.onlyMultiple():
3087 checkedShowMultiple = " checked"
3088 if self._filterCrit.getField("comment") is not None:
3089 checkedShowComments = " checked"
3090 l = [ i18nformat("""<input type="checkbox" name="trackShowMultiple"%s> _("only multiple tracks")""")%checkedShowMultiple,
3091 i18nformat("""<input type="checkbox" name="comment"%s> _("only with comments")""")%checkedShowComments]
3092 return l
3094 def _getFilterMenu(self):
3096 options = [
3097 ('Tracks', {"title": _("tracks"),
3098 "options": self._getTrackFilterItemList()}),
3099 ('Types', {"title": _("types"),
3100 "options": self._getContribTypeFilterItemList()}),
3101 ('Status', {"title": _("status"),
3102 "options": self._getStatusFilterItemList()}),
3103 ('AccTracks', {"title": _("(proposed to be) accepted for tracks"),
3104 "options": self._getAccTrackFilterItemList()}),
3105 ('AccTypes', {"title": _("(proposed to be) accepted for types"),
3106 "options": self._getAccContribTypeFilterItemList()}),
3107 ('Others', {"title": _("others"),
3108 "selectFunc": False,
3109 "options": self._getOthersFilterItemList()})
3112 extraInfo = ""
3113 if self._conf.getRegistrationForm().getStatusesList():
3114 extraInfo = i18nformat("""<table align="center" cellspacing="10" width="100%%">
3115 <tr>
3116 <td colspan="5" class="titleCellFormat"> _("Author search") <input type="text" name="authSearch" value=%s></td>
3117 </tr>
3118 </table>
3119 """)%(quoteattr(str(self._authSearch)))
3121 p = WFilterCriteriaAbstracts(options, None, extraInfo)
3123 return p.getHTML()
3126 def _getColumnTitlesDict(self):
3128 Dictionary with the translation from "ids" to "name to display" for each of the options you can choose for the display.
3129 This method complements the method "_setDispOpts" in which we get a dictonary with "ids".
3131 if not hasattr(self, "_columns"):
3132 self._columns = {"ID": "ID","Title": "Title", "PrimaryAuthor": "Primary Author", "Tracks": "Tracks", "Type": "Type", "Status":"Status", \
3133 "Rating":" Rating", "AccTrack": "Acc. Track", "AccType": "Acc. Type", "SubmissionDate": "Submission Date", "ModificationDate": "Modification Date"}
3134 return self._columns
3136 def _getDisplay(self):
3138 These are the 'display' options selected by the user. In case no options were selected we add some of them by default.
3140 display = self._display[:]
3142 if display == []:
3143 display = self.COLUMNS
3144 return display
3146 def _getAccType(self, abstract):
3147 status = abstract.getCurrentStatus()
3148 if isinstance(status,(review.AbstractStatusAccepted, review.AbstractStatusProposedToAccept)) and status.getType() is not None:
3149 return self.htmlText(status.getType().getName())
3150 return ""
3152 def _getAccTrack(self, abstract):
3153 acc_track = abstract.getAcceptedTrack()
3154 if not acc_track:
3155 return ""
3156 return self.htmlText(acc_track.getCode())
3158 def getVars( self ):
3159 vars = wcomponents.WTemplated.getVars(self)
3160 vars["abstractSelectionAction"]=quoteattr(str(urlHandlers.UHAbstractConfSelectionAction.getURL(self._conf)))
3161 vars["confId"] = self._conf.getId()
3162 self._authSearch=vars.get("authSearch","")
3164 vars["filterMenu"] = self._getFilterMenu()
3166 sortingField=None
3167 if self._sortingCrit is not None:
3168 sortingField=self._sortingCrit.getField()
3170 vars["sortingField"] = sortingField.getId()
3171 vars["order"] = self._order
3172 vars["downArrow"] = Config.getInstance().getSystemIconURL("downArrow")
3173 vars["upArrow"] = Config.getInstance().getSystemIconURL("upArrow")
3174 vars["getSortingURL"] = lambda column: self._getURL(sortingField, column)
3175 vars["getAccType"] = lambda abstract: self._getAccType(abstract)
3176 vars["getAccTrack"] = lambda abstract: self._getAccTrack(abstract)
3178 f = filters.SimpleFilter( self._filterCrit, self._sortingCrit )
3179 abstractList=f.apply(self._conf.getAbstractMgr().getAbstractsMatchingAuth(self._authSearch))
3180 if self._order =="up":
3181 abstractList.reverse()
3182 vars["abstracts"] = abstractList
3184 vars["totalNumberAbstracts"] = str(len(self._conf.getAbstractMgr().getAbstractList()))
3185 vars["filteredNumberAbstracts"] = str(len(abstractList))
3186 vars["filterUsed"] = self._filterUsed
3187 vars["accessAbstract"] = quoteattr(str(urlHandlers.UHAbstractDirectAccess.getURL(self._conf)))
3189 url = urlHandlers.UHConfAbstractManagment.getURL(self._conf)
3190 url.setSegment( "results" )
3191 vars["filterPostURL"] = quoteattr(str(url))
3192 vars["excelIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("excel")))
3193 vars["pdfIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("pdf")))
3194 vars["xmlIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("xml")))
3195 vars["displayColumns"] = self._getDisplay()
3196 vars["columnsDict"] = self._getColumnTitlesDict()
3197 vars["columns"] = self.COLUMNS
3199 return vars
3201 class WPConfAbstractList( WPConferenceModifAbstractBase ):
3203 def __init__(self, rh, conf, msg, filterUsed = False ):
3204 self._msg = msg
3205 self._filterUsed = filterUsed
3206 WPConferenceModifAbstractBase.__init__(self, rh, conf)
3208 def _getTabContent( self, params ):
3209 order = params.get("order","down")
3210 wc = WAbstracts( self._conf, params.get("filterCrit", None ),
3211 params.get("sortingCrit", None),
3212 order,
3213 params.get("display",None),
3214 self._filterUsed )
3215 p = {"authSearch":params.get("authSearch","")}
3216 return wc.getHTML( p )
3218 def _setActiveTab(self):
3219 self._tabAbstractList.setActive()
3222 class WPModNewAbstract(WPConfAbstractList):
3224 def __init__(self, rh, conf, abstractData):
3225 WPConfAbstractList.__init__(self, rh, conf, "")
3227 def _getTabContent(self, params):
3228 from MaKaC.webinterface.pages.abstracts import WAbstractDataModification
3229 params["postURL"] = urlHandlers.UHConfModNewAbstract.getURL(self._conf)
3230 params["origin"] = "management"
3231 wc = WAbstractDataModification(self._conf)
3232 return wc.getHTML(params)
3234 def getCSSFiles(self):
3235 return WPConfAbstractList.getCSSFiles(self) + \
3236 self._asset_env['contributions_sass'].urls()
3238 def getJSFiles(self):
3239 return WPConfAbstractList.getJSFiles(self) + \
3240 self._includeJSPackage('Management') + \
3241 self._asset_env['abstracts_js'].urls()
3243 def _getHeadContent(self):
3244 return WPConfAbstractList._getHeadContent(self) + render('js/mathjax.config.js.tpl') + \
3245 '\n'.join(['<script src="{0}" type="text/javascript"></script>'.format(url)
3246 for url in self._asset_env['mathjax_js'].urls()])
3249 class WConfModAbstractsMerge(wcomponents.WTemplated):
3251 def __init__(self,conf):
3252 self._conf=conf
3254 def getVars(self):
3255 vars=wcomponents.WTemplated.getVars(self)
3256 vars["postURL"]=quoteattr(str(urlHandlers.UHConfModAbstractsMerge.getURL(self._conf)))
3257 vars["selAbstracts"]=",".join(vars.get("absIdList",[]))
3258 vars["targetAbs"]=quoteattr(str(vars.get("targetAbsId","")))
3259 vars["inclAuthChecked"]=""
3260 if vars.get("inclAuth",False):
3261 vars["inclAuthChecked"]=" checked"
3262 vars["comments"]=self.htmlText(vars.get("comments",""))
3263 vars["notifyChecked"]=""
3264 if vars.get("notify",False):
3265 vars["notifyChecked"]=" checked"
3266 return vars
3269 class WPModMergeAbstracts(WPConfAbstractList):
3271 def __init__(self, rh, conf):
3272 WPConfAbstractList.__init__(self, rh, conf, "")
3274 def _getTabContent(self, params):
3275 wc = WConfModAbstractsMerge(self._conf)
3276 p = {"absIdList": params.get("absIdList", []),
3277 "targetAbsId": params.get("targetAbsId", ""),
3278 "inclAuth": params.get("inclAuth", False),
3279 "comments": params.get("comments", ""),
3280 "notify": params.get("notify", True),
3282 return wc.getHTML(p)
3286 class WPConfModifDisplayBase( WPConferenceModifBase ):
3288 def _createTabCtrl( self ):
3290 self._tabCtrl = wcomponents.TabControl()
3292 self._tabDisplayCustomization = self._tabCtrl.newTab( "dispCustomization", _("Layout customization"), \
3293 urlHandlers.UHConfModifDisplayCustomization.getURL( self._conf ) )
3294 self._tabDisplayConfHeader = self._tabCtrl.newTab( "displConfHeader", _("Conference header"), \
3295 urlHandlers.UHConfModifDisplayConfHeader.getURL( self._conf ) )
3296 self._tabDisplayMenu = self._tabCtrl.newTab( "dispMenu", _("Menu"), \
3297 urlHandlers.UHConfModifDisplayMenu.getURL( self._conf ) )
3298 self._tabDisplayResources = self._tabCtrl.newTab( "dispResources", _("Images"), \
3299 urlHandlers.UHConfModifDisplayResources.getURL( self._conf ) )
3301 self._setActiveTab()
3303 def _getPageContent( self, params ):
3304 self._createTabCtrl()
3306 html = wcomponents.WTabControl( self._tabCtrl, self._getAW() ).getHTML( self._getTabContent( params ) )
3307 return html
3309 def _getTabContent( self ):
3310 return "nothing"
3312 def _setActiveSideMenuItem( self ):
3313 self._layoutMenuItem.setActive()
3315 class WPConfModifDisplayCustomization( WPConfModifDisplayBase ):
3317 def __init__(self, rh, conf):
3318 WPConfModifDisplayBase.__init__(self, rh, conf)
3320 def _getTabContent( self, params ):
3321 wc = WConfModifDisplayCustom( self._conf )
3322 return wc.getHTML()
3324 def _setActiveTab( self ):
3325 self._tabDisplayCustomization.setActive()
3327 class WConfModifDisplayCustom(wcomponents.WTemplated):
3329 def __init__(self, conf):
3330 self._conf = conf
3331 dm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf)
3332 self._format = dm.getFormat()
3334 def getVars(self):
3335 vars = wcomponents.WTemplated.getVars(self)
3336 vars["conf"]=self._conf
3337 vars["saveLogo"]=urlHandlers.UHSaveLogo.getURL(self._conf)
3338 vars["logoURL"]=""
3339 if self._conf.getLogo():
3340 vars["logoURL"] = urlHandlers.UHConferenceLogo.getURL(self._conf, _=int(time.time()))
3342 vars["formatTitleTextColor"] = WFormatColorOptionModif("titleTextColor", self._format, self._conf, 3).getHTML()
3343 vars["formatTitleBgColor"] = WFormatColorOptionModif("titleBgColor", self._format, self._conf, 4).getHTML()
3345 # Set up the logo of the conference
3346 vars["logoIconURL"] = Config.getInstance().getSystemIconURL("logo")
3347 if vars["logoURL"]:
3348 vars["logo"] = """<img heigth=\"95\" width=\"150\" src="%s" alt="%s" border="0">"""%(vars["logoURL"], self._conf.getTitle())
3349 vars["removeLogo"] = i18nformat("""<form action=%s method="POST"><input type="submit" class="btn" value="_("remove")"></form>""")%quoteattr(str(urlHandlers.UHRemoveLogo.getURL(self._conf)))
3350 else:
3351 vars["logo"] = "<em>No logo has been saved for this conference</em>"
3352 vars["removeLogo"] = ""
3355 #creating css part
3356 vars["saveCSS"]=urlHandlers.UHSaveCSS.getURL(self._conf)
3357 sm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getStyleManager()
3358 if sm.getLocalCSS():
3359 vars["cssDownload"] = sm.getCSS().getURL()
3360 else:
3361 vars["css"] = ""
3362 vars["cssDownload"] = ""
3363 vars["removeCSS"] = str(urlHandlers.UHRemoveCSS.getURL(self._conf))
3364 vars["previewURL"]= urlHandlers.UHConfModifPreviewCSS.getURL(self._conf)
3367 if sm.getCSS():
3368 vars["currentCSSFileName"] = sm.getCSS().getFileName()
3369 else:
3370 vars["currentCSSFileName"] = ""
3371 return vars
3373 class WPConfModifDisplayMenu( WPConfModifDisplayBase ):
3375 def __init__(self, rh, conf, linkId):
3376 WPConfModifDisplayBase.__init__(self, rh, conf)
3377 self._linkId = linkId
3379 def _getTabContent( self, params ):
3380 wc = WConfModifDisplayMenu( self._conf, self._linkId )
3381 return wc.getHTML()
3383 def _setActiveTab( self ):
3384 self._tabDisplayMenu.setActive()
3386 class WConfModifDisplayMenu(wcomponents.WTemplated):
3388 def __init__(self, conf, linkId):
3389 self._conf = conf
3390 dm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf)
3391 self._menu = dm.getMenu()
3392 self._link = self._menu.getLinkById(linkId)
3394 def getVars(self):
3395 vars = wcomponents.WTemplated.getVars(self)
3396 vars["addLinkURL"]=quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._conf)))
3397 vars["addPageURL"]=quoteattr(str(urlHandlers.UHConfModifDisplayAddPage.getURL(self._conf)))
3398 vars["addSpacerURL"]=quoteattr(str(urlHandlers.UHConfModifDisplayAddSpacer.getURL(self._conf)))
3399 vars["menuDisplay"] = ConfEditMenu(self._menu, urlHandlers.UHConfModifDisplayMenu.getURL).getHTML()
3400 vars["confId"] = self._conf.getId()
3401 if self._link:
3402 if isinstance(self._link, displayMgr.SystemLink):
3403 p = {
3404 "dataModificationURL": quoteattr(str(urlHandlers.UHConfModifDisplayModifySystemData.getURL(self._link))), \
3405 "moveUpURL": quoteattr(str(urlHandlers.UHConfModifDisplayUpLink.getURL(self._link))), \
3406 "imageUpURL": quoteattr(str(Config.getInstance().getSystemIconURL("upArrow"))), \
3407 "moveDownURL": quoteattr(str(urlHandlers.UHConfModifDisplayDownLink.getURL(self._link))), \
3408 "imageDownURL": quoteattr(str(Config.getInstance().getSystemIconURL("downArrow")))
3410 name = self._link.getName()
3411 if name == "timetable":
3412 vars["linkEdition"] = WTimetableModif(self._link).getHTML(p)
3413 else:
3414 vars["linkEdition"] = WSystemLinkModif(self._link).getHTML(p)
3415 elif isinstance(self._link, displayMgr.Spacer):
3416 p = {
3417 "removeLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayRemoveLink.getURL(self._link))), \
3418 "toggleLinkStatusURL": quoteattr(str(urlHandlers.UHConfModifDisplayToggleLinkStatus.getURL(self._link))), \
3419 "moveUpURL": quoteattr(str(urlHandlers.UHConfModifDisplayUpLink.getURL(self._link))), \
3420 "imageUpURL": quoteattr(str(Config.getInstance().getSystemIconURL("upArrow"))), \
3421 "moveDownURL": quoteattr(str(urlHandlers.UHConfModifDisplayDownLink.getURL(self._link))), \
3422 "imageDownURL": quoteattr(str(Config.getInstance().getSystemIconURL("downArrow")))
3424 vars["linkEdition"] = WSpacerModif(self._link).getHTML(p)
3425 elif isinstance(self._link, displayMgr.ExternLink):
3426 p = {
3427 "dataModificationURL": quoteattr(str(urlHandlers.UHConfModifDisplayModifyData.getURL(self._link))), \
3428 "removeLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayRemoveLink.getURL(self._link))), \
3429 "addSubLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._link))), \
3430 "toggleLinkStatusURL": quoteattr(str(urlHandlers.UHConfModifDisplayToggleLinkStatus.getURL(self._link))), \
3431 "moveUpURL": quoteattr(str(urlHandlers.UHConfModifDisplayUpLink.getURL(self._link))), \
3432 "imageUpURL": quoteattr(str(Config.getInstance().getSystemIconURL("upArrow"))), \
3433 "moveDownURL": quoteattr(str(urlHandlers.UHConfModifDisplayDownLink.getURL(self._link))), \
3434 "imageDownURL": quoteattr(str(Config.getInstance().getSystemIconURL("downArrow"))) }
3435 vars["linkEdition"] = WLinkModif(self._link).getHTML(p)
3436 else:
3437 p = {
3438 "dataModificationURL": quoteattr(str(urlHandlers.UHConfModifDisplayModifyData.getURL(self._link))), \
3439 "removeLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayRemoveLink.getURL(self._link))), \
3440 "toggleLinkStatusURL": quoteattr(str(urlHandlers.UHConfModifDisplayToggleLinkStatus.getURL(self._link))), \
3441 "toggleHomePageURL": quoteattr(str(urlHandlers.UHConfModifDisplayToggleHomePage.getURL(self._link))), \
3442 "moveUpURL": quoteattr(str(urlHandlers.UHConfModifDisplayUpLink.getURL(self._link))), \
3443 "imageUpURL": quoteattr(str(Config.getInstance().getSystemIconURL("upArrow"))), \
3444 "moveDownURL": quoteattr(str(urlHandlers.UHConfModifDisplayDownLink.getURL(self._link))), \
3445 "imageDownURL": quoteattr(str(Config.getInstance().getSystemIconURL("downArrow"))) }
3446 vars["linkEdition"] = WPageLinkModif(self._link).getHTML(p)
3447 else:
3448 vars["linkEdition"] = i18nformat("""<center><b> _("Click on an item of the menu to edit it")</b></center>""")
3450 return vars
3452 class WPConfModifDisplayResources( WPConfModifDisplayBase ):
3454 def __init__(self, rh, conf):
3455 WPConfModifDisplayBase.__init__(self, rh, conf)
3457 def _getTabContent( self, params ):
3458 wc = WConfModifDisplayResources( self._conf)
3459 return wc.getHTML()
3461 def _setActiveTab( self ):
3462 self._tabDisplayResources.setActive()
3464 class WConfModifDisplayResources(wcomponents.WTemplated):
3466 def __init__(self, conf):
3467 self._conf = conf
3469 def getVars(self):
3470 vars = wcomponents.WTemplated.getVars(self)
3471 vars["savePic"]=urlHandlers.UHSavePic.getURL(self._conf)
3472 #creating picture items for each saved picture
3473 vars["picsList"] = []
3474 im = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getImagesManager()
3475 for pic in im.getPicList().values():
3476 vars["picsList"].append({"id":pic.getId(),
3477 "picURL": str(urlHandlers.UHConferencePic.getURL(pic))})
3478 return vars
3480 class WPConfModifDisplayConfHeader( WPConfModifDisplayBase ):
3482 def __init__(self, rh, conf, optionalParams={}):
3483 WPConfModifDisplayBase.__init__(self, rh, conf)
3484 self._optionalParams=optionalParams
3486 def _getTabContent( self, params ):
3487 wc = WConfModifDisplayConfHeader( self._conf)
3488 return wc.getHTML(self._optionalParams)
3490 def _setActiveTab( self ):
3491 self._tabDisplayConfHeader.setActive()
3493 class WConfModifDisplayConfHeader(wcomponents.WTemplated):
3495 def __init__(self, conf):
3496 self._conf = conf
3497 dm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf)
3498 self._tickerTape=dm.getTickerTape()
3499 self._searchEnabled = dm.getSearchEnabled()
3501 def getVars(self):
3502 vars = wcomponents.WTemplated.getVars(self)
3504 #indico-style "checkboxes"
3505 vars["enablePic"]=quoteattr(str(Config.getInstance().getSystemIconURL( "enabledSection" )))
3506 vars["disablePic"]=quoteattr(str(Config.getInstance().getSystemIconURL( "disabledSection" )))
3507 enabledText = _("Click to disable")
3508 disabledText = _("Click to enable")
3510 # ------ Ticker Tape: ------
3511 # general
3512 vars["tickertapeURL"]=quoteattr(str(urlHandlers.UHTickerTapeAction.getURL(self._conf)))
3513 status= _("DISABLED")
3514 btnLabel= _("Enable")
3515 statusColor = "#612828"
3516 if self._tickerTape.isSimpleTextEnabled():
3517 statusColor = "#286135"
3518 status= _("ENABLED")
3519 btnLabel= _("Disable")
3520 vars["status"]= """<span style="color: %s;">%s</span>""" %(statusColor,status)
3521 vars["statusBtn"]=btnLabel
3522 # annoucements
3523 urlNP=urlHandlers.UHTickerTapeAction.getURL(self._conf)
3524 urlNP.addParam("nowHappening", "action")
3525 if self._tickerTape.isNowHappeningEnabled():
3526 vars["nowHappeningIcon"]=vars["enablePic"]
3527 vars["nowHappeningTextIcon"]=enabledText
3528 else:
3529 vars["nowHappeningIcon"]=vars["disablePic"]
3530 vars["nowHappeningTextIcon"]=disabledText
3531 vars["nowHappeningURL"]=quoteattr("%s#tickerTape"%str(urlNP))
3533 urlST=urlHandlers.UHTickerTapeAction.getURL(self._conf)
3534 urlST.addParam("simpleText", "action")
3535 vars["simpleTextURL"]=quoteattr("%s#tickerTape"%urlST)
3536 # simple ext
3537 vars["text"]=quoteattr(self._tickerTape.getText())
3538 if not vars.has_key("modifiedText"):
3539 vars["modifiedText"]=""
3540 else:
3541 vars["modifiedText"]= i18nformat("""<font color="green"> _("(text saved)")</font>""")
3543 #enable or disable the contribution search feature
3544 urlSB=urlHandlers.UHConfModifToggleSearch.getURL(self._conf)
3545 if self._searchEnabled:
3546 vars["searchBoxIcon"]=vars["enablePic"]
3547 vars["searchBoxTextIcon"]=enabledText
3548 else:
3549 vars["searchBoxIcon"]=vars["disablePic"]
3550 vars["searchBoxTextIcon"]=disabledText
3551 vars["searchBoxURL"]=quoteattr(str(urlSB))
3553 #enable or disable navigation icons
3554 vars["confType"] = self._conf.getType()
3555 urlSB=urlHandlers.UHConfModifToggleNavigationBar.getURL(self._conf)
3556 if displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getDisplayNavigationBar():
3557 vars["navigationBoxIcon"]=vars["enablePic"]
3558 vars["navigationBoxTextIcon"]=enabledText
3559 else:
3560 vars["navigationBoxIcon"]=vars["disablePic"]
3561 vars["navigationBoxTextIcon"]=disabledText
3562 vars["navigationBoxURL"]=quoteattr(str(urlSB))
3564 return vars
3566 class WFormatColorOptionModif(wcomponents.WTemplated):
3568 def __init__(self, formatOption, format, conf, formId=4):
3569 self._formatOption = formatOption
3570 self._format = format
3571 self._conf = conf
3573 # The form number on the page... used for the color picker
3574 self._formId = formId
3576 def getVars(self):
3577 vars = wcomponents.WTemplated.getVars(self)
3578 value = self._format.getFormatOption(self._formatOption)
3580 urlChangeColor = value["url"].getURL(self._conf)
3581 urlChangeColor.addParam("formatOption",self._formatOption)
3583 vars["changeColorURL"] = str(urlChangeColor)
3584 vars["colorCode"] = value["code"]
3585 vars["formatOption"] = self._formatOption
3587 return vars
3589 class ConfEditMenu:
3591 def __init__(self, menu, modifURLGen=None):
3592 self._menu = menu
3593 self._linkModifHandler = modifURLGen
3595 def getHTML(self):
3596 html = ["<table>"]
3597 for link in self._menu.getLinkList():
3598 html.append(self._getLinkHTML(link))
3599 html.append("</table>")
3600 return "".join(html)
3602 def _getLinkHTML(self, link, indent=""):
3603 if self._menu.linkHasToBeDisplayed(link):
3604 disabled = i18nformat("""<font size="-1" color="red"> _("(disabled)")</font>""")
3605 if link.isEnabled():
3606 disabled = ""
3607 if link.getType() == "spacer":
3608 html = """<tr><td></td><td nowrap><a href="%s">[%s]</a>%s</td></tr>\n"""%(self._linkModifHandler(link), link.getName(), disabled)
3609 else:
3610 system = "<font size=-1>E </font>"
3611 home = ""
3612 if isinstance(link, displayMgr.SystemLink):
3613 system = "<font size=-1 color=\"green\">S </font>"
3614 if isinstance(link, displayMgr.PageLink):
3615 if link.getPage().isHome():
3616 home = "&nbsp;<font size=-1 color=\"green\">(home)</font>"
3617 system = "<font size=-1 color=\"black\">P </font>"
3618 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)]
3619 for l in link.getLinkList():
3620 html.append( self._getLinkHTML(l, "%s%s"%(indent ,self._menu.getIndent())))
3621 return "".join(html)
3622 return ""
3625 class WLinkModif(wcomponents.WTemplated):
3626 def __init__(self, link):
3627 self._link = link
3629 def getVars(self):
3630 vars = wcomponents.WTemplated.getVars(self)
3632 vars["linkName"] = self._link.getCaption()
3633 vars["linkURL"] = self._link.getURL()
3634 vars["displayTarget"] = _("Display in the SAME window")
3635 if self._link.getDisplayTarget() == "_blank":
3636 vars["displayTarget"] = _("Display in a NEW window")
3637 if self._link.isEnabled():
3638 vars["linkStatus"] = _("Activated")
3639 vars["changeStatusTo"] = _("Disable")
3640 else:
3641 vars["linkStatus"] = _("Disabled")
3642 vars["changeStatusTo"] = _("Activate")
3644 return vars
3646 class WPageLinkModif(wcomponents.WTemplated):
3648 def __init__(self, link):
3649 self._link = link
3651 def getVars(self):
3652 vars = wcomponents.WTemplated.getVars(self)
3654 vars["linkName"] = self._link.getCaption()
3655 vars["linkContent"] = self.htmlText("%s..."%self._link.getPage().getContent()[0:50])
3656 vars["displayTarget"] = _("Display in the SAME window")
3657 if self._link.getDisplayTarget() == "_blank":
3658 vars["displayTarget"] = _("Display in a NEW window")
3659 if self._link.isEnabled():
3660 vars["linkStatus"] = _("Activated")
3661 vars["changeStatusTo"] = _("Disable")
3662 else:
3663 vars["linkStatus"] = _("Disabled")
3664 vars["changeStatusTo"] = _("Activate")
3665 if self._link.getPage().isHome():
3666 vars["homeText"] = _("Default conference home page")
3667 vars["changeHomeTo"] = _("Normal page")
3668 else:
3669 vars["homeText"] = _("Normal page")
3670 vars["changeHomeTo"] = _("Default conference home page")
3671 return vars
3673 class WSystemLinkModif(wcomponents.WTemplated):
3675 def __init__(self, link):
3676 self._link = link
3678 def getVars(self):
3679 vars = wcomponents.WTemplated.getVars(self)
3680 vars["linkName"] = self._link.getCaption()
3681 vars["linkStatus"] = _("Disabled")
3682 vars["changeStatusTo"] = _("Activate")
3683 if self._link.isEnabled():
3684 vars["linkStatus"] = _("Activated")
3685 vars["changeStatusTo"] = _("Disable")
3686 url=urlHandlers.UHConfModifDisplayToggleLinkStatus.getURL(self._link)
3687 vars["toggleLinkStatusURL"]=quoteattr(str(url))
3688 return vars
3690 class WTimetableModif(WSystemLinkModif):
3692 def getVars(self):
3693 wvars = WSystemLinkModif.getVars(self)
3694 # Timetable detailed view
3695 wvars["viewMode"] = _("Generic")
3696 wvars["changeViewModeTo"] = _("Detailed")
3697 if self._link.getMenu().is_timetable_detailed_view():
3698 wvars["viewMode"] = _("Detailed")
3699 wvars["changeViewModeTo"] = _("Generic")
3700 wvars["toggleTimetableViewURL"] = str(urlHandlers.UHConfModifDisplayToggleTimetableView.getURL(self._link))
3701 # Timeable Layout
3702 wvars["defaultTTLayout"] = _("Normal")
3703 wvars["changedefaultTTLayoutTo"] = _("By room")
3704 if self._link.getMenu().get_timetable_layout() == 'room':
3705 wvars["defaultTTLayout"] = _("By room")
3706 wvars["changedefaultTTLayoutTo"] = _("Normal")
3707 wvars["toggleTTDefaultLayoutURL"] = str(urlHandlers.UHConfModifDisplayToggleTTDefaultLayout.getURL(self._link))
3708 return wvars
3711 class WSpacerModif(wcomponents.WTemplated):
3712 def __init__(self, link):
3713 self._link = link
3715 def getVars(self):
3716 vars = wcomponents.WTemplated.getVars(self)
3717 vars["linkName"] = self._link.getName()
3718 if self._link.isEnabled():
3719 vars["linkStatus"] = _("Activated")
3720 vars["changeStatusTo"] = _("Disable")
3721 else:
3722 vars["linkStatus"] = _("Disabled")
3723 vars["changeStatusTo"] = _("Activate")
3724 return vars
3726 class WPConfModifDisplayAddPage( WPConfModifDisplayBase ):
3728 def __init__(self, rh, conf, linkId):
3729 WPConfModifDisplayBase.__init__(self, rh, conf)
3730 self._linkId = linkId
3731 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3732 if linkId:
3733 self._link = self._menu.getLinkById(linkId)
3734 else:
3735 self._link = self._menu
3737 def _setActiveTab( self ):
3738 self._tabDisplayMenu.setActive()
3740 def _getTabContent( self, params ):
3741 return WConfModifDisplayAddPage( self._conf, self._linkId ).getHTML()
3744 class WConfModifDisplayAddPage(wcomponents.WTemplated):
3746 def __init__(self, conf, linkId):
3747 self._conf = conf
3748 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3749 if linkId:
3750 self._link = self._menu.getLinkById(linkId)
3751 else:
3752 self._link = self._menu
3754 def getVars(self):
3755 vars = wcomponents.WTemplated.getVars(self)
3756 vars["saveLinkURL"] = quoteattr(str(urlHandlers.UHConfModifDisplayAddPage.getURL(self._link)))
3757 vars["content"]=""
3758 return vars
3760 class WPConfModifDisplayAddLink( WPConfModifDisplayBase ):
3761 def __init__(self, rh, conf, linkId):
3762 WPConfModifDisplayBase.__init__(self, rh, conf)
3763 self._linkId = linkId
3764 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3765 if linkId:
3766 self._link = self._menu.getLinkById(linkId)
3767 else:
3768 self._link = self._menu
3770 def _setActiveTab( self ):
3771 self._tabDisplayMenu.setActive()
3773 def _getTabContent( self, params ):
3774 wc = WConfModifDisplayAddLink( self._conf, self._linkId )
3775 p = {"addLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._conf))), \
3776 "addPageURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddPage.getURL(self._conf))), \
3777 "addSpacerURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddSpacer.getURL(self._conf))) }
3778 return wc.getHTML( p )
3781 class WConfModifDisplayAddLink(wcomponents.WTemplated):
3783 def __init__(self, conf, linkId):
3784 self._conf = conf
3785 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3786 if linkId:
3787 self._link = self._menu.getLinkById(linkId)
3788 else:
3789 self._link = self._menu
3791 def getVars(self):
3792 vars = wcomponents.WTemplated.getVars(self)
3793 vars["menuDisplay"] = ConfEditMenu(self._menu, urlHandlers.UHConfModifDisplay.getURL).getHTML()
3794 vars["saveLinkURL"] = quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._link)))
3795 return vars
3798 class WPConfModifDisplayModifyData( WPConfModifDisplayBase ):
3799 def __init__(self, rh, conf, link):
3800 WPConfModifDisplayBase.__init__(self, rh, conf)
3801 self._link = link
3802 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3804 def _setActiveTab( self ):
3805 self._tabDisplayMenu.setActive()
3807 def _getTabContent( self, params ):
3808 wc = WConfModifDisplayModifyData( self._conf, self._link )
3809 p = {
3810 "modifyDataURL": quoteattr(str(urlHandlers.UHConfModifDisplayModifyData.getURL(self._link))), \
3811 "addLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._conf))), \
3812 "addPageURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddPage.getURL(self._conf))), \
3813 "addSpacerURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddSpacer.getURL(self._conf))) }
3814 return wc.getHTML( p )
3816 class WConfModifDisplayModifyData(wcomponents.WTemplated):
3818 def __init__(self, conf, link):
3819 self._conf = conf
3820 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3821 self._link = link
3824 def getVars(self):
3825 vars = wcomponents.WTemplated.getVars(self)
3826 vars["menuDisplay"] = ConfEditMenu(self._menu, urlHandlers.UHConfModifDisplay.getURL).getHTML()
3827 vars["saveLinkURL"] = quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._link)))
3828 vars["name"] = self._link.getCaption()
3829 vars["value_name"] = quoteattr(self._link.getCaption())
3830 vars["url"] = self._link.getURL()
3831 if self._link.getDisplayTarget() == "_blank":
3832 vars["newChecked"] = _("""CHECKED""")
3833 vars["sameChecked"] = ""
3834 else:
3835 vars["newChecked"] = ""
3836 vars["sameChecked"] = _("""CHECKED""")
3838 return vars
3842 class WPConfModifDisplayModifyPage( WPConfModifDisplayBase ):
3843 def __init__(self, rh, conf, link):
3844 WPConfModifDisplayBase.__init__(self, rh, conf)
3845 self._link = link
3846 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3848 def _setActiveTab( self ):
3849 self._tabDisplayMenu.setActive()
3851 def _getTabContent( self, params ):
3852 wc = WConfModifDisplayModifyPage( self._conf, self._link )
3853 p = {
3854 "modifyDataURL": quoteattr(str(urlHandlers.UHConfModifDisplayModifyData.getURL(self._link))) }
3855 return wc.getHTML( p )
3857 class WConfModifDisplayModifyPage(wcomponents.WTemplated):
3859 def __init__(self, conf, link):
3860 self._conf = conf
3861 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3862 self._link = link
3865 def getVars(self):
3866 vars = wcomponents.WTemplated.getVars(self)
3867 vars["saveLinkURL"] = quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._link)))
3868 vars["name"] = self._link.getCaption()
3869 vars["value_name"] = quoteattr(self._link.getCaption())
3870 vars["content"] = self._link.getPage().getContent().replace('"','\\"').replace("'","\\'").replace('\r\n','\\n').replace('\n','\\n')
3871 if self._link.getDisplayTarget() == "_blank":
3872 vars["newChecked"] = _("""CHECKED""")
3873 vars["sameChecked"] = ""
3874 else:
3875 vars["newChecked"] = ""
3876 vars["sameChecked"] = _("""CHECKED""")
3877 return vars
3879 class WPConfModifDisplayModifySystemData( WPConfModifDisplayBase ):
3880 def __init__(self, rh, conf, link):
3881 WPConfModifDisplayBase.__init__(self, rh, conf)
3882 self._link = link
3883 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3885 def _setActiveTab( self ):
3886 self._tabDisplayMenu.setActive()
3888 def _getTabContent( self, params ):
3889 wc = WConfModifDisplayModifySystemData( self._conf, self._link )
3890 p = {
3891 "modifyDataURL": quoteattr(str(urlHandlers.UHConfModifDisplayModifySystemData.getURL(self._link))), \
3892 "addLinkURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddLink.getURL(self._conf))), \
3893 "addPageURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddPage.getURL(self._conf))), \
3894 "addSpacerURL": quoteattr(str(urlHandlers.UHConfModifDisplayAddSpacer.getURL(self._conf))) }
3895 return wc.getHTML( p )
3897 class WConfModifDisplayModifySystemData(wcomponents.WTemplated):
3899 def __init__(self, conf, link):
3900 self._conf = conf
3901 self._menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
3902 self._link = link
3905 def getVars(self):
3906 vars = wcomponents.WTemplated.getVars(self)
3907 vars["menuDisplay"] = ConfEditMenu(self._menu, urlHandlers.UHConfModifDisplay.getURL).getHTML()
3908 vars["saveLinkURL"] = quoteattr(str(urlHandlers.UHConfModifDisplayModifySystemData.getURL(self._link)))
3909 vars["name"] = self._link.getCaption()
3910 vars["value_name"] = quoteattr(self._link.getCaption())
3911 return vars
3914 class WPConfModifDisplayRemoveLink( WPConfModifDisplayBase ):
3915 def __init__(self, rh, conf, link):
3916 WPConfModifDisplayBase.__init__(self, rh, conf)
3917 self._link = link
3919 def _setActiveTab( self ):
3920 self._tabDisplayMenu.setActive()
3922 def _getTabContent( self, params ):
3924 msg = {
3925 'challenge': _("Are you sure that you want to delete this link?"),
3926 'target': self._link.getName()
3929 postURL = quoteattr(str(urlHandlers.UHConfModifDisplayRemoveLink.getURL(self._link)))
3930 return wcomponents.WConfirmation().getHTML( msg, postURL, {})
3933 class WPConfParticipantList( WPConfAbstractList ):
3935 def __init__(self, rh, conf, emailList, displayedGroups, abstracts):
3936 WPConfAbstractList.__init__(self, rh, conf, None)
3937 self._emailList = emailList
3938 self._displayedGroups = displayedGroups
3939 self._abstracts = abstracts
3941 def _getTabContent( self, params ):
3942 wc = WAbstractsParticipantList(self._conf, self._emailList, self._displayedGroups, self._abstracts)
3943 return wc.getHTML()
3945 class WPConfModifParticipantList( WPConferenceBase ):
3947 def __init__(self, rh, conf, emailList, displayedGroups, contribs):
3948 WPConferenceBase.__init__(self, rh, conf)
3949 self._emailList = emailList
3950 self._displayedGroups = displayedGroups
3951 self._contribs = contribs
3953 def _getBody( self, params ):
3954 WPConferenceBase._getBody(self, params)
3955 wc = WContribParticipantList(self._conf, self._emailList, self._displayedGroups, self._contribs)
3956 params = {"urlDisplayGroup":urlHandlers.UHContribsConfManagerDisplayParticipantList.getURL(self._conf)}
3957 return wc.getHTML(params)
3960 class WConfModifContribList(wcomponents.WTemplated):
3962 def __init__(self,conf,filterCrit, sortingCrit, order, filterUsed=False, filterUrl=None):
3963 self._conf=conf
3964 self._filterCrit=filterCrit
3965 self._sortingCrit=sortingCrit
3966 self._order = order
3967 self._totaldur =timedelta(0)
3968 self._filterUsed = filterUsed
3969 self._filterUrl = filterUrl
3972 def _getURL( self ):
3973 #builds the URL to the contribution list page
3974 # preserving the current filter and sorting status
3975 url = urlHandlers.UHConfModifContribList.getURL(self._conf)
3977 #save params in websession
3978 dict = session.setdefault('ContributionFilterConf%s' % self._conf.getId(), {})
3979 if self._filterCrit.getField("type"):
3980 l=[]
3981 for t in self._filterCrit.getField("type").getValues():
3982 if t!="":
3983 l.append(t)
3984 dict["types"] = l
3985 if self._filterCrit.getField("type").getShowNoValue():
3986 dict["typeShowNoValue"] = "1"
3988 if self._filterCrit.getField("track"):
3989 dict["tracks"] = self._filterCrit.getField("track").getValues()
3990 if self._filterCrit.getField("track").getShowNoValue():
3991 dict["trackShowNoValue"] = "1"
3993 if self._filterCrit.getField("session"):
3994 dict["sessions"] = self._filterCrit.getField("session").getValues()
3995 if self._filterCrit.getField("session").getShowNoValue():
3996 dict["sessionShowNoValue"] = "1"
3998 if self._filterCrit.getField("status"):
3999 dict["status"] = self._filterCrit.getField("status").getValues()
4001 if self._filterCrit.getField("material"):
4002 dict["material"] = self._filterCrit.getField("material").getValues()
4004 if self._sortingCrit.getField():
4005 dict["sortBy"] = self._sortingCrit.getField().getId()
4006 dict["order"] = "down"
4007 dict["OK"] = "1"
4008 session.modified = True
4010 return url
4013 def _getMaterialsHTML(self, contrib):
4014 materials=[]
4015 if contrib.getPaper() is not None:
4016 url= urlHandlers.UHContribModifMaterialBrowse.getURL(contrib.getPaper())
4017 #url.addParams({'contribId' : contrib.getId(), 'confId' : contrib.getConference().getId(), 'materialId' : 'paper'})
4018 materials.append("""<a href=%s>%s</a>"""%(quoteattr(str(url)),self.htmlText(PaperFactory().getTitle().lower())))
4019 if contrib.getSlides() is not None:
4020 url= urlHandlers.UHContribModifMaterialBrowse.getURL(contrib.getSlides())
4021 #url.addParams({'contribId' : contrib.getId(), 'confId' : contrib.getConference().getId(), 'materialId' : 'slides'})
4022 materials.append("""<a href=%s>%s</a>"""%(quoteattr(str(url)),self.htmlText(SlidesFactory().getTitle().lower())))
4023 if contrib.getPoster() is not None:
4024 url= urlHandlers.UHContribModifMaterialBrowse.getURL(contrib.getPoster())
4025 #url.addParams({'contribId' : contrib.getId(), 'confId' : contrib.getConference().getId(), 'materialId' : 'poster'})
4026 materials.append("""<a href=%s>%s</a>"""%(quoteattr(str(url)),self.htmlText(PosterFactory().getTitle().lower())))
4027 if contrib.getVideo() is not None:
4028 materials.append("""<a href=%s>%s</a>"""%(
4029 quoteattr(str(urlHandlers.UHContribModifMaterials.getURL(contrib))),
4030 self.htmlText(materialFactories.VideoFactory.getTitle())))
4031 for material in contrib.getMaterialList():
4032 url=urlHandlers.UHContribModifMaterials.getURL(contrib)
4033 materials.append("""<a href=%s>%s</a>"""%(
4034 quoteattr(str(url)),self.htmlText(material.getTitle())))
4035 return "<br>".join(materials)
4037 def _getContribHTML( self, contrib ):
4038 try:
4039 sdate=contrib.getAdjustedStartDate().strftime("%d-%b-%Y %H:%M" )
4040 except AttributeError:
4041 sdate = ""
4042 title = """<a href=%s>%s</a>"""%( quoteattr( str( urlHandlers.UHContributionModification.getURL( contrib ) ) ), self.htmlText( contrib.getTitle() ))
4043 strdur = ""
4044 if contrib.getDuration() is not None and contrib.getDuration().seconds != 0:
4045 strdur = (datetime(1900,1,1)+ contrib.getDuration()).strftime("%Hh%M'")
4046 dur = contrib.getDuration()
4047 self._totaldur = self._totaldur + dur
4049 l = [self.htmlText( spk.getFullName() ) for spk in contrib.getSpeakerList()]
4050 speaker = "<br>".join( l )
4051 session = ""
4052 if contrib.getSession() is not None:
4053 if contrib.getSession().getCode() != "no code":
4054 session=self.htmlText(contrib.getSession().getCode())
4055 else:
4056 session=self.htmlText(contrib.getSession().getId())
4057 track = ""
4058 if contrib.getTrack() is not None:
4059 if contrib.getTrack().getCode() is not None:
4060 track = self.htmlText( contrib.getTrack().getCode() )
4061 else:
4062 track = self.htmlText( contrib.getTrack().getId() )
4063 cType=""
4064 if contrib.getType() is not None:
4065 cType=self.htmlText(contrib.getType().getName())
4066 status=contrib.getCurrentStatus()
4067 statusCaption=ContribStatusList().getCode(status.__class__)
4068 html = """
4069 <tr id="contributions%s" style="background-color: transparent;" onmouseout="javascript:onMouseOut('contributions%s')" onmouseover="javascript:onMouseOver('contributions%s')">
4070 <td valign="top" align="right" nowrap><input onchange="javascript:isSelected('contributions%s')" type="checkbox" name="contributions" value=%s></td>
4071 <td valign="top" nowrap class="CRLabstractDataCell">%s</td>
4072 <td valign="top" nowrap class="CRLabstractDataCell">%s</td>
4073 <td valign="top" nowrap class="CRLabstractDataCell">%s</td>
4074 <td valign="top" class="CRLabstractDataCell">%s</td>
4075 <td valign="top" class="CRLabstractDataCell">%s</td>
4076 <td valign="top" class="CRLabstractDataCell">%s</td>
4077 <td valign="top" class="CRLabstractDataCell">%s</td>
4078 <td valign="top" class="CRLabstractDataCell">%s</td>
4079 <td valign="top" class="CRLabstractDataCell">%s</td>
4080 <td valign="top" class="CRLabstractDataCell" nowrap>%s</td>
4081 </tr>
4082 """%(contrib.getId(), contrib.getId(), contrib.getId(),
4083 contrib.getId(), contrib.getId(),
4084 self.htmlText(contrib.getId()),
4085 sdate or "&nbsp;",strdur or "&nbsp;",cType or "&nbsp;",
4086 title or "&nbsp;",
4087 speaker or "&nbsp;",session or "&nbsp;",
4088 track or "&nbsp;",statusCaption or "&nbsp;",
4089 self._getMaterialsHTML(contrib) or "&nbsp;")
4090 return html
4092 def _getTypeItemsHTML(self):
4093 checked=""
4094 if self._filterCrit.getField("type").getShowNoValue():
4095 checked=" checked"
4096 res=[ i18nformat("""<input type="checkbox" name="typeShowNoValue" value="--none--"%s> --_("not specified")--""")%checked]
4097 for t in self._conf.getContribTypeList():
4098 checked=""
4099 if t.getId() in self._filterCrit.getField("type").getValues():
4100 checked=" checked"
4101 res.append("""<input type="checkbox" name="types" value=%s%s> %s"""%(quoteattr(str(t.getId())),checked,self.htmlText(t.getName())))
4102 return res
4104 def _getSessionItemsHTML(self):
4105 checked=""
4106 if self._filterCrit.getField("session").getShowNoValue():
4107 checked=" checked"
4108 res=[ i18nformat("""<input type="checkbox" name="sessionShowNoValue" value="--none--"%s> --_("not specified")--""")%checked]
4109 for s in self._conf.getSessionListSorted():
4110 checked=""
4111 l = self._filterCrit.getField("session").getValues()
4112 if not isinstance(l, list):
4113 l = [l]
4114 if s.getId() in l:
4115 checked=" checked"
4116 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())))
4117 return res
4119 def _getTrackItemsHTML(self):
4120 checked=""
4121 if self._filterCrit.getField("track").getShowNoValue():
4122 checked=" checked"
4123 res=[ i18nformat("""<input type="checkbox" name="trackShowNoValue" value="--none--"%s> --_("not specified")--""")%checked]
4124 for t in self._conf.getTrackList():
4125 checked=""
4126 if t.getId() in self._filterCrit.getField("track").getValues():
4127 checked=" checked"
4128 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())))
4129 return res
4131 def _getStatusItemsHTML(self):
4132 res=[]
4133 for st in ContribStatusList().getList():
4134 id=ContribStatusList().getId(st)
4135 checked=""
4136 if id in self._filterCrit.getField("status").getValues():
4137 checked=" checked"
4138 code=ContribStatusList().getCode(st)
4139 caption=ContribStatusList().getCaption(st)
4140 res.append("""<input type="checkbox" name="status" value=%s%s> (%s) %s"""%(quoteattr(str(id)),checked,self.htmlText(code),self.htmlText(caption)))
4141 return res
4143 def _getMaterialItemsHTML(self):
4144 res=[]
4145 for (id,caption) in [(PaperFactory().getId(),PaperFactory().getTitle()),\
4146 (SlidesFactory().getId(),SlidesFactory().getTitle()),\
4147 ("--other--", _("other")),("--none--", i18nformat("""--_("no material")--"""))]:
4148 checked=""
4149 if id in self._filterCrit.getField("material").getValues():
4150 checked=" checked"
4151 res.append("""<input type="checkbox" name="material" value=%s%s> %s"""%(quoteattr(str(id)),checked,self.htmlText(caption)))
4152 return res
4154 def _getFilterMenu(self):
4156 options = [
4157 ('Types', {"title": _("Types"),
4158 "options": self._getTypeItemsHTML()}),
4159 ('Sessions', {"title": _("Sessions"),
4160 "options": self._getSessionItemsHTML()}),
4161 ('Tracks', {"title": _("Tracks"),
4162 "options": self._getTrackItemsHTML()}),
4163 ('Status', {"title": _("Status"),
4164 "options": self._getStatusItemsHTML()})
4167 extraInfo = i18nformat("""<table align="center" cellspacing="10" width="100%%">
4168 <tr>
4169 <td colspan="5" class="titleCellFormat"> _("Author search") <input type="text" name="authSearch" value=%s></td>
4170 </tr>
4171 </table>
4172 """)%(quoteattr(str(self._authSearch)))
4174 p = WFilterCriteriaContribs(options, None, extraInfo)
4176 return p.getHTML()
4178 def getVars( self ):
4179 vars = wcomponents.WTemplated.getVars( self )
4180 vars["filterUrl"] = str(self._filterUrl).replace('%', '%%')
4181 vars["quickSearchURL"]=quoteattr(str(urlHandlers.UHConfModContribQuickAccess.getURL(self._conf)))
4182 vars["filterPostURL"]=quoteattr(str(urlHandlers.UHConfModifContribList.getURL(self._conf)))
4183 self._authSearch=vars.get("authSearch","").strip()
4184 cl=self._conf.getContribsMatchingAuth(self._authSearch)
4186 sortingField = self._sortingCrit.getField()
4187 self._currentSorting=""
4189 if sortingField is not None:
4190 self._currentSorting=sortingField.getId()
4191 vars["currentSorting"]=""
4193 url=self._getURL()
4194 url.addParam("sortBy","number")
4195 vars["numberImg"]=""
4196 if self._currentSorting == "number":
4197 vars["currentSorting"] = i18nformat("""<input type="hidden" name="sortBy" value="_("number")">""")
4198 if self._order == "down":
4199 vars["numberImg"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4200 url.addParam("order","up")
4201 elif self._order == "up":
4202 vars["numberImg"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4203 url.addParam("order","down")
4204 vars["numberSortingURL"]=quoteattr(str(url))
4206 url = self._getURL()
4207 url.addParam("sortBy", "date")
4208 vars["dateImg"] = ""
4209 if self._currentSorting == "date":
4210 vars["currentSorting"]= i18nformat("""<input type="hidden" name="sortBy" value="_("date")">""")
4211 if self._order == "down":
4212 vars["dateImg"]="""<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4213 url.addParam("order","up")
4214 elif self._order == "up":
4215 vars["dateImg"]="""<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4216 url.addParam("order","down")
4217 vars["dateSortingURL"]=quoteattr(str(url))
4220 url = self._getURL()
4221 url.addParam("sortBy", "name")
4222 vars["titleImg"] = ""
4223 if self._currentSorting == "name":
4224 vars["currentSorting"]= i18nformat("""<input type="hidden" name="sortBy" value="_("name")">""")
4225 if self._order == "down":
4226 vars["titleImg"]="""<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4227 url.addParam("order","up")
4228 elif self._order == "up":
4229 vars["titleImg"]="""<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4230 url.addParam("order","down")
4231 vars["titleSortingURL"]=quoteattr(str(url))
4234 url = self._getURL()
4235 url.addParam("sortBy", "type")
4236 vars["typeImg"] = ""
4237 if self._currentSorting == "type":
4238 vars["currentSorting"]= i18nformat("""<input type="hidden" name="sortBy" value="_("type")">""")
4239 if self._order == "down":
4240 vars["typeImg"]="""<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4241 url.addParam("order","up")
4242 elif self._order == "up":
4243 vars["typeImg"]="""<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4244 url.addParam("order","down")
4245 vars["typeSortingURL"] = quoteattr( str( url ) )
4246 url = self._getURL()
4247 url.addParam("sortBy", "session")
4248 vars["sessionImg"] = ""
4249 if self._currentSorting == "session":
4250 vars["currentSorting"] = i18nformat("""<input type="hidden" name="sortBy" value='_("session")'>""")
4251 if self._order == "down":
4252 vars["sessionImg"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4253 url.addParam("order","up")
4254 elif self._order == "up":
4255 vars["sessionImg"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4256 url.addParam("order","down")
4257 vars["sessionSortingURL"] = quoteattr( str( url ) )
4258 url = self._getURL()
4259 url.addParam("sortBy", "speaker")
4260 vars["speakerImg"]=""
4261 if self._currentSorting=="speaker":
4262 vars["currentSorting"] = i18nformat("""<input type="hidden" name="sortBy" value="_("speaker")">""")
4263 if self._order == "down":
4264 vars["speakerImg"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4265 url.addParam("order","up")
4266 elif self._order == "up":
4267 vars["speakerImg"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4268 url.addParam("order","down")
4269 vars["speakerSortingURL"]=quoteattr( str( url ) )
4271 url = self._getURL()
4272 url.addParam("sortBy","track")
4273 vars["trackImg"] = ""
4274 if self._currentSorting == "track":
4275 vars["currentSorting"] = i18nformat("""<input type="hidden" name="sortBy" value="_("track")">""")
4276 if self._order == "down":
4277 vars["trackImg"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow")))
4278 url.addParam("order","up")
4279 elif self._order == "up":
4280 vars["trackImg"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow")))
4281 url.addParam("order","down")
4282 vars["trackSortingURL"] = quoteattr( str( url ) )
4284 f=filters.SimpleFilter(self._filterCrit,self._sortingCrit)
4285 filteredContribs = f.apply(cl)
4286 l = [self._getContribHTML(contrib) for contrib in filteredContribs]
4287 contribsToPrint = ["""<input type="hidden" name="contributions" value="%s">"""%contrib.getId() for contrib in filteredContribs]
4288 numContribs = len(filteredContribs)
4290 if self._order =="up":
4291 l.reverse()
4292 vars["contribsToPrint"] = "\n".join(contribsToPrint)
4293 vars["contributions"] = "".join(l)
4294 orginURL = urlHandlers.UHConfModifContribList.getURL(self._conf)
4295 vars["numContribs"]=str(numContribs)
4297 vars["totalNumContribs"] = str(len(self._conf.getContributionList()))
4298 vars["filterUsed"] = self._filterUsed
4300 vars["contributionsPDFURL"]=quoteattr(str(urlHandlers.UHContribsConfManagerDisplayMenuPDF.getURL(self._conf)))
4301 vars["contribSelectionAction"]=quoteattr(str(urlHandlers.UHContribConfSelectionAction.getURL(self._conf)))
4303 totaldur = self._totaldur
4304 days = totaldur.days
4305 hours = (totaldur.seconds)/3600
4306 dayhours = (days * 24)+hours
4307 mins = ((totaldur.seconds)/60)-(hours*60)
4308 vars["totaldur"] = """%sh%sm""" % (dayhours, mins)
4309 vars['rbActive'] = Config.getInstance().getIsRoomBookingActive()
4310 vars["bookings"] = Conversion.reservationsList(self._conf.getRoomBookingList())
4311 vars["filterMenu"] = self._getFilterMenu()
4312 vars["sortingOptions"]="""<input type="hidden" name="sortBy" value="%s">
4313 <input type="hidden" name="order" value="%s">"""%(self._sortingCrit.getField().getId(), self._order)
4314 vars["pdfIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("pdf")))
4315 vars["excelIconURL"] = quoteattr(str(Config.getInstance().getSystemIconURL("excel")))
4316 vars["xmlIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("xml")))
4317 return vars
4319 class WFilterCriteriaContribs(wcomponents.WFilterCriteria):
4321 Draws the options for a filter criteria object
4322 This means rendering the actual table that contains
4323 all the HTML for the several criteria
4326 def __init__(self, options, filterCrit, extraInfo=""):
4327 wcomponents.WFilterCriteria.__init__(self, options, filterCrit, extraInfo)
4329 def _drawFieldOptions(self, id, data):
4331 page = WFilterCriterionOptionsContribs(id, data)
4333 # TODO: remove when we have a better template system
4334 return page.getHTML().replace('%','%%')
4336 class WFilterCriterionOptionsContribs(wcomponents.WTemplated):
4338 def __init__(self, id, data):
4339 self._id = id
4340 self._data = data
4342 def getVars(self):
4344 vars = wcomponents.WTemplated.getVars( self )
4346 vars["id"] = self._id
4347 vars["title"] = self._data["title"]
4348 vars["options"] = self._data["options"]
4349 vars["selectFunc"] = self._data.get("selectFunc", True)
4351 return vars
4353 class WPModifContribList( WPConferenceModifBase ):
4355 _userData = ['favorite-user-list', 'favorite-user-ids']
4357 def __init__(self, rh, conference, filterUsed=False):
4358 WPConferenceModifBase.__init__(self, rh, conference)
4359 self._filterUsed = filterUsed
4361 def _setActiveSideMenuItem(self):
4362 self._contribListMenuItem.setActive(True)
4364 def _getPageContent( self, params ):
4365 filterCrit=params.get("filterCrit",None)
4366 sortingCrit=params.get("sortingCrit",None)
4367 order = params.get("order","down")
4369 filterParams = {}
4370 fields = getattr(filterCrit, '_fields')
4371 for field in fields.values():
4372 id = field.getId()
4373 showNoValue = field.getShowNoValue()
4374 values = field.getValues()
4375 if showNoValue:
4376 filterParams['%sShowNoValue' % id] = '--none--'
4377 filterParams[id] = values
4379 requestParams = self._rh.getRequestParams()
4381 operationType = requestParams.get('operationType')
4382 if operationType != 'resetFilters':
4383 operationType = 'filter'
4384 urlParams = dict(isBookmark='y', operationType=operationType)
4386 urlParams.update(self._rh.getRequestParams())
4387 urlParams.update(filterParams)
4388 filterUrl = self._rh._uh.getURL(None, **urlParams)
4390 wc = WConfModifContribList(self._conf,filterCrit, sortingCrit, order, self._filterUsed, filterUrl)
4391 p={"authSearch":params.get("authSearch","")}
4393 return wc.getHTML(p)
4395 class WPConfModifContribToPDFMenu( WPModifContribList ):
4397 def __init__(self, rh, conf, contribIds):
4398 WPModifContribList.__init__(self, rh, conf)
4399 self._contribIds = contribIds
4401 def _getPageContent(self, params):
4403 wc = WConfModifContribToPDFMenu(self._conf, self._contribIds)
4404 return wc.getHTML(params)
4406 class WConfModifContribToPDFMenu(wcomponents.WTemplated):
4407 def __init__(self, conf, contribIds):
4408 self._conf = conf
4409 self.contribIds = contribIds
4411 def getVars( self ):
4412 vars = wcomponents.WTemplated.getVars( self )
4413 vars["createPDFURL"] = urlHandlers.UHContribsConfManagerDisplayMenuPDF.getURL(self._conf)
4414 l = []
4415 for id in self.contribIds:
4416 l.append("""<input type="hidden" name="contributions" value="%s">"""%id)
4417 vars["contribIdsList"] = "\n".join(l)
4418 return vars
4421 class WConfModMoveContribsToSession(wcomponents.WTemplated):
4423 def __init__(self,conf,contribIdList=[]):
4424 self._conf=conf
4425 self._contribIdList=contribIdList
4427 def getVars(self):
4428 vars=wcomponents.WTemplated.getVars(self)
4429 vars["postURL"]=quoteattr(str(urlHandlers.UHConfModMoveContribsToSession.getURL(self._conf)))
4430 vars["contribs"]=",".join(self._contribIdList)
4431 s=["""<option value="--none--">--none--</option>"""]
4432 for session in self._conf.getSessionListSorted():
4433 if not session.isClosed():
4434 s.append("""<option value=%s>%s</option>"""%(
4435 quoteattr(str(session.getId())),
4436 self.htmlText(session.getTitle())))
4437 vars["sessions"]="".join(s)
4438 return vars
4441 class WPModMoveContribsToSession(WPModifContribList):
4443 def _getPageContent(self,params):
4444 wc=WConfModMoveContribsToSession(self._conf,params.get("contribIds",[]))
4445 return wc.getHTML()
4448 class WPModMoveContribsToSessionConfirmation(WPModifContribList):
4450 def _getPageContent(self,params):
4451 wc=wcomponents.WConfModMoveContribsToSessionConfirmation(self._conf,params.get("contribIds",[]),params.get("targetSession",None))
4452 p={"postURL":urlHandlers.UHConfModMoveContribsToSession.getURL(self._conf),}
4453 return wc.getHTML(p)
4456 class WPConfEditContribType(WPConferenceModifBase):
4458 def __init__(self, rh, ct):
4459 self._conf = ct.getConference()
4460 self._contribType = ct
4461 WPConferenceModifBase.__init__(self, rh, self._conf)
4463 def _setActiveSideMenuItem(self):
4464 self._generalSettingsMenuItem.setActive(True)
4466 def _getPageContent( self, params ):
4467 wc = WConfEditContribType(self._contribType)
4468 params["saveURL"] = quoteattr(str(urlHandlers.UHConfEditContribType.getURL(self._contribType)))
4469 return wc.getHTML(params)
4472 class WConfEditContribType(wcomponents.WTemplated):
4474 def __init__(self, contribType):
4475 self._contribType = contribType
4477 def getVars(self):
4478 vars = wcomponents.WTemplated.getVars(self)
4479 vars["ctName"] = self._contribType.getName()
4480 vars["ctDescription"] = self._contribType.getDescription()
4482 return vars
4484 class WPConfAddContribType(WPConferenceModifBase):
4486 def _setActiveSideMenuItem(self):
4487 self._generalSettingsMenuItem.setActive(True)
4489 def _getPageContent( self, params ):
4490 wc = WConfAddContribType()
4491 params["saveURL"] = quoteattr(str(urlHandlers.UHConfAddContribType.getURL(self._conf)))
4492 return wc.getHTML(params)
4495 class WConfAddContribType(wcomponents.WTemplated):
4497 def getVars(self):
4498 vars = wcomponents.WTemplated.getVars(self)
4499 return vars
4501 class WAbstractsParticipantList(wcomponents.WTemplated):
4503 def __init__(self, conf, emailList, displayedGroups, abstracts):
4504 self._emailList = emailList
4505 self._displayedGroups = displayedGroups
4506 self._conf = conf
4507 self._abstracts = abstracts
4509 def getVars(self):
4510 vars = wcomponents.WTemplated.getVars(self)
4512 vars["submitterEmails"] = ",".join(self._emailList["submitters"]["emails"])
4513 vars["primaryAuthorEmails"] = ",".join(self._emailList["primaryAuthors"]["emails"])
4514 vars["coAuthorEmails"] = ",".join(self._emailList["coAuthors"]["emails"])
4516 urlDisplayGroup = urlHandlers.UHAbstractsConfManagerDisplayParticipantList.getURL(self._conf)
4517 abstractsToPrint = []
4518 for abst in self._abstracts:
4519 abstractsToPrint.append("""<input type="hidden" name="abstracts" value="%s">"""%abst)
4520 abstractsList = "".join(abstractsToPrint)
4521 displayedGroups = []
4522 for dg in self._displayedGroups:
4523 displayedGroups.append("""<input type="hidden" name="displayedGroups" value="%s">"""%dg)
4524 groupsList = "".join(displayedGroups)
4526 # Submitters
4527 text = _("show list")
4528 vars["submitters"] = "<tr colspan=\"2\"><td>&nbsp;</td></tr>"
4529 if "submitters" in self._displayedGroups:
4530 l = []
4531 color = "white"
4532 text = _("close list")
4533 for subm in self._emailList["submitters"]["tree"].values():
4534 if color=="white":
4535 color="#F6F6F6"
4536 else:
4537 color="white"
4538 participant = "%s %s %s <%s>"%(subm.getTitle(), subm.getFirstName(), safe_upper(subm.getFamilyName()), subm.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["submitters"] = "".join(l)
4543 urlDisplayGroup.addParam("clickedGroup", "submitters")
4544 vars["showSubmitters"] = """<form action="%s" method="post">\
4547 <input type="submit" class="btn" value="%s">
4548 </form>"""%(str(urlDisplayGroup), abstractsList,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>"%(pAuth.getFullName(), 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), abstractsList,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"%cAuth.getFullName()
4588 else:
4589 participant = "%s <%s>"%(cAuth.getFullName(), 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), abstractsList,groupsList, text)
4599 return vars
4601 class WContribParticipantList(wcomponents.WTemplated):
4603 def __init__(self, conf, emailList, displayedGroups, contribs):
4604 self._emailList = emailList
4605 self._displayedGroups = displayedGroups
4606 self._conf = conf
4607 self._contribs = contribs
4609 def getVars(self):
4610 vars = wcomponents.WTemplated.getVars(self)
4612 vars["speakerEmails"] = ", ".join(self._emailList["speakers"]["emails"])
4613 vars["primaryAuthorEmails"] = ", ".join(self._emailList["primaryAuthors"]["emails"])
4614 vars["coAuthorEmails"] = ", ".join(self._emailList["coAuthors"]["emails"])
4616 urlDisplayGroup = vars["urlDisplayGroup"]
4617 contribsToPrint = []
4618 for contrib in self._contribs:
4619 contribsToPrint.append("""<input type="hidden" name="contributions" value="%s">"""%contrib)
4620 contribsList = "".join(contribsToPrint)
4621 displayedGroups = []
4622 for dg in self._displayedGroups:
4623 displayedGroups.append("""<input type="hidden" name="displayedGroups" value="%s">"""%dg)
4624 groupsList = "".join(displayedGroups)
4626 # Speakers
4627 text = _("show list")
4628 vars["speakers"] = "<tr colspan=\"2\"><td>&nbsp;</td></tr>"
4629 if "speakers" in self._displayedGroups:
4630 l = []
4631 color = "white"
4632 text = _("close list")
4633 for speaker in self._emailList["speakers"]["tree"].values():
4634 if color=="white":
4635 color="#F6F6F6"
4636 else:
4637 color="white"
4638 participant = "%s <%s>"%(speaker.getFullName(), speaker.getEmail())
4639 l.append("<tr>\
4640 <td colspan=\"2\" nowrap bgcolor=\"%s\" class=\"blacktext\">\
4641 &nbsp;&nbsp;&nbsp;%s</td></tr>"%(color, self.htmlText(participant)))
4642 vars["speakers"] = "".join(l)
4643 urlDisplayGroup.addParam("clickedGroup", "speakers")
4644 vars["showSpeakers"] = """<form action="%s" method="post">\
4647 <input type="submit" class="btn" value="%s">
4648 </form>"""%(str(urlDisplayGroup), contribsList,groupsList, text)
4650 # Primary authors
4651 text = _("show list")
4652 vars["primaryAuthors"] = "<tr colspan=\"2\"><td>&nbsp;</td></tr>"
4653 if "primaryAuthors" in self._displayedGroups:
4654 l = []
4655 color = "white"
4656 text = _("close list")
4657 for pAuth in self._emailList["primaryAuthors"]["tree"].values():
4658 if color=="white":
4659 color="#F6F6F6"
4660 else:
4661 color="white"
4662 participant = "%s %s %s <%s>"%(pAuth.getTitle(), pAuth.getFirstName(), safe_upper(pAuth.getFamilyName()), pAuth.getEmail())
4663 l.append("<tr><td colspan=\"2\" nowrap bgcolor=\"%s\" \
4664 class=\"blacktext\">&nbsp;&nbsp;&nbsp;%s</td></tr>"%(color, self.htmlText(participant)))
4665 vars["primaryAuthors"] = "".join(l)
4666 urlDisplayGroup.addParam("clickedGroup", "primaryAuthors")
4667 vars["showPrimaryAuthors"] = """<form action="%s" method="post">\
4670 <input type="submit" class="btn" value="%s">
4671 </form>"""%(str(urlDisplayGroup), contribsList,groupsList, text)
4673 # Co-Authors
4674 text = _("show list")
4675 vars["coAuthors"] = "<tr colspan=\"2\"><td>&nbsp;</td></tr>"
4676 if "coAuthors" in self._displayedGroups:
4677 l = []
4678 color = "white"
4679 text = _("close list")
4680 for cAuth in self._emailList["coAuthors"]["tree"].values():
4681 if color=="white":
4682 color="#F6F6F6"
4683 else:
4684 color="white"
4685 cAuthEmail = cAuth.getEmail()
4686 if cAuthEmail.strip() == "":
4687 participant = "%s %s %s"%(cAuth.getTitle(), cAuth.getFirstName(), safe_upper(cAuth.getFamilyName()))
4688 else:
4689 participant = "%s %s %s <%s>"%(cAuth.getTitle(), cAuth.getFirstName(), safe_upper(cAuth.getFamilyName()), cAuthEmail)
4690 l.append("<tr><td colspan=\"2\" nowrap bgcolor=\"%s\" class=\"blacktext\">\
4691 &nbsp;&nbsp;&nbsp;%s</td></tr>"%(color, self.htmlText(participant)))
4692 vars["coAuthors"] = "".join(l)
4693 urlDisplayGroup.addParam("clickedGroup", "coAuthors")
4694 vars["showCoAuthors"] = """<form action="%s" method="post">\
4697 <input type="submit" class="btn" value="%s">
4698 </form>"""%(str(urlDisplayGroup), contribsList,groupsList, text)
4699 return vars
4702 class WPAbstractSendNotificationMail(WPConferenceBase):
4704 def __init__(self, rh, conf, count):
4705 WPConferenceBase.__init__(self, rh, conf)
4706 self._count = count
4708 def _getBody( self, params ):
4709 return i18nformat("""
4710 <table align="center"><tr><td align="center">
4711 <b> _("The submitters of the selected abstracts will nearly recieve the notification mail").<br>
4712 <br>
4713 _("You can now close this window.")</b>
4714 </td></tr></table>
4716 """)
4719 class WPContributionList( WPConferenceDefaultDisplayBase ):
4720 navigationEntry = navigation.NEContributionList
4722 def _getBody( self, params ):
4723 wc = WConfContributionList( self._getAW(), self._conf, params["filterCrit"], params.get("filterText",""))
4724 return wc.getHTML()
4726 def _defineSectionMenu( self ):
4727 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
4728 self._sectionMenu.setCurrentItem(self._contribListOpt)
4731 class WConfContributionList (WConfDisplayBodyBase):
4733 _linkname = "contributionList"
4735 def __init__(self, aw, conf, filterCrit, filterText):
4736 self._aw = aw
4737 self._conf = conf
4738 self._filterCrit = filterCrit
4739 self._filterText = filterText
4741 def getVars(self):
4742 wvars = wcomponents.WTemplated.getVars(self)
4744 wvars["body_title"] = self._getTitle()
4745 wvars["contributions"] = self._conf.getContributionListSorted(includeWithdrawn=False, key="title")
4746 wvars["showAttachedFiles"] = self._conf.getAbstractMgr().showAttachedFilesContribList()
4747 wvars["conf"] = self._conf
4748 wvars["accessWrapper"] = self._aw
4749 wvars["filterCriteria"] = self._filterCrit
4750 wvars["filterText"] = self._filterText
4751 wvars["formatDate"] = lambda date: format_date(date, "d MMM yyyy")
4752 wvars["formatTime"] = lambda time: format_time(time, format="short", timezone=timezone(DisplayTZ(self._aw, self._conf).getDisplayTZ()))
4753 return wvars
4756 class WConfAuthorIndex(WConfDisplayBodyBase):
4758 _linkname = "authorIndex"
4760 def __init__(self, conf):
4761 self._conf = conf
4763 def getVars(self):
4764 wvars = wcomponents.WTemplated.getVars(self)
4765 wvars["body_title"] = self._getTitle()
4766 wvars["items"] = dict(enumerate(self._getItems()))
4767 return wvars
4769 def _getItems(self):
4770 res = []
4772 for key, authors in self._conf.getAuthorIndex().iteritems():
4773 # get the first identity that matches the author
4774 if len(authors) == 0:
4775 continue
4776 else:
4777 auth = next((x for x in authors if x.getContribution() and x.getContribution().getConference()), None)
4778 if auth is None:
4779 continue
4781 authorURL = urlHandlers.UHContribAuthorDisplay.getURL(auth.getContribution(), authorId=auth.getId())
4782 contribs = []
4783 res.append({'fullName': auth.getFullNameNoTitle(),
4784 'affiliation': auth.getAffiliation(),
4785 'authorURL': authorURL,
4786 'contributions': contribs})
4788 for auth in authors:
4789 contrib = auth.getContribution()
4790 if contrib is not None and contrib.getConference() is not None:
4791 contribs.append({
4792 'title': contrib.getTitle(),
4793 'url': str(urlHandlers.UHContributionDisplay.getURL(auth.getContribution())),
4794 'materials': fossilize(contrib.getAllMaterialList())
4796 return res
4799 class WPAuthorIndex(WPConferenceDefaultDisplayBase):
4800 navigationEntry = navigation.NEAuthorIndex
4802 def getJSFiles(self):
4803 return WPConferenceDefaultDisplayBase.getJSFiles(self) + \
4804 self._asset_env['indico_authors'].urls()
4806 def _getBody(self, params):
4807 wc = WConfAuthorIndex(self._conf)
4808 return wc.getHTML()
4810 def _defineSectionMenu(self):
4811 WPConferenceDefaultDisplayBase._defineSectionMenu(self)
4812 self._sectionMenu.setCurrentItem(self._authorIndexOpt)
4815 class WConfSpeakerIndex(WConfDisplayBodyBase):
4817 _linkname = "speakerIndex"
4819 def __init__(self, conf):
4820 self._conf = conf
4822 def getVars(self):
4823 wvars = wcomponents.WTemplated.getVars(self)
4824 res = collections.defaultdict(list)
4825 for index, key in enumerate(self._conf.getSpeakerIndex().getParticipationKeys()):
4826 pl = self._conf.getSpeakerIndex().getById(key)
4827 try:
4828 speaker = pl[0]
4829 except IndexError:
4830 continue
4831 res[index].append({'fullName': speaker.getFullNameNoTitle(), 'affiliation': speaker.getAffiliation()})
4832 for speaker in pl:
4833 if isinstance(speaker, conference.SubContribParticipation):
4834 participation = speaker.getSubContrib()
4835 if participation is None:
4836 continue
4837 url = urlHandlers.UHSubContributionDisplay.getURL(participation)
4838 else:
4839 participation = speaker.getContribution()
4840 if participation is None:
4841 continue
4842 url = urlHandlers.UHContributionDisplay.getURL(participation)
4843 if participation.getConference() is not None:
4844 res[index].append({'title': participation.getTitle(), 'url': str(url),
4845 'materials': fossilize(participation.getAllMaterialList())})
4846 wvars["body_title"] = self._getTitle()
4847 wvars["items"] = res
4848 return wvars
4851 class WPSpeakerIndex(WPConferenceDefaultDisplayBase):
4852 navigationEntry = navigation.NESpeakerIndex
4854 def _getBody(self, params):
4855 wc=WConfSpeakerIndex(self._conf)
4856 return wc.getHTML()
4858 def getJSFiles(self):
4859 return WPConferenceDefaultDisplayBase.getJSFiles(self) + \
4860 self._asset_env['indico_authors'].urls()
4862 def _defineSectionMenu( self ):
4863 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
4864 self._sectionMenu.setCurrentItem(self._speakerIndexOpt)
4866 class WConfMyContributions(wcomponents.WTemplated):
4868 def __init__(self, aw, conf):
4869 self._aw=aw
4870 self._conf=conf
4872 def getHTML(self, params):
4873 return wcomponents.WTemplated.getHTML(self, params)
4875 def getVars(self):
4876 vars = wcomponents.WTemplated.getVars( self )
4877 vars["User"] = self._aw.getUser()
4878 vars["Conference"] = self._conf
4879 vars["ConfReviewingChoice"] = self._conf.getConfPaperReview().getChoice()
4880 return vars
4883 class WConfMyStuffMySessions(WConfDisplayBodyBase):
4885 _linkname = "mysessions"
4887 def __init__(self, aw, conf):
4888 self._aw = aw
4889 self._conf = conf
4891 def _getSessionsHTML(self):
4892 if self._aw.getUser() is None:
4893 return ""
4894 #ls=self._conf.getCoordinatedSessions(self._aw.getUser())+self._conf.getManagedSession(self._aw.getUser())
4895 ls = set(self._conf.getCoordinatedSessions(self._aw.getUser()))
4896 ls = list(ls | set(self._conf.getManagedSession(self._aw.getUser())))
4897 if len(ls) <= 0:
4898 return ""
4899 res = []
4900 iconURL = Config.getInstance().getSystemIconURL("conf_edit")
4901 for s in ls:
4902 modURL = urlHandlers.UHSessionModification.getURL(s)
4903 dispURL = urlHandlers.UHSessionDisplay.getURL(s)
4904 res.append("""
4905 <tr class="infoTR">
4906 <td class="infoTD" width="100%%">%s</td>
4907 <td nowrap class="infoTD"><a href=%s>%s</a><span class="horizontalSeparator">|</span><a href=%s>%s</a></td>
4908 </tr>""" % (self.htmlText(s.getTitle()),
4909 quoteattr(str(modURL)),
4910 _("Edit"),
4911 quoteattr(str(dispURL)),
4912 _("View")))
4913 return """
4914 <table class="infoTable" cellspacing="0" width="100%%">
4915 <tr>
4916 <td nowrap class="tableHeader"> %s </td>
4917 <td nowrap class="tableHeader" style="text-align:right;"> %s </td>
4918 </tr>
4919 <tr>
4920 <td>%s</td>
4921 </tr>
4922 </table>
4923 """ % (_("Session"),
4924 _("Actions"),
4925 "".join(res))
4927 def getVars(self):
4928 wvars = wcomponents.WTemplated.getVars(self)
4929 wvars["body_title"] = self._getTitle()
4930 wvars["items"] = self._getSessionsHTML()
4931 return wvars
4934 class WPConfMyStuffMySessions(WPConferenceDefaultDisplayBase):
4935 navigationEntry = navigation.NEMyStuff
4937 def _getBody(self,params):
4938 wc=WConfMyStuffMySessions(self._getAW(),self._conf)
4939 return wc.getHTML()
4941 def _defineSectionMenu( self ):
4942 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
4943 self._sectionMenu.setCurrentItem(self._myStuffOpt)
4946 class WConfMyStuffMyContributions(WConfDisplayBodyBase):
4948 _linkname = "mycontribs"
4950 def __init__(self, aw, conf):
4951 self._aw = aw
4952 self._conf = conf
4954 def _getContribsHTML(self):
4955 return WConfMyContributions(self._aw, self._conf).getHTML({})
4957 def getVars(self):
4958 wvars = wcomponents.WTemplated.getVars(self)
4959 wvars["body_title"] = self._getTitle()
4960 wvars["items"] = self._getContribsHTML()
4961 return wvars
4964 class WPConfMyStuffMyContributions(WPConferenceDefaultDisplayBase):
4965 navigationEntry = navigation.NEMyStuff
4967 def _getBody(self,params):
4968 wc=WConfMyStuffMyContributions(self._getAW(),self._conf)
4969 return wc.getHTML()
4971 def _defineSectionMenu( self ):
4972 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
4973 self._sectionMenu.setCurrentItem(self._myContribsOpt)
4976 class WConfMyStuffMyTracks(WConfDisplayBodyBase):
4978 _linkname = "mytracks"
4980 def __init__(self, aw, conf):
4981 self._aw = aw
4982 self._conf = conf
4984 def _getTracksHTML(self):
4985 if self._aw.getUser() is None or not self._conf.getAbstractMgr().isActive() or not self._conf.hasEnabledSection("cfa"):
4986 return ""
4987 lt = self._conf.getCoordinatedTracks(self._aw.getUser())
4988 if len(lt) <= 0:
4989 return ""
4990 res = []
4991 iconURL = Config.getInstance().getSystemIconURL("conf_edit")
4992 for t in lt:
4993 modURL = urlHandlers.UHTrackModifAbstracts.getURL(t)
4994 res.append("""
4995 <tr class="infoTR">
4996 <td class="infoTD" width="100%%">%s</td>
4997 <td nowrap class="infoTD"><a href=%s>%s</a></td>
4998 </tr>""" % (self.htmlText(t.getTitle()),
4999 quoteattr(str(modURL)),
5000 _("Edit")))
5001 return """
5002 <table class="infoTable" cellspacing="0" width="100%%">
5003 <tr>
5004 <td nowrap class="tableHeader"> %s </td>
5005 <td nowrap class="tableHeader" style="text-align:right;"> %s </td>
5006 </tr>
5007 <tr>
5008 <td>%s</td>
5009 </tr>
5010 </table>
5011 """ % (_("Track"),
5012 _("Actions"),
5013 "".join(res))
5015 def getVars(self):
5016 wvars = wcomponents.WTemplated.getVars(self)
5017 wvars["body_title"] = self._getTitle()
5018 wvars["items"] = self._getTracksHTML()
5019 return wvars
5021 class WPConfMyStuffMyTracks(WPConferenceDefaultDisplayBase):
5022 navigationEntry = navigation.NEMyStuff
5024 def _getBody(self,params):
5025 wc=WConfMyStuffMyTracks(self._getAW(),self._conf)
5026 return wc.getHTML()
5028 def _defineSectionMenu( self ):
5029 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
5030 self._sectionMenu.setCurrentItem(self._myTracksOpt)
5033 class WConfMyStuff(WConfDisplayBodyBase):
5035 _linkname = "mystuff"
5037 def __init__(self, aw, conf):
5038 self._aw = aw
5039 self._conf = conf
5041 def getVars(self):
5042 wvars = wcomponents.WTemplated.getVars(self)
5043 wvars["body_title"] = self._getTitle()
5044 return wvars
5047 class WPMyStuff(WPConferenceDefaultDisplayBase):
5048 navigationEntry = navigation.NEMyStuff
5050 def _getBody(self,params):
5051 wc=WConfMyStuff(self._getAW(),self._conf)
5052 return wc.getHTML()
5054 def _defineSectionMenu( self ):
5055 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
5056 self._sectionMenu.setCurrentItem(self._myStuffOpt)
5059 class WConfModAbstractBook(wcomponents.WTemplated):
5061 def __init__(self,conf):
5062 self._conf = conf
5064 def getVars(self):
5065 vars = wcomponents.WTemplated.getVars(self)
5066 boaConfig = self._conf.getBOAConfig()
5067 vars["sortByList"] = boaConfig.getSortByTypes()
5068 vars["modURL"] = quoteattr(str(urlHandlers.UHConfModAbstractBook.getURL(self._conf)))
5069 vars["previewURL"] = quoteattr(str(urlHandlers.UHConfAbstractBook.getURL(self._conf)))
5070 vars["sortBy"] = boaConfig.getSortBy()
5071 vars["boaConfig"] = boaConfig
5072 vars["urlToogleShowIds"] = str(urlHandlers.UHConfModAbstractBookToogleShowIds.getURL(self._conf))
5073 vars["conf"] = self._conf
5074 vars["bookOfAbstractsActive"] = self._conf.getAbstractMgr().getCFAStatus()
5075 vars["bookOfAbstractsMenuActive"] = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(
5076 self._conf).getMenu().getLinkByName('abstractsBook').isEnabled()
5077 vars["correspondingAuthorList"] = boaConfig.getCorrespondingAuthorTypes()
5078 vars["correspondingAuthor"] = boaConfig.getCorrespondingAuthor()
5079 return vars
5082 class WPModAbstractBook(WPConferenceModifAbstractBase):
5084 def _setActiveTab(self):
5085 self._tabBOA.setActive()
5087 def _getTabContent(self, params):
5088 wc = WConfModAbstractBook(self._conf)
5089 return wc.getHTML()
5091 def getCSSFiles(self):
5092 return WPConferenceModifAbstractBase.getCSSFiles(self) + \
5093 self._asset_env['contributions_sass'].urls()
5095 def getJSFiles(self):
5096 return WPConferenceModifAbstractBase.getJSFiles(self) + \
5097 self._includeJSPackage('Management') + \
5098 self._asset_env['abstracts_js'].urls()
5100 def _getHeadContent(self):
5101 return WPConferenceModifAbstractBase._getHeadContent(self) + render('js/mathjax.config.js.tpl') + \
5102 '\n'.join(['<script src="{0}" type="text/javascript"></script>'.format(url)
5103 for url in self._asset_env['mathjax_js'].urls()])
5106 # ------------------ Static web pages ------------------
5108 class WPConferenceStaticDefaultDisplayBase( WPConferenceDefaultDisplayBase ):
5110 def _getHTMLHeader( self ):
5111 cssDir="./css"
5112 if len(self._staticPars) > 0 and self._staticPars.values()[0].startswith(".."):
5113 cssDir="../css"
5114 return """
5115 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5116 <html>
5117 <head>
5118 <title>%s</title>
5119 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
5120 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5121 <link rel="shortcut icon" href=%s>
5122 <link rel="stylesheet" type="text/css" href="%s/%s">
5123 </head>
5124 <body>
5126 """%(self._getTitle(), quoteattr(self._staticPars["addressBarIcon"]),
5127 cssDir, Config.getInstance().getCssStylesheetName(),
5128 self._getWarningMessage())
5130 def _getHeader( self ):
5133 wc = wcomponents.WStaticWebHeader()
5134 params = {}
5135 params["imgLogo"] = self._staticPars["miniLogo"]
5136 return wc.getHTML( params )
5138 def _applyConfDisplayDecoration( self, body ):
5139 frame = WConfStaticDisplayFrame( self._getAW(), self._conf, self._staticPars)
5140 frameParams = {}
5141 body = """
5142 <div class="confBodyBox clearfix">
5143 <div style="width: 100%;">
5144 <!--Main body-->
5146 </div>
5147 </div>"""%( body )
5148 return frame.getHTML( self._sectionMenu, body, frameParams)
5151 class WConfStaticDetails(WConfDisplayBodyBase):
5153 _linkname = "overview"
5155 def __init__(self, aw, conf, staticPars):
5156 self._conf = conf
5157 self._aw = aw
5158 self._staticPars = staticPars
5160 def _getChairsHTML(self):
5161 l = []
5162 for chair in self._conf.getChairList():
5163 mailToURL = """mailto:%s""" % urllib.quote(chair.getEmail())
5164 l.append("""<a href=%s>%s</a>""" % (quoteattr(mailToURL), self.htmlText(chair.getFullName())))
5165 res = ""
5166 if len(l) > 0:
5167 res = i18nformat("""
5168 <tr>
5169 <td align="right" valign="top" class="displayField"><b> _("Chairs"):</b></td>
5170 <td>%s</td>
5171 </tr>
5172 """) % "<br>".join(l)
5173 return res
5175 def _getMaterialHTML(self):
5176 l = []
5177 for mat in self._conf.getAllMaterialList():
5178 temp = wcomponents.WMaterialDisplayItem()
5179 url = urlHandlers.UHStaticMaterialDisplay.getRelativeURL(mat)
5180 l.append(temp.getHTML(self._aw, mat, url, self._staticPars["material"]))
5181 res = ""
5182 if l:
5183 res = i18nformat("""
5184 <tr>
5185 <td align="right" valign="top" class="displayField"><b> _("Material"):</b></td>
5186 <td align="left" width="100%%">%s</td>
5187 </tr>""") % "<br>".join(l)
5188 return res
5190 def _getMoreInfoHTML(self):
5191 res = ""
5192 if self._conf.getContactInfo() != "":
5193 res = i18nformat("""
5194 <tr>
5195 <td align="right" valign="top" class="displayField"><b> _("Additional info"):</b>
5196 </td>
5197 <td>%s</td>
5198 </tr>""") % self._conf.getContactInfo()
5199 return res
5201 def getVars( self ):
5202 wvars = wcomponents.WTemplated.getVars( self )
5203 wvars["description"] = self._conf.getDescription()
5204 sdate, edate = self._conf.getAdjustedStartDate(), self._conf.getAdjustedEndDate()
5205 fsdate, fedate = format_date(sDate, format='long'), format_date(eDate, format='long')
5206 fstime, fetime = sdate.strftime("%H:%M"), edate.strftime("%H:%M")
5207 wvars["dateInterval"] = i18nformat("""_("from") %s %s _("to") %s %s""") % (fsdate, fstime,
5208 fedate, fetime)
5209 if sdate.strftime("%d%B%Y") == edate.strftime("%d%B%Y"):
5210 timeInterval = fstime
5211 if sdate.strftime("%H%M") != edate.strftime("%H%M"):
5212 timeInterval = "%s-%s" % (fstime, fetime)
5213 wvars["dateInterval"] = "%s (%s)" % (fsdate, timeInterval)
5214 wvars["location"] = ""
5215 location = self._conf.getLocation()
5216 if location:
5217 wvars["location"] = "<i>%s</i><br><pre>%s</pre>" % (location.getName(), location.getAddress())
5218 room = self._conf.getRoom()
5219 if room:
5220 roomLink = linking.RoomLinker().getHTMLLink(room, location)
5221 wvars["location"] += i18nformat("""<small> _("Room"):</small> %s""") % roomLink
5222 wvars["chairs"] = self._getChairsHTML()
5223 wvars["material"] = self._getMaterialHTML()
5224 wvars["moreInfo"] = self._getMoreInfoHTML()
5225 wvars["actions"] = ''
5227 return wvars
5230 class ConfStaticDisplayMenu:
5232 def __init__(self, menu, linkList):
5233 self._menu = menu
5234 self._linkList = linkList
5236 def getHTML(self, params):
5237 html = []
5238 html = ["""<!--Left menu-->
5239 <div class="conf_leftMenu">
5240 <ul>
5241 <li class="menuConfTopCell">
5242 &nbsp;
5243 </li>
5244 """]
5245 for link in self._linkList:
5246 if link.isVisible():
5247 html.append(self._getLinkHTML(link, params))
5248 html.append("""<li class="menuConfBottomCell">&nbsp;</li>""")
5249 html.append(""" </ul>
5250 <div align="left" class="confSupportEmailBox">%s</div>
5251 </div>"""%params["supportEmail"])
5252 return "".join(html)
5254 def _getLinkHTML(self, link, params, indent=""):
5255 if not link.isVisible():
5256 return ""
5257 if link.getType() == "spacer":
5258 html = """<tr><td><br></td></tr>\n"""
5259 else:
5260 parentDir = ""
5261 if len(params) > 0 and params.values()[0].startswith(".."):
5262 parentDir = "."
5263 target = ""
5264 sublinkList=[]
5266 for sublink in link.getEnabledLinkList():
5267 if sublink.isVisible():
5268 sublinkList.append(sublink)
5270 if isinstance(link,displayMgr.ExternLink):
5271 target=""" target="_blank" """
5272 #Commented because menuicon variable is not used anymore
5273 #if sublinkList:
5274 # menuicon=params["arrowBottomMenuConf"]
5275 #else:
5276 # menuicon=params["arrowRightMenuConf"]
5278 #TODO: eventually change this so that it's the same as the non-static menu
5279 if self._menu.isCurrentItem(link):
5280 url="%s%s"%(parentDir, link.getStaticURL())
5281 html = ["""<li id="menuLink_%s" class="menuConfSelected" nowrap><a href="%s"%s>%s</a></li>\n"""%(sublink.getName(), url, target, \
5282 _(link.getCaption()))]
5283 else:
5284 url="%s%s"%(parentDir, link.getStaticURL())
5285 html = ["""<li id="menuLink_%s" class="menuConfTitle" nowrap><a class="confSection" href="%s"%s>%s</a></li>\n"""%(sublink.getName(), url, target, link.getCaption())]
5287 for sublink in sublinkList:
5288 target = ""
5289 if isinstance(link, displayMgr.ExternLink):
5290 target = " target=\"_blank\""
5291 if self._menu.isCurrentItem(sublink):
5292 url="%s%s"%(parentDir, sublink.getStaticURL())
5293 html.append("""<li id="menuLink_%s" class="menuConfSelected" nowrap><a href="%s"%s>\
5294 %s</a></li>\n"""\
5295 %(sublink.getName(), url, target, _(sublink.getCaption())))
5296 else:
5297 url="%s%s"%(parentDir, sublink.getStaticURL())
5298 html.append( """<li id="menuLink_%s" class="menuConfMiddleCell" nowrap><a class="confSubSection" href="%s"%s>\
5299 <img border="0" src="%s" alt="">&nbsp;%s</a></li>"""%(sublink.getName(), url, target,\
5300 params["bulletMenuConf"], _(sublink.getCaption()) ))
5301 return "".join(html)
5303 class WConfStaticDisplayFrame(wcomponents.WTemplated):
5305 def __init__(self, aw, conf, staticPars):
5306 self._aw = aw
5307 self._conf = conf
5308 self._staticPars = staticPars
5310 def getHTML( self, menu, body, params ):
5311 self._body = body
5312 self._menu = menu
5313 return wcomponents.WTemplated.getHTML( self, params )
5315 def _getMenuList(self, menuIds):
5316 l = []
5317 for id in menuIds:
5318 link = self._menu.getLinkByName(id)
5319 if link is not None:
5320 l.append(link)
5321 return l
5323 def getVars(self):
5324 vars = wcomponents.WTemplated.getVars( self )
5325 vars["logo"] = ""
5326 if self._conf.getLogo():
5327 vars["logo"] = "<img src=\"%s\" alt=\"%s\" border=\"0\" class=\"\" >"%(self._staticPars["logo"], self._conf.getTitle())
5328 vars["confTitle"] = self._conf.getTitle()
5329 tz = DisplayTZ(self._aw,self._conf).getDisplayTZ()
5330 adjusted_sDate = self._conf.getAdjustedStartDate(tz)
5331 adjusted_eDate = self._conf.getAdjustedEndDate(tz)
5332 vars["confDateInterval"] = i18nformat("""_("from") %s _("to") %s""")%(format_date(adjusted_sDate, format='long'), format_date(adjusted_eDate, format='long'))
5333 if adjusted_sDate.strftime("%d%B%Y") == \
5334 adjusted_eDate.strftime("%d%B%Y"):
5335 vars["confDateInterval"] = format_date(adjusted_sDate, format='long')
5336 elif adjusted_sDate.strftime("%B%Y") == adjusted_eDate.strftime("%B%Y"):
5337 vars["confDateInterval"] = "%s-%s %s"%(adjusted_sDate.day, adjusted_eDate.day, format_date(adjusted_sDate, format='MMMM yyyy'))
5338 vars["confLocation"] = ""
5339 if self._conf.getLocationList():
5340 vars["confLocation"] = self._conf.getLocationList()[0].getName()
5341 vars["body"] = self._body
5342 vars["supportEmail"] = ""
5343 if self._conf.getSupportInfo().hasEmail():
5344 mailto = quoteattr("""mailto:%s?subject=%s"""%(self._conf.getSupportInfo().getEmail(), urllib.quote( self._conf.getTitle() ) ))
5345 vars["supportEmail"] = i18nformat("""<a href=%s class="confSupportEmail"><img src="%s" border="0" alt="email"> _("support")</a>""")%(mailto, self._staticPars["smallEmail"] )
5346 p=self._staticPars
5347 p["supportEmail"] = vars["supportEmail"]
5348 menuList = self._getMenuList(["overview", "programme", "timetable", "contributionList", "authorIndex", "abstractsBook"])
5349 vars["menu"] = ConfStaticDisplayMenu( self._menu, menuList ).getHTML(p)
5350 format = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getFormat()
5351 vars["bgColorCode"] = format.getFormatOption("titleBgColor")["code"]
5352 vars["textColorCode"] = format.getFormatOption("titleTextColor")["code"]
5353 return vars
5355 class WPConferenceStaticDisplay( WPConferenceStaticDefaultDisplayBase ):
5357 def __init__(self, rh, target, staticPars):
5358 WPConferenceStaticDefaultDisplayBase.__init__(self, rh, target)
5359 self._staticPars = staticPars
5361 def _getBody( self, params ):
5362 wc = WConfStaticDetails( self._getAW(), self._conf, self._staticPars )
5363 return wc.getHTML({})
5365 def _defineSectionMenu( self ):
5366 WPConferenceStaticDefaultDisplayBase._defineSectionMenu(self)
5367 self._sectionMenu.setCurrentItem(self._overviewOpt)
5369 class WConfStaticProgramTrack(wcomponents.WTemplated):
5371 def __init__( self, aw, track, staticPars ):
5372 self._aw = aw
5373 self._track = track
5374 self._staticPars=staticPars
5376 def getVars( self ):
5377 vars = wcomponents.WTemplated.getVars( self )
5378 vars["bulletURL"] = self._staticPars["track_bullet"]
5379 vars["title"] = """%s """%(self._track.getTitle() )#"""<a href=%s>%s</a> """%(quoteattr(str(urlHandlers.UHStaticTrackContribList.getRelativeURL(self._track))), self._track.getTitle() )
5380 vars["description"] = self._track.getDescription()
5381 subtracks = []
5382 for subtrack in self._track.getSubTrackList():
5383 subtracks.append( "%s"%subtrack.getTitle() )
5384 vars["subtracks"] = ""
5385 if subtracks:
5386 vars["subtracks"] = i18nformat("""<i> _("Sub-tracks") </i>: %s""")%", ".join( subtracks )
5387 return vars
5389 class WConfStaticProgram(wcomponents.WTemplated):
5391 def __init__(self, aw, conf, staticPars):
5392 self._conf = conf
5393 self._aw = aw
5394 self._staticPars = staticPars
5396 def getVars( self ):
5397 vars = wcomponents.WTemplated.getVars( self )
5398 program = []
5399 for track in self._conf.getTrackList():
5400 program.append( WConfStaticProgramTrack( self._aw, track, self._staticPars ).getHTML() )
5401 vars["program"] = "".join( program )
5402 return vars
5404 class WPConferenceStaticProgram( WPConferenceStaticDefaultDisplayBase ):
5406 def __init__(self, rh, target, staticPars):
5407 WPConferenceStaticDefaultDisplayBase.__init__(self, rh, target)
5408 self._staticPars = staticPars
5410 def _getBody( self, params ):
5411 wc = WConfStaticProgram( self._getAW(), self._conf, self._staticPars )
5412 return wc.getHTML()
5414 def _defineSectionMenu( self ):
5415 WPConferenceStaticDefaultDisplayBase._defineSectionMenu( self )
5416 self._sectionMenu.setCurrentItem(self._programOpt)
5418 class WConfStaticAuthorIndex(wcomponents.WTemplated):
5420 def __init__(self,aw,conf, staticPars):
5421 self._aw=aw
5422 self._conf=conf
5423 self._staticPars=staticPars
5424 self._lastLetter = "-1"
5426 def _getMaterialHTML(self, contrib):
5427 lm=[]
5428 paper=contrib.getPaper()
5429 track=contrib.getTrack()
5430 trackFolder="./other_contributions"
5431 if track is not None:
5432 trackFolder=track.getTitle().replace(" ","_")
5433 for mat in contrib.getAllMaterialList():
5434 url="%s/%s"%(trackFolder, str(urlHandlers.UHStaticMaterialDisplay.getRelativeURL(mat)))
5435 lm.append("""<a href=%s><span style="font-style: italic;"><small> %s</small></span></a>"""%(
5436 quoteattr(url),
5437 self.htmlText(mat.getTitle().lower())))
5438 return ", ".join(lm)
5440 def _getLetterIndex(self):
5441 url=urlHandlers.UHStaticConfAuthorIndex.getRelativeURL()
5442 res=[]
5443 for letter in ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']:
5444 res.append("""<a href="%s#letter_%s">%s</a>"""%(str(url),letter, letter))
5445 return " | ".join(res)
5447 def _getItemHTML(self,pl):
5448 if len(pl)<=0:
5449 return ""
5450 auth=pl[0]
5451 authCaption = safe_upper(auth.getFamilyName())
5452 htmlLetter = ""
5453 letter = "-1"
5454 if len(auth.getFamilyName()) > 0:
5455 letter = auth.getFamilyName()[0].lower()
5456 if self._lastLetter != letter:
5457 self._lastLetter = letter
5458 htmlLetter = """<a href="" name="letter_%s"></a>"""%letter
5459 if auth.getFirstName()!="":
5460 authCaption="%s, %s"%(authCaption,auth.getFirstName())
5461 if authCaption.strip()=="":
5462 return ""
5463 contribList=[]
5464 for auth in pl:
5465 contrib=auth.getContribution()
5466 url=urlHandlers.UHStaticContributionDisplay.getRelativeURL(contrib)
5467 material = self._getMaterialHTML(contrib)
5468 if material.strip()!="":
5469 material = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( %s )"%material
5470 contribList.append("""<p style="text-indent: -3em;margin-left:3em"><a href=%s>%s-%s</a>%s</p>"""%(quoteattr(str(url)), self.htmlText(contrib.getId()),self.htmlText(contrib.getTitle()), material ))
5471 res="""
5472 <tr>
5473 <td valign="top">%s%s</td>
5474 <td width="100%%">%s</td>
5475 </tr>
5476 <tr>
5477 <td colspan="2" style="border-bottom: 1px solid; border-color: #EAEAEA">&nbsp;</td>
5478 </tr>"""%(htmlLetter, self.htmlText(authCaption),"".join(contribList))
5479 return res
5481 def getVars(self):
5482 vars=wcomponents.WTemplated.getVars(self)
5483 res=[]
5484 for partList in self._conf.getAuthorIndex().getParticipations():
5485 res.append(self._getItemHTML(partList))
5486 vars["letterIndex"] = self._getLetterIndex()
5487 vars["items"]="".join(res)
5488 return vars
5490 class WPStaticAuthorIndex(WPConferenceStaticDefaultDisplayBase):
5492 def __init__(self, rh, target, staticPars):
5493 WPConferenceStaticDefaultDisplayBase.__init__(self, rh, target)
5494 self._staticPars = staticPars
5496 def _getBody(self,params):
5497 wc=WConfStaticAuthorIndex(self._getAW(),self._conf,self._staticPars)
5498 return wc.getHTML()
5500 def _defineSectionMenu( self ):
5501 WPConferenceStaticDefaultDisplayBase._defineSectionMenu( self )
5502 self._sectionMenu.setCurrentItem(self._authorIndexOpt)
5504 class WConfStaticContributionList ( wcomponents.WTemplated ):
5506 def __init__( self, conf, trackDict ):
5507 self._conf = conf
5508 self._trackDict = trackDict
5510 def _getMaterialHTML(self, contrib):
5511 lm=[]
5512 paper=contrib.getPaper()
5513 track=contrib.getTrack()
5514 trackFolder="./other_contributions"
5515 if track is not None:
5516 trackFolder=track.getTitle().replace(" ","_")
5517 for mat in contrib.getAllMaterialList():
5518 url="%s/%s"%(trackFolder, str(urlHandlers.UHStaticMaterialDisplay.getRelativeURL(mat)))
5519 lm.append("""<a href=%s><span style="font-style: italic;"><small> %s</small></span></a>"""%(
5520 quoteattr(url),
5521 self.htmlText(mat.getTitle().lower())))
5522 return ", ".join(lm)
5524 def _getTrackHTML(self, track):
5525 return """
5526 <tr><td colspan="5">&nbsp;</td></tr>
5527 <tr>
5528 <td class="groupTitle" colspan="5" style="background:#E5E5E5; color:gray">%s</td>
5529 </tr>
5530 <tr><td colspan="5">&nbsp;</td></tr>
5531 """%(track.getTitle())
5533 def _getContribHTML( self, contrib ):
5534 sdate = ""
5535 if contrib.isScheduled():
5536 sdate=contrib.getAdjustedStartDate().strftime("%d-%b-%Y %H:%M" )
5537 title = """<a href=%s>%s</a>"""%( quoteattr( str( urlHandlers.UHStaticContributionDisplay.getRelativeURL( contrib ) ) ), self.htmlText( contrib.getTitle() ))
5538 contribType = ""
5539 if contrib.getType() is not None:
5540 contribType = contrib.getType().getName()
5541 l = []
5542 for spk in contrib.getSpeakerList():
5543 l.append( self.htmlText( spk.getFullName() ) )
5544 speaker = "<br>".join( l )
5545 session = ""
5546 if contrib.getSession() is not None:
5547 if contrib.getSession().getCode() != "no code":
5548 session=self.htmlText(contrib.getSession().getCode())
5549 else:
5550 session=self.htmlText(contrib.getSession().getTitle())
5551 track = ""
5552 if contrib.getTrack() is not None:
5553 track = self.htmlText( contrib.getTrack().getCode() )
5554 html = """
5555 <tr>
5556 <td class="abstractLeftDataCell">%s</td>
5557 <td class="abstractDataCell">%s</td>
5558 <td class="abstractDataCell">%s</td>
5559 <td class="abstractDataCell">%s</td>
5560 <td class="abstractDataCell">%s</td>
5561 </tr>
5562 """%(title or "&nbsp;", speaker or "&nbsp;",
5563 self._getMaterialHTML(contrib) or "&nbsp;",
5564 contribType or "&nbsp;",
5565 self.htmlText( contrib.getId() )
5567 return html
5569 def _cmpContribTitle(c1, c2):
5570 o1=c1.getTitle().lower().strip()
5571 o2=c2.getTitle().lower().strip()
5572 return cmp( o1, o2 )
5573 _cmpContribTitle=staticmethod(_cmpContribTitle)
5575 def getVars( self ):
5576 vars = wcomponents.WTemplated.getVars( self )
5578 l = []
5579 #for track in self._conf.getTrackList():
5580 # l.append(self._getTrackHTML(track))
5581 # for contrib in self._trackDict[track.getId()]:
5582 # l.append( self._getContribHTML( contrib ) )
5583 contList=self._conf.getContributionList()
5584 contList.sort(WConfStaticContributionList._cmpContribTitle)
5585 for contrib in contList:
5586 l.append( self._getContribHTML( contrib ) )
5587 vars["contributions"] = "".join(l)
5589 return vars
5591 class WPStaticContributionList( WPConferenceStaticDefaultDisplayBase ):
5593 def __init__(self, rh, target, staticPars, trackDict):
5594 WPConferenceStaticDefaultDisplayBase.__init__(self, rh, target)
5595 self._staticPars = staticPars
5596 self._trackDict = trackDict
5598 def _getBody( self, params ):
5599 wc = WConfStaticContributionList( self._conf, self._trackDict)
5600 return wc.getHTML()
5602 def _defineSectionMenu( self ):
5603 WPConferenceStaticDefaultDisplayBase._defineSectionMenu( self )
5604 self._sectionMenu.setCurrentItem(self._contribListOpt)
5606 class WPContributionStaticDisplay( WPConferenceStaticDefaultDisplayBase ):
5608 def __init__(self, rh, target, staticPars):
5609 WPConferenceStaticDefaultDisplayBase.__init__(self, rh, target.getConference())
5610 self._staticPars = staticPars
5611 self._contrib = target
5613 def _getBody( self, params ):
5614 wc=WContributionStaticDisplay( self._getAW(), self._contrib, self._staticPars )
5615 return wc.getHTML()
5617 def _defineSectionMenu( self ):
5618 WPConferenceStaticDefaultDisplayBase._defineSectionMenu( self )
5619 self._sectionMenu.setCurrentItem(self._contribListOpt)
5621 class WContributionStaticDisplay(wcomponents.WTemplated):
5623 def __init__(self, aw, contrib, staticPars):
5624 self._aw = aw
5625 self._contrib = contrib
5626 self._staticPars=staticPars
5628 def _getHTMLRow( self, title, body):
5629 if body.strip() == "":
5630 return ""
5631 str = """
5632 <tr>
5633 <td align="right" valign="top" class="displayField" nowrap><b>%s:</b></td>
5634 <td width="100%%">%s</td>
5635 </tr>"""%(title, body)
5636 return str
5638 def _getMaterialHTML(self):
5639 lm=[]
5640 paper=self._contrib.getPaper()
5641 if paper is not None:
5642 lm.append("""<a href=%s><img src=%s border="0" alt="paper"> %s</a>"""%(
5643 quoteattr(str(urlHandlers.UHStaticMaterialDisplay.getRelativeURL(paper))),
5644 quoteattr(str(self._staticPars["paper"])),
5645 self.htmlText(materialFactories.PaperFactory().getTitle())))
5646 slides=self._contrib.getSlides()
5647 if slides is not None:
5648 lm.append("""<a href=%s><img src=%s border="0" alt="slides"> %s</a>"""%(
5649 quoteattr(str(urlHandlers.UHStaticMaterialDisplay.getRelativeURL(slides))),
5650 quoteattr(str(self._staticPars["slides"])),
5651 self.htmlText(materialFactories.SlidesFactory().getTitle())))
5652 poster=self._contrib.getPoster()
5653 if poster is not None:
5654 lm.append("""<a href=%s><img src=%s border="0" alt="poster"> %s</a>"""%(
5655 quoteattr(str(urlHandlers.UHStaticMaterialDisplay.getRelativeURL(poster))),
5656 quoteattr(str(self._staticPars["poster"])),
5657 self.htmlText(materialFactories.PosterFactory().getTitle())))
5658 video=self._contrib.getVideo()
5659 if video is not None:
5660 lm.append("""<a href=%s><img src=%s border="0" alt="video"> %s</a>"""%(
5661 quoteattr(str(urlHandlers.UHStaticMaterialDisplay.getRelativeURL(video))),
5662 quoteattr(str(self._staticPars["video"])),
5663 self.htmlText(materialFactories.VideoFactory().getTitle())))
5664 iconURL=quoteattr(str(self._staticPars["material"]))
5665 for material in self._contrib.getMaterialList():
5666 url=urlHandlers.UHStaticMaterialDisplay.getRelativeURL(material)
5667 lm.append("""<a href=%s><img src=%s border="0" alt=""> %s</a>"""%(
5668 quoteattr(str(url)),iconURL,self.htmlText(material.getTitle())))
5669 return self._getHTMLRow("Material","<br>".join(lm))
5671 def getVars( self ):
5672 vars = wcomponents.WTemplated.getVars( self )
5674 vars["title"] = self.htmlText(self._contrib.getTitle())
5675 vars["description"] = self._contrib.getDescription()
5676 vars["id"]=self.htmlText(self._contrib.getId())
5677 vars["startDate"] = i18nformat("""--_("not yet scheduled")--""")
5678 vars["startTime"] = ""
5679 if self._contrib.isScheduled():
5680 vars["startDate"]=self.htmlText(self._contrib.getAdjustedStartDate().strftime("%d-%b-%Y"))
5681 vars["startTime"]=self.htmlText(self._contrib.getAdjustedStartDate().strftime("%H:%M"))
5682 vars["location"]=""
5683 loc=self._contrib.getLocation()
5684 if loc is not None:
5685 vars["location"]="<i>%s</i>"%(self.htmlText(loc.getName()))
5686 if loc.getAddress() is not None and loc.getAddress()!="":
5687 vars["location"]="%s <pre>%s</pre>"%(vars["location"],loc.getAddress())
5688 room=self._contrib.getRoom()
5689 if room is not None:
5690 roomLink=linking.RoomLinker().getHTMLLink(room,loc)
5691 vars["location"]= i18nformat("""%s <small> _("Room"):</small> %s""")%(\
5692 vars["location"],roomLink)
5693 vars["location"]=self._getHTMLRow( _("Place"),vars["location"])
5694 l=[]
5695 for speaker in self._contrib.getSpeakerList():
5696 l.append(self.htmlText(speaker.getFullName()))
5697 vars["speakers"]=self._getHTMLRow( _("Presenters"),"<br>".join(l))
5699 pal = []
5700 for pa in self._contrib.getPrimaryAuthorList():
5701 authCaption="%s"%pa.getFullName()
5702 if pa.getAffiliation()!="":
5703 authCaption="%s (%s)"%(authCaption,pa.getAffiliation())
5704 pal.append(self.htmlText(authCaption))
5705 vars["primaryAuthors"]=self._getHTMLRow( _("Primary Authors"),"<br>".join(pal))
5706 cal = []
5707 for ca in self._contrib.getCoAuthorList():
5708 authCaption="%s"%ca.getFullName()
5709 if ca.getAffiliation()!="":
5710 authCaption="%s (%s)"%(authCaption,ca.getAffiliation())
5711 cal.append(self.htmlText(authCaption))
5712 vars["coAuthors"]=self._getHTMLRow( _("Co-Authors"),"<br>".join(cal))
5713 vars["contribType"]=""
5714 if self._contrib.getType() != None:
5715 vars["contribType"]=self._getHTMLRow( _("Contribution type"),self.htmlText(self._contrib.getType().getName()))
5716 vars["material"]=self._getMaterialHTML()
5717 vars["duration"]=""
5718 if self._contrib.getDuration() is not None:
5719 vars["duration"]=(datetime(1900,1,1)+self._contrib.getDuration()).strftime("%M'")
5720 if (datetime(1900,1,1)+self._contrib.getDuration()).hour>0:
5721 vars["duration"]=(datetime(1900,1,1)+self._contrib.getDuration()).strftime("%Hh%M'")
5722 vars["inTrack"]=""
5723 if self._contrib.getTrack():
5724 trackCaption=self._contrib.getTrack().getTitle()
5725 vars["inTrack"]="""%s"""%(self.htmlText(trackCaption))
5726 vars["inTrack"]=self._getHTMLRow( _("Included in track"),vars["inTrack"])
5727 return vars
5729 class WMaterialStaticDisplay(wcomponents.WTemplated):
5731 def __init__(self, aw, material, staticPars):
5732 self._material=material
5733 self._aw=aw
5734 self._staticPars = staticPars
5736 def getVars( self ):
5737 vars=wcomponents.WTemplated.getVars( self )
5738 if isinstance(self._material, conference.Paper):
5739 vars["icon"]=quoteattr(str(self._staticPars["paper"]))
5740 elif isinstance(self._material, conference.Slides):
5741 vars["icon"]=quoteattr(str(self._staticPars["slides"]))
5742 else:
5743 vars["icon"]=quoteattr(str(self._staticPars["material"]))
5744 vars["title"]=self._material.getTitle()
5745 vars["description"]=self._material.getDescription()
5746 rl = []
5747 for res in self._material.getResourceList():
5748 # TODO: remove the check "isinstance", it is only for CHEP04
5749 if isinstance(res ,conference.Link):# and not isinstance(self._material, conference.Video):
5750 rl.append("""<tr><td align="left">[LINK]</td><td width="100%%" align="left"><b>%s</b> <small>(<a href="%s">%s</a>)</small)</td></tr>"""%(res.getName(), res.getURL(), res.getURL()))
5751 else:
5752 rl.append("""
5753 <tr>
5754 <td align="left">&nbsp;</td>
5755 <td width="100%%" align="left"><b>%s</b> <small>(<a href="%s/%s">%s</a> %s)</small></td>
5756 </tr>"""%(res.getName(),
5757 vars["rootDir"], vars["fileAccessURLGen"](res),
5758 res.getFileName(),strfFileSize(res.getSize())))
5759 vars["resources"] = """
5760 <table border="0" width="100%%" align="left">
5762 </table>"""%"".join(rl)
5763 return vars
5766 class WPMaterialStaticDisplay( WPConferenceStaticDefaultDisplayBase ):
5768 def __init__(self, rh, material, staticPars):
5769 WPConferenceStaticDefaultDisplayBase.__init__(self, rh, material.getConference())
5770 self._material=material
5771 self._staticPars = staticPars
5773 def _getBody( self, params ):
5774 wc = WMaterialStaticDisplay( self._getAW(), self._material, self._staticPars )
5775 pars = {"rootDir":".", "fileAccessURLGen": urlHandlers.UHStaticResourceDisplay.getRelativeURL }
5776 return wc.getHTML( pars )
5778 class WTrackStaticContribList ( wcomponents.WTemplated ):
5780 def __init__( self, track, trackDict ):
5781 self._track = track
5782 self._conf = track.getConference()
5783 self._trackDict = trackDict
5785 def _getTrackHTML(self, track):
5786 return """
5787 <tr><td colspan="5">&nbsp;</td></tr>
5788 <tr>
5789 <td class="groupTitle" colspan="5" style="background:#E5E5E5; color:gray">%s</td>
5790 </tr>
5791 <tr><td colspan="5">&nbsp;</td></tr>
5792 """%(track.getTitle())
5794 def _getMaterialHTML(self, contrib):
5795 lm=[]
5796 paper=contrib.getPaper()
5797 track=contrib.getTrack()
5798 trackFolder="./other_contributions"
5799 if track is not None:
5800 trackFolder=track.getTitle().replace(" ","_")
5801 for mat in self._conf.getAllMaterialList():
5802 url="%s/%s"%(trackFolder, str(urlHandlers.UHStaticMaterialDisplay.getRelativeURL(mat)))
5803 lm.append("""<a href=%s><span style="font-style: italic;"><small> %s</small></span></a>"""%(
5804 quoteattr(url),
5805 self.htmlText(mat.getTitle().lower())))
5806 return ", ".join(lm)
5808 def _getContribHTML( self, contrib ):
5809 sdate = ""
5810 if contrib.isScheduled():
5811 sdate=contrib.getAdjustedStartDate().strftime("%d-%b-%Y %H:%M" )
5812 title = """<a href=%s>%s</a>"""%( quoteattr( str( urlHandlers.UHStaticContributionDisplay.getRelativeURL( contrib ) ) ), self.htmlText( contrib.getTitle() ))
5813 contribType = ""
5814 if contrib.getType() is not None:
5815 contribType = contrib.getType().getName()
5816 l = []
5817 for spk in contrib.getSpeakerList():
5818 l.append( self.htmlText( spk.getFullName() ) )
5819 speaker = "<br>".join( l )
5820 session = ""
5821 if contrib.getSession() is not None:
5822 if contrib.getSession().getCode() != "no code":
5823 session=self.htmlText(contrib.getSession().getCode())
5824 else:
5825 session=self.htmlText(contrib.getSession().getTitle())
5826 track = ""
5827 if contrib.getTrack() is not None:
5828 track = self.htmlText( contrib.getTrack().getCode() )
5829 html = """
5830 <tr>
5831 <td class="abstractLeftDataCell">%s</td>
5832 <td class="abstractDataCell">%s</td>
5833 <td class="abstractDataCell">%s</td>
5834 <td class="abstractDataCell">%s</td>
5835 <td class="abstractDataCell">%s</td>
5836 </tr>
5837 """%(title or "&nbsp;", speaker or "&nbsp;",
5838 self._getMaterialHTML(contrib) or "&nbsp;",
5839 contribType or "&nbsp;",
5840 self.htmlText( contrib.getId() )
5842 return html
5844 def getVars( self ):
5845 vars = wcomponents.WTemplated.getVars( self )
5847 l = []
5848 l.append(self._getTrackHTML(self._track))
5849 for contrib in self._trackDict[self._track.getId()]:
5850 l.append( self._getContribHTML( contrib ) )
5851 vars["contributions"] = "".join(l)
5853 return vars
5855 class WPTrackStaticContribList( WPConferenceStaticDefaultDisplayBase ):
5857 def __init__(self, rh, target, staticPars, trackDict):
5858 WPConferenceStaticDefaultDisplayBase.__init__(self, rh, target.getConference())
5859 self._staticPars = staticPars
5860 self._track = target
5861 self._trackDict = trackDict
5863 def _getBody( self, params ):
5864 wc = WTrackStaticContribList( self._track, self._trackDict)
5865 return wc.getHTML()
5867 def _defineSectionMenu( self ):
5868 WPConferenceStaticDefaultDisplayBase._defineSectionMenu( self )
5869 self._sectionMenu.setCurrentItem(self._programOpt)
5871 class WPStaticMeetingBase(WPConferenceStaticDefaultDisplayBase):
5873 def getRootDir(self, target):
5874 rootDir="."
5875 if not isinstance(target, conference.Conference):
5876 rootDir="%s/.."%rootDir
5877 owner=target.getOwner()
5878 while not isinstance(owner, conference.Conference):
5879 rootDir="%s/.."%rootDir
5880 owner=owner.getOwner()
5881 return rootDir
5883 def _getHTMLHeader( self ):
5884 path = Config.getInstance().getStylesheetsDir()
5885 # if a css file is associated with the XSL stylesheet, then we include it in the header
5886 styleText = """<link rel="stylesheet" href="%s/css/%s">
5887 <link rel="stylesheet" href="%s/css/events/common.css">""" % \
5888 (self.getRootDir(self._target), Config.getInstance().getCssStylesheetName(), self.getRootDir(self._target))
5889 try:
5890 if os.path.exists("%s.css" % (os.path.join(path,self._view))):
5891 styleText += """
5892 <style type="text/css">
5894 </style>""" % open("%s/%s.css" % (path,self._view),"r").read()
5895 except AttributeError, e:
5896 pass
5897 return """
5898 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5899 <html>
5900 <head>
5901 <title>%s</title>
5902 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
5903 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5904 <link rel="shortcut icon" href=%s>
5906 </head>
5907 <body>"""%(self._getTitle(),
5908 quoteattr(self._staticPars["addressBarIcon"]),
5909 styleText)
5911 def _getHeader( self ):
5914 wc = wcomponents.WStaticWebHeader()
5915 params = {}
5916 params["imgLogo"] = self._staticPars["miniLogo"]
5917 return wc.getHTML( params )
5919 def _applyConfDisplayDecoration( self, body ):
5920 return body
5923 class WPXSLMeetingStaticDisplay( WPStaticMeetingBase ):
5925 def __init__(self, rh, target, staticPars):
5926 WPStaticMeetingBase.__init__(self, rh, target.getConference())
5927 self._view = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(target.getConference()).getDefaultStyle()
5928 if self._view =="static":
5929 self._view="standard"
5930 self._type = "meeting"
5931 self._params={}
5932 self._params["showDate"] = "all"
5933 self._params["showSession"] = "all"
5934 self._params["detailLevel"] = "contribution"
5935 self._conf = self._target=target
5936 self._staticPars = staticPars
5938 def _getBody( self, params ):
5939 pars = { \
5940 "modifyURL": "", \
5941 "materialURL": "", \
5942 "cloneURL": "", \
5943 "sessionModifyURLGen": "", \
5944 "contribModifyURLGen": "", \
5945 "contribMaterialURLGen": "", \
5946 "subContribMaterialURLGen": "", \
5947 "sessionMaterialURLGen": "", \
5948 "subContribModifyURLGen": "", \
5949 "materialURLGen": urlHandlers.UHMStaticMaterialDisplay.getRelativeURL, \
5950 "resourceURLGen": urlHandlers.UHMStaticResourceDisplay.getRelativeURL}
5951 view = self._view
5952 from MaKaC.accessControl import AccessWrapper
5953 outGen = outputGenerator(AccessWrapper())
5954 path = Config.getInstance().getStylesheetsDir()
5955 stylepath = "%s.xsl" % (os.path.join(path, view))
5956 if os.path.exists(stylepath):
5957 if self._params.get("detailLevel", "") == "contribution" or self._params.get("detailLevel", "") == "":
5958 includeContribution = 1
5959 else:
5960 includeContribution = 0
5961 return outGen.getFormattedOutput(self._rh, self._conf, stylepath, pars, 1, includeContribution, 1, 1, self._params.get("showSession",""), self._params.get("showDate",""))
5962 else:
5963 return "Cannot find the %s stylesheet" % view
5965 class WPMMaterialStaticDisplay( WPStaticMeetingBase ):
5967 def __init__(self, rh, material, staticPars):
5968 WPStaticMeetingBase.__init__(self, rh, material.getConference())
5969 self._material=self._target=material
5970 self._staticPars = staticPars
5972 def _applyConfDisplayDecoration( self, body ):
5973 from MaKaC.webinterface.meeting import WMConfDisplayFrame
5974 frame = WMConfDisplayFrame( self._getAW(), self._conf )
5975 frameParams = {\
5976 "logoURL": urlHandlers.UHConferenceLogo.getURL( self._conf) }
5977 if self._conf.getLogo():
5978 frameParams["logoURL"] = urlHandlers.UHConferenceLogo.getURL( self._conf)
5980 confTitle = self._conf.getTitle()
5981 colspan=""
5982 imgOpen=""
5983 padding=""
5984 padding=""" style="padding:0px" """
5985 urlIndex=str(urlHandlers.UHStaticConferenceDisplay.getRelativeURL())
5986 urlIndex="%s/%s"%(self.getRootDir(self._material), urlIndex)
5987 body = i18nformat("""
5988 <div class="confBodyBox clearfix" %s %s>
5990 <table border="0" cellpadding="0" cellspacing="0"
5991 align="center" valign="top" width="95%%">
5992 <tr>
5993 <td class="formTitle" width="100%%"> _("Added Material") - %s</td>
5994 </tr>
5995 <tr>
5996 <td align="left" valign="middle" width="100%%">
5997 <b><br><a href=%s> _("Home")</a></b>
5998 </td>
5999 </tr>
6000 </table>
6001 <!--Main body-->
6003 </div>""")%(colspan,padding,imgOpen, confTitle,
6004 quoteattr(urlIndex),
6005 body)
6006 return frame.getHTML( body, frameParams)
6008 def _getBody( self, params ):
6009 wc = WMaterialStaticDisplay( self._getAW(), self._material, self._staticPars )
6010 pars = { "rootDir":self.getRootDir(self._material), "fileAccessURLGen": urlHandlers.UHMStaticResourceDisplay.getRelativeURL }
6011 return wc.getHTML( pars )
6014 class WConferenceStaticTimeTable(wcomponents.WTemplated):
6016 def __init__( self, timeTable, conference, aw ):
6017 self._aw = aw
6018 self._timeTable = timeTable
6019 self._conf = conference
6020 self._sessionColorMap = {}
6022 def _getRandomColor( self, color=1 ):
6023 if color==0:
6024 r=g=b = random.randint(130,255)
6025 else:
6026 r = random.randint(130,255)
6027 g = random.randint(130,255)
6028 b = random.randint(130,255)
6029 return "#%X%X%X"%(r,g,b)
6031 def _generateColor( self, color=1, colorMap={} ):
6033 This function generates a color which does not already exist in the passed colormap
6034 params:
6035 color: indicates whether the returned color should be gray-level or colored
6036 colormap: returned color must not be in this dict.
6038 color = self._getRandomColor(color)
6039 while(color in colorMap.values()):
6040 color = self._getRandomColor(color)
6041 return color
6043 def _getSessionColor( self, session ):
6044 if session.getId() not in self._sessionColorMap.keys():
6045 color = session.getColor()
6046 # if color=="#F0C060" and color in self._sessionColorMap.values():
6047 # color = self._generateColor(1,self._sessionColorMap)
6048 self._sessionColorMap[session.getId()] = color
6049 return self._sessionColorMap[session.getId()]
6051 def _getColor( self, entry ):
6052 bgcolor = "#E6E6E6"
6053 if isinstance(entry, schedule.LinkedTimeSchEntry) and \
6054 isinstance(entry.getOwner(), conference.SessionSlot):
6055 bgcolor = self._getSessionColor( entry.getOwner().getSession() )
6056 elif isinstance(entry, schedule.LinkedTimeSchEntry) and \
6057 isinstance(entry.getOwner(), conference.Contribution):
6058 contrib = entry.getOwner()
6059 if contrib.getSession():
6060 bgcolor = self._getSessionColor( contrib.getSession() )
6061 else:
6062 bgcolor = "#F6F6F6"
6063 elif isinstance(entry, schedule.BreakTimeSchEntry):
6064 owner = entry.getSchedule().getOwner()
6065 if isinstance(owner,conference.Session):
6066 bgcolor = self._getSessionColor( owner )
6067 else:
6068 bgcolor = "#90C0F0"
6069 if entry.getColor()!="":
6070 bgcolor=entry.getColor()
6071 return bgcolor
6073 def _getTextColor( self, entry ):
6074 textcolor = "#777777"
6075 if isinstance(entry, schedule.LinkedTimeSchEntry) and \
6076 isinstance(entry.getOwner(), conference.SessionSlot):
6077 textcolor = entry.getOwner().getSession().getTextColor()
6078 elif isinstance(entry, schedule.LinkedTimeSchEntry) and \
6079 isinstance(entry.getOwner(), conference.Contribution):
6080 contrib = entry.getOwner()
6081 if contrib.getSession():
6082 textcolor = contrib.getSession().getTextColor()
6083 elif isinstance(entry, schedule.BreakTimeSchEntry):
6084 owner = entry.getSchedule().getOwner()
6085 if isinstance(owner,conference.Session):
6086 textcolor = owner.getTextColor()
6087 else:
6088 if entry.getTextColor()!="":
6089 textcolor=entry.getTextColor()
6090 return textcolor
6092 def _getContributionHTML( self, contribution, URL ):
6093 room = ""
6094 if contribution.getRoom() != None:
6095 room = "%s: "%contribution.getRoom().getName()
6096 speakerList = []
6097 for spk in contribution.getSpeakerList():
6098 spkcapt=spk.getFullName()
6099 if spk.getAffiliation().strip() != "":
6100 spkcapt="%s (%s)"%(spkcapt, spk.getAffiliation())
6101 speakerList.append(spkcapt)
6102 speakers =""
6103 if speakerList != []:
6104 speakers = "<br><small>by %s</small>"%"; ".join(speakerList)
6105 linkColor=""
6106 if contribution.getSession() is not None:
6107 if contribution.getSession().isTextColorToLinks():
6108 linkColor="color:%s"%contribution.getSession().getTextColor()
6109 return """<table width="100%%">
6110 <tr>
6111 <td width="100%%" align="center" style="%s">
6112 [%s] <a href="%s" style="%s">%s</a>%s<br><small>(%s%s - %s)</small>
6113 </td>
6114 </tr>
6115 </table>"""%(linkColor, self.htmlText(contribution.getId()),URL, linkColor,
6116 self.htmlText(contribution.getTitle()),
6117 speakers, room,
6118 contribution.getAdjustedStartDate().strftime("%H:%M"),
6119 contribution.getAdjustedEndDate().strftime("%H:%M") )
6121 def _getSessionHTML( self, session, URL, refDay ):
6122 room = ""
6123 if session.getRoom() != None:
6124 room = "%s: "%session.getRoom().getName()
6125 #################################
6126 # Fermi timezone awareness #
6127 #################################
6128 sDate = session.getAdjustedStartDate()
6129 eDate = session.getAdjustedEndDate()
6130 timeInterval = "<br>(%s%s - %s)"%(room, \
6131 sDate.strftime("%H:%M"), \
6132 eDate.strftime("%H:%M") )
6133 if session.getAdjustedStartDate().strftime("%d%B%Y") != \
6134 refDay.getDate().strftime("%d%B%Y") :
6135 if session.getAdjustedEndDate().strftime("%d%B%Y") != \
6136 refDay.getDate().strftime("%d%B%Y") :
6137 timeInterval = ""
6138 else:
6139 timeInterval = i18nformat("""<br>(%s_("until") %s)""")%(room, eDate.strftime("%H:%M"))
6140 else:
6141 if session.getAdjustedEndDate().strftime("%d%B%Y") != \
6142 refDay.getDate().strftime("%d%B%Y") :
6143 timeInterval = i18nformat("""<br>(%s_("from") %s)""")%(room, sDate.strftime("%H:%M"))
6145 #################################
6146 # Fermi timezone awareness(end) #
6147 #################################
6148 conveners=""
6149 l=[]
6150 for conv in session.getConvenerList():
6151 l.append("""%s"""%(self.htmlText(conv.getDirectFullName())))
6152 if len(l)>0:
6153 conveners= i18nformat("""<br><small> _("Conveners"): %s</small>""")%"; ".join(l)
6154 title = self.htmlText(session.getSession().getTitle())
6155 if session.getTitle().strip() != "":
6156 title = "%s: %s"%(title, session.getTitle())
6157 linkColor=""
6158 if session.getSession().isTextColorToLinks():
6159 linkColor="color:%s"%session.getSession().getTextColor()
6160 return """<a href="%s" style="%s">%s</a>%s<small>%s</small>"""%(URL, linkColor,\
6161 title, conveners, timeInterval )
6163 def _getBreakHTML( self, breakEntry ):
6164 room = ""
6165 if breakEntry.getRoom() != None:
6166 room = "%s: "%breakEntry.getRoom().getName()
6168 ################################
6169 # Fermi timezone awareness #
6170 ################################
6171 sDate = breakEntry.getAdjustedStartDate()
6172 eDate = breakEntry.getAdjustedEndDate()
6173 return """<b>%s</b><br><small>(%s%s - %s)</small>"""%( breakEntry.getTitle(),\
6174 room, \
6175 sDate.strftime("%H:%M"),\
6176 eDate.strftime("%H:%M") )
6177 ################################
6178 # Fermi timezone awareness(end) #
6179 ################################
6181 def _getEntryHTML(self,entry,refDay):
6182 if isinstance(entry,schedule.LinkedTimeSchEntry):
6183 if isinstance(entry.getOwner(),conference.SessionSlot):
6184 return self._getSessionHTML(entry.getOwner(),self._sessionURLGen(entry.getOwner().getSession()),refDay)
6185 if isinstance(entry.getOwner(), conference.Contribution):
6186 return self._getContributionHTML(entry.getOwner(), \
6187 self._contribURLGen(entry.getOwner()))
6188 elif isinstance(entry,schedule.BreakTimeSchEntry):
6189 return self._getBreakHTML(entry)
6191 def _getColorLegendItemHTML( self, color, descrip ):
6192 str = """ <span height="10px" width="20px" style="background:%s; border:1px solid black;font-size: 10px;">&nbsp;&nbsp;</span>
6193 <span align="left" style="font-size: 10px;">%s</span>
6194 """%(color, descrip)
6195 return str
6197 def _getColorLegendHTML( self ):
6198 html = """<table bgcolor="white" cellpadding="0" cellspacing="1" width="100%%" style="padding:3px; border-top:1px solid #E6E6E6;border-bottom:1px solid #E6E6E6;">
6199 <tr>
6200 <td bgcolor="white" width="100%%" align="center">
6201 &nbsp;
6203 </td>
6204 </tr>
6205 </table>
6207 l = []
6208 l.append( self._getColorLegendItemHTML( "#90C0F0", _("Conference break")) )
6209 l.append( self._getColorLegendItemHTML( "#F6F6F6", _("Conference contribution")) )
6210 for sessionId in self._sessionColorMap.keys():
6211 session = self._conf.getSessionById( sessionId )
6212 str = self._getColorLegendItemHTML(\
6213 self._sessionColorMap[ sessionId ],\
6214 i18nformat(""" _("Session"): <i>%s </i>""")%session.getTitle())
6215 l.append( str )
6216 return html%" - ".join( l )
6218 def _getHTMLTimeTable( self, highDetailLevel=0 ):
6219 self._sessionColorMap = {}
6220 daySch = []
6221 num_slots_in_hour=int(timedelta(hours=1).seconds/self._timeTable.getSlotLength().seconds)
6222 for day in self._timeTable.getDayList():
6223 self._sessionColorMap.clear()
6224 emptyDay=True
6225 slotList=[]
6226 lastEntries=[]
6227 maxOverlap=day.getNumMaxOverlaping()
6228 width="100"
6229 if maxOverlap!=0:
6230 width=100/maxOverlap
6231 else:
6232 maxOverlap=1
6233 for hour in range(day.getStartHour(),day.getEndHour()+1):
6234 hourSlots=[]
6235 emptyHour = True
6236 for slot in day.getSlotsOnHour(hour):
6237 remColSpan=maxOverlap
6238 temp=[]
6239 entryList=slot.getEntryList()
6240 entryList.sort(timetable.sortEntries)
6241 for entry in entryList:
6242 emptyHour = False
6243 emptyDay = False
6244 if len(slot.getEntryList()):
6245 remColSpan=0
6246 else:
6247 remColSpan-=1
6248 if entry in lastEntries:
6249 continue
6250 bgcolor=self._getColor(entry)
6251 textcolor=self._getTextColor(entry)
6252 colspan=""
6253 if not day.hasEntryOverlaps(entry):
6254 colspan=""" colspan="%s" """%maxOverlap
6255 temp.append("""<td valign="top" rowspan="%i" align="center" bgcolor="%s" width="%i%%"%s><font color="%s">%s</font></td>"""%(day.getNumSlots(entry),bgcolor, width, colspan, textcolor, self._getEntryHTML(entry,day)))
6256 lastEntries.append(entry)
6257 if remColSpan>0:
6258 temp.append("""<td width="100%%" colspan="%i"></td>"""%(remColSpan))
6259 if slot.getAdjustedStartDate().minute==0:
6260 hourSlots.append("""
6261 <tr>
6262 <td valign="top" rowspan="%s" bgcolor="white" width="10" style="padding-right: 5px;"><font color="gray" size="-1">%02i:00</font></td>
6264 </tr>
6265 """%(num_slots_in_hour,\
6266 hour,\
6267 "".join(temp)))
6268 else:
6269 if len(temp) == 0:
6270 temp = ["<td></td>"]
6271 hourSlots.append("""<tr>%s</tr>"""%"".join(temp))
6272 if emptyHour:
6273 slotList.append("""
6274 <tr>
6275 <td valign="top" bgcolor="white" width="10" style="padding-right: 5px;"><font color="gray" size="-1">%02i:00</font></td>
6276 <td>&nbsp;</td>
6277 </tr>""" % hour)
6278 else:
6279 slotList.append("".join(hourSlots))
6280 legend=""
6281 if highDetailLevel:
6282 legend=self._getColorLegendHTML()
6283 if not emptyDay:
6284 str="""
6285 <table align="center" width="100%%">
6286 <tr>
6287 <td width="100%%">
6288 <table align="center" border="0" width="100%%"
6289 celspacing="0" cellpadding="0" bgcolor="#E6E6E6">
6290 <tr>
6291 <td colspan="%i" align="center" bgcolor="white"><b>%s</b></td>
6292 </tr>
6293 <tr>
6294 <td colspan="%i">%s</td>
6295 </tr>
6297 </table>
6298 </td>
6299 </tr>
6300 </table>
6301 """%(maxOverlap+2,\
6302 format_date(day.getDate(), format='full'), \
6303 maxOverlap+2, legend, \
6304 "".join(slotList) )
6305 daySch.append(str)
6306 str = "<br>".join( daySch )
6307 return str
6309 def getVars( self ):
6310 vars = wcomponents.WTemplated.getVars( self )
6311 self._contribURLGen = vars["contribURLGen"]
6312 self._sessionURLGen = vars["sessionURLGen"]
6313 vars["timetable"] = self._getHTMLTimeTable(vars.get("detailLevel", "") == "contribution")
6314 return vars
6318 class WPConferenceStaticTimeTable( WPConferenceStaticDefaultDisplayBase ):
6320 def __init__(self, rh, target, staticPars):
6321 WPConferenceStaticDefaultDisplayBase.__init__(self, rh, target)
6322 self._staticPars = staticPars
6324 def _getEntryList(self):
6325 lsessions = self._conf.getSchedule().getEntries()
6326 res = []
6327 for entry in lsessions:
6328 if isinstance(entry,schedule.LinkedTimeSchEntry):
6329 owner = entry.getOwner()
6330 if isinstance(owner, conference.SessionSlot):
6331 if owner.canAccess(self._getAW()):
6332 res.append( entry )
6333 elif owner.canView(self._getAW()):
6334 if isinstance(owner,conference.SessionSlot):
6335 slot=owner
6336 for slotEntry in slot.getSchedule().getEntries():
6337 if isinstance(slotEntry.getOwner(),conference.Contribution):
6338 if slotEntry.getOwner().canAccess(self._getAW()):
6339 res.append(slotEntry)
6340 else:
6341 if owner.canAccess(self._getAW()):
6342 res.append( entry )
6343 else:
6344 res.append( entry )
6345 return res
6347 def _getParallelTimeTable( self, params ):
6348 tz = DisplayTZ(self._getAW(),self._conf).getDisplayTZ()
6349 tt = timetable.TimeTable( self._conf.getSchedule(), tz )
6350 #####################################
6351 # Fermi timezone awareness #
6352 #####################################
6353 sDate = self._conf.getSchedule().getStartDate(tz)
6354 eDate = self._conf.getSchedule().getEndDate(tz)
6355 #####################################
6356 # Fermi timezone awareness(end) #
6357 #####################################
6358 tt.setStartDate( sDate )
6359 tt.setEndDate( eDate )
6360 tt.mapEntryList(self._getEntryList())
6361 return tt
6363 def _getBody( self, params ):
6364 tt = self._getParallelTimeTable( params )
6365 wc = WConferenceStaticTimeTable( tt, self._conf, self._getAW() )
6366 pars = {"contribURLGen": urlHandlers.UHStaticContributionDisplay.getRelativeURL, \
6367 "sessionURLGen": urlHandlers.UHStaticSessionDisplay.getRelativeURL }
6368 return wc.getHTML( pars )
6370 def _defineSectionMenu( self ):
6371 WPConferenceStaticDefaultDisplayBase._defineSectionMenu( self )
6372 self._sectionMenu.setCurrentItem(self._timetableOpt)
6374 class WSessionStaticDisplay(wcomponents.WTemplated):
6376 def __init__(self,aw,session):
6377 self._aw=aw
6378 self._session=session
6380 def _getHTMLRow(self,title,body):
6381 str = """
6382 <tr>
6383 <td nowrap class="displayField" valign="top"><b>%s:</b></td>
6384 <td>%s</td>
6385 </tr>"""%(title,body)
6386 if body.strip() == "":
6387 return ""
6388 return str
6390 def _getColor(self,entry):
6391 bgcolor = "white"
6392 if isinstance(entry,schedule.LinkedTimeSchEntry):
6393 if isinstance(entry.getOwner(),conference.Contribution):
6394 bgcolor = entry.getOwner().getSession().getColor()
6395 elif isinstance(entry,schedule.BreakTimeSchEntry):
6396 bgcolor = entry.getColor()
6397 return bgcolor
6399 def _getContributionHTML(self,contrib):
6400 URL=urlHandlers.UHStaticContributionDisplay.getRelativeURL(contrib, "..")
6401 room = ""
6402 if contrib.getRoom() != None:
6403 room = "%s: "%contrib.getRoom().getName()
6404 speakerList = []
6405 for spk in contrib.getSpeakerList():
6406 speakerList.append(spk.getDirectFullName())
6407 speakers =""
6408 if speakerList != []:
6409 speakers = i18nformat("""<br><small> _("by") %s</small>""")%"; ".join(speakerList)
6410 linkColor=""
6411 if contrib.getSession().isTextColorToLinks():
6412 linkColor="color:%s"%contrib.getSession().getTextColor()
6413 return """<table width="100%%">
6414 <tr>
6415 <td width="100%%" align="center" style="color:%s">
6416 [%s] <a href="%s" style="%s">%s</a>%s<br><small>(%s%s - %s)</small>
6417 </td>
6418 </tr>
6419 </table>"""%(
6420 contrib.getSession().getTextColor(),contrib.getId(),URL,\
6421 linkColor, contrib.getTitle(),speakers,room,
6422 contrib.getAdjustedStartDate().strftime("%H:%M"),
6423 contrib.getAdjustedEndDate().strftime("%H:%M") )
6425 def _getBreakHTML(self,breakEntry):
6426 return """
6427 <font color="%s">%s<br><small>(%s - %s)</small></font>
6428 """%(\
6429 breakEntry.getTextColor(),\
6430 self.htmlText(breakEntry.getTitle()),\
6431 self.htmlText(breakEntry.getAdjustedStartDate().strftime("%H:%M")),\
6432 self.htmlText(breakEntry.getAdjustedEndDate().strftime("%H:%M")))
6434 def _getSchEntries(self):
6435 res=[]
6436 for slot in self._session.getSlotList():
6437 for entry in slot.getSchedule().getEntries():
6438 res.append(entry)
6439 return res
6441 def _getEntryHTML(self,entry):
6442 if isinstance(entry,schedule.LinkedTimeSchEntry):
6443 if isinstance(entry.getOwner(),conference.Contribution):
6444 return self._getContributionHTML(entry.getOwner())
6445 elif isinstance(entry,schedule.BreakTimeSchEntry):
6446 return self._getBreakHTML(entry)
6448 def _getTimeTableHTML(self):
6449 tz = DisplayTZ(self._aw,self._session.getConference()).getDisplayTZ()
6450 timeTable=timetable.TimeTable(self._session.getSchedule(), tz)
6451 sDate,eDate=self._session.getAdjustedStartDate(tz),self._session.getAdjustedEndDate(tz)
6452 timeTable.setStartDate(sDate)
6453 timeTable.setEndDate(eDate)
6454 timeTable.mapEntryList(self._getSchEntries())
6455 daySch = []
6456 num_slots_in_hour=int(timedelta(hours=1).seconds/timeTable.getSlotLength().seconds)
6457 hourSlots,hourNeedsDisplay=[],False
6458 for day in timeTable.getDayList():
6459 slotList=[]
6460 lastEntries=[]
6461 maxOverlap=day.getNumMaxOverlaping()
6462 width="100"
6463 if maxOverlap!=0:
6464 width=100/maxOverlap
6465 else:
6466 maxOverlap=1
6467 for slot in day.getSlotList():
6468 if slot.getAdjustedStartDate().minute==0:
6469 if hourNeedsDisplay:
6470 slotList.append("".join(hourSlots))
6471 hourSlots,hourNeedsDisplay=[],False
6472 remColSpan=maxOverlap
6473 temp=[]
6474 for entry in slot.getEntryList():
6475 hourNeedsDisplay=True
6476 if len(slot.getEntryList()):
6477 remColSpan=0
6478 else:
6479 remColSpan-=1
6480 if entry in lastEntries:
6481 continue
6482 bgcolor=self._getColor(entry)
6483 colspan=""
6484 if not day.hasEntryOverlaps(entry):
6485 colspan=""" colspan="%s" """%maxOverlap
6486 temp.append("""<td valign="top" rowspan="%i" align="center" bgcolor="%s" width="%i%%"%s>%s</td>"""%(day.getNumSlots(entry),bgcolor,width,colspan,self._getEntryHTML(entry)))
6487 lastEntries.append(entry)
6488 if remColSpan>0:
6489 temp.append("""<td width="100%%" colspan="%i"></td>"""%(remColSpan))
6490 if slot.getAdjustedStartDate().minute==0:
6491 str="""
6492 <tr>
6493 <td valign="top" rowspan="%s" bgcolor="white" width="40"><font color="gray" size="-1">%s</font></td>
6495 </tr>
6496 """%(num_slots_in_hour,\
6497 slot.getAdjustedStartDate().strftime("%H:%M"),\
6498 "".join(temp))
6499 else:
6500 if len(temp) == 0:
6501 temp = ["<td></td>"]
6502 str = """<tr>%s</tr>"""%"".join(temp)
6503 hourSlots.append(str)
6504 str="""
6505 <a name="%s">
6506 <table align="center" width="100%%">
6507 <tr>
6508 <td width="100%%">
6509 <table align="center" border="0" width="100%%"
6510 celspacing="0" cellpadding="0" bgcolor="#E6E6E6">
6511 <tr>
6512 <td colspan="%i" align="center" bgcolor="white"><b>%s</b></td>
6513 </tr>
6515 </table>
6516 </td>
6517 </tr>
6518 </table>
6519 """%(day.getDate().strftime("%Y-%m-%d"),maxOverlap+2,
6520 format_date(day.getDate(), format='full'),
6521 "".join(slotList) )
6522 daySch.append(str)
6523 str = "<br>".join( daySch )
6524 return str
6526 def getVars(self):
6527 vars=wcomponents.WTemplated.getVars( self )
6529 vars["title"]=self.htmlText(self._session.getTitle())
6531 if self._session.getDescription():
6532 desc = self._session.getDescription().strip()
6533 else:
6534 desc = ""
6536 if desc!="":
6537 vars["description"]="""
6538 <tr>
6539 <td colspan="2">%s</td>
6540 </tr>
6541 """%desc
6542 else:
6543 vars["description"] = ""
6545 #################################
6546 # Fermi timezone awareness #
6547 #################################
6548 sDate=self._session.getAdjustedStartDate()
6549 eDate=self._session.getAdjustedEndDate()
6550 if sDate.strftime("%d%b%Y")==eDate.strftime("%d%b%Y"):
6551 vars["dateInterval"]=format_datetime(sDate, format='EEEE d MMMM yyyy H:mm')
6552 else:
6553 vars["dateInterval"]=i18nformat("""_("from") %s _("to") %s""")%(
6554 format_datetime(sDate, format='EEEE d MMMM yyyy H:mm'),
6555 format_datetime(eDate, format='EEEE d MMMM yyyy H:mm'))
6556 #################################
6557 # Fermi timezone awareness(end) #
6558 #################################
6560 vars["location"]=""
6561 loc=self._session.getLocation()
6562 if loc is not None and loc.getName().strip()!="":
6563 vars["location"]="""<i>%s</i>"""%self.htmlText(loc.getName())
6564 if loc.getAddress().strip()!="":
6565 vars["location"]="""%s<pre>%s</pre>"""%(vars["location"],
6566 loc.getAddress())
6567 room = self._session.getRoom()
6568 if room is not None:
6569 roomLink=linking.RoomLinker().getHTMLLink(room,loc)
6570 vars["location"]= i18nformat("""%s<br><small> _("Room"):</small> %s""")%(vars["location"],
6571 roomLink)
6572 vars["location"]=self._getHTMLRow("Place", vars["location"])
6574 sessionConvs=[]
6575 for convener in self._session.getConvenerList():
6576 sessionConvs.append("""<a href="mailto:%s">%s</a>"""%(convener.getEmail(),
6577 self.htmlText(convener.getFullName())))
6578 slotConvsHTML=""
6579 for entry in self._session.getSchedule().getEntries():
6580 slot=entry.getOwner()
6581 l=[]
6582 for convener in slot.getOwnConvenerList():
6583 l.append("""<a href="mailto:%s">%s</a>"""%(convener.getEmail(),
6584 self.htmlText(convener.getFullName())))
6585 if len(l)>0:
6586 slotConvsHTML+="""
6587 <tr>
6588 <td valign="top">%s (<small>%s-%s</small>):</td>
6589 <td>%s</td>
6590 </tr>
6591 """%(self.htmlText(slot.getTitle()),
6592 slot.getAdjustedStartDate().strftime("%d-%b-%y %H:%M"),
6593 slot.getAdjustedEndDate().strftime("%d-%b-%y %H:%M"),
6594 "; ".join(l))
6595 convs=""
6596 if len(sessionConvs)>0 or slotConvsHTML.strip()!="":
6597 convs="""
6598 <table>
6599 <tr>
6600 <td valign="top" colspan="2">%s</td>
6601 </tr>
6603 </table>"""%("<br>".join(sessionConvs),slotConvsHTML)
6604 vars["conveners"]=self._getHTMLRow( _("Conveners"),convs)
6605 lm = []
6606 for material in self._session.getAllMaterialList():
6607 url=urlHandlers.UHStaticMaterialDisplay.getRelativeURL(material)
6608 lm.append(wcomponents.WMaterialDisplayItem().getHTML(self._aw,material,url))
6609 vars["material"] = self._getHTMLRow( _("Material"), "<br>".join( lm ) )
6610 vars["contribs"]= ""
6611 if self._session.getContributionList() != []:
6612 vars["contribs"]=self._getTimeTableHTML()
6613 return vars
6616 class WPSessionStaticDisplay(WPConferenceStaticDefaultDisplayBase):
6618 def __init__(self, rh, target, staticPars):
6619 WPConferenceStaticDefaultDisplayBase.__init__(self, rh, target.getConference())
6620 self._session = target
6621 self._staticPars = staticPars
6623 def _defineSectionMenu(self):
6624 WPConferenceStaticDefaultDisplayBase._defineSectionMenu(self)
6625 self._sectionMenu.setCurrentItem(self._timetableOpt)
6627 def _getBody(self,params):
6628 wc = WSessionStaticDisplay(self._getAW(), self._session)
6629 return wc.getHTML()
6631 #------------------------ End Static ---------------------------------------------------------------
6633 class WTimeTableCustomizePDF(wcomponents.WTemplated):
6635 def __init__(self, conf):
6636 self._conf = conf
6638 def getVars(self):
6639 vars = wcomponents.WTemplated.getVars(self)
6640 url = urlHandlers.UHConfTimeTablePDF.getURL(self._conf)
6641 vars["getPDFURL"] = quoteattr(str(url))
6642 vars["showDays"] = vars.get("showDays", "all")
6643 vars["showSessions"] = vars.get("showSessions", "all")
6645 wc = WConfCommonPDFOptions(self._conf)
6646 vars["commonPDFOptions"] = wc.getHTML()
6648 return vars
6651 class WPTimeTableCustomizePDF(WPConferenceDefaultDisplayBase):
6652 navigationEntry = navigation.NETimeTableCustomizePDF
6654 def _getBody(self, params):
6655 wc = WTimeTableCustomizePDF(self._conf)
6656 return wc.getHTML(params)
6658 def _defineSectionMenu(self):
6659 WPConferenceDefaultDisplayBase._defineSectionMenu(self)
6660 self._sectionMenu.setCurrentItem(self._timetableOpt)
6663 class WConfModifPendingQueuesList(wcomponents.WTemplated):
6665 def __init__(self, url, title, target, list, pType):
6666 self._postURL = url
6667 self._title = title
6668 self._target = target
6669 self._list = list
6670 self._pType = pType
6672 def _cmpByConfName(self, cp1, cp2):
6673 if cp1 is None and cp2 is not None:
6674 return -1
6675 elif cp1 is not None and cp2 is None:
6676 return 1
6677 elif cp1 is None and cp2 is None:
6678 return 0
6679 return cmp(cp1.getTitle(), cp2.getTitle())
6681 def _cmpByContribName(self, cp1, cp2):
6682 if cp1 is None and cp2 is not None:
6683 return -1
6684 elif cp1 is not None and cp2 is None:
6685 return 1
6686 elif cp1 is None and cp2 is None:
6687 return 0
6688 return cmp(cp1.getContribution().getTitle(), cp2.getContribution().getTitle())
6690 def _cmpBySessionName(self, cp1, cp2):
6691 if cp1 is None and cp2 is not None:
6692 return -1
6693 elif cp1 is not None and cp2 is None:
6694 return 1
6695 elif cp1 is None and cp2 is None:
6696 return 0
6697 return cmp(cp1.getSession().getTitle(), cp2.getSession().getTitle())
6699 def getVars(self):
6700 vars = wcomponents.WTemplated.getVars(self)
6702 vars["postURL"] = self._postURL
6703 vars["title"] = self._title
6704 vars["target"] = self._target
6705 vars["list"] = self._list
6706 vars["pType"] = self._pType
6708 return vars
6711 class WConfModifPendingQueues(wcomponents.WTemplated):
6713 def __init__(self, conf, aw, activeTab="submitters"):
6714 self._conf = conf
6715 self._aw = aw
6716 self._activeTab = activeTab
6717 self._pendingConfManagers = self._conf.getPendingQueuesMgr().getPendingConfManagers()
6718 self._pendingConfSubmitters = self._conf.getPendingQueuesMgr().getPendingConfSubmitters()
6719 self._pendingSubmitters = self._conf.getPendingQueuesMgr().getPendingSubmitters()
6720 self._pendingManagers = self._conf.getPendingQueuesMgr().getPendingManagers()
6721 self._pendingCoordinators = self._conf.getPendingQueuesMgr().getPendingCoordinators()
6723 def _createTabCtrl(self):
6724 self._tabCtrl = wcomponents.TabControl()
6725 url = urlHandlers.UHConfModifPendingQueues.getURL(self._conf)
6726 url.addParam("tab", "conf_submitters")
6727 self._tabConfSubmitters = self._tabCtrl.newTab("conf_submitters", \
6728 _("Pending Conference Submitters"),str(url))
6729 url.addParam("tab", "conf_managers")
6730 self._tabConfManagers = self._tabCtrl.newTab("conf_managers", \
6731 _("Pending Conference Managers"),str(url))
6732 url.addParam("tab", "submitters")
6733 self._tabSubmitters = self._tabCtrl.newTab("submitters", \
6734 _("Pending Contribution Submitters"),str(url))
6735 url.addParam("tab", "managers")
6736 self._tabManagers = self._tabCtrl.newTab("managers", \
6737 _("Pending Managers"),str(url))
6738 url.addParam("tab", "coordinators")
6739 self._tabCoordinators = self._tabCtrl.newTab("coordinators", \
6740 _("Pending Coordinators"),str(url))
6741 self._tabSubmitters.setEnabled(True)
6742 tab = self._tabCtrl.getTabById(self._activeTab)
6743 if tab is None:
6744 tab = self._tabCtrl.getTabById("conf_submitters")
6745 tab.setActive()
6747 def getVars(self):
6748 vars = wcomponents.WTemplated.getVars(self)
6749 self._createTabCtrl()
6750 list = []
6751 url = ""
6752 title = ""
6754 if self._tabConfSubmitters.isActive():
6755 # Pending conference submitters
6756 keys = self._conf.getPendingQueuesMgr().getPendingConfSubmittersKeys(True)
6758 url = urlHandlers.UHConfModifPendingQueuesActionConfSubm.getURL(self._conf)
6759 url.addParam("tab","conf_submitters")
6760 title = _("Pending chairpersons/speakers to become submitters")
6761 target = _("Conference")
6762 pType = "ConfSubmitters"
6764 for key in keys:
6765 list.append((key, self._pendingConfSubmitters[key][:]))
6767 elif self._tabConfManagers.isActive():
6768 # Pending conference managers
6769 keys = self._conf.getPendingQueuesMgr().getPendingConfManagersKeys(True)
6771 url = urlHandlers.UHConfModifPendingQueuesActionConfMgr.getURL(self._conf)
6772 url.addParam("tab","conf_managers")
6773 title = _("Pending chairpersons to become managers")
6774 target = _("Conference")
6775 pType = "ConfManagers"
6777 for key in keys:
6778 list.append((key, self._pendingConfManagers[key][:]))
6780 elif self._tabSubmitters.isActive():
6781 # Pending submitters
6782 keys = self._conf.getPendingQueuesMgr().getPendingSubmittersKeys(True)
6784 url = urlHandlers.UHConfModifPendingQueuesActionSubm.getURL(self._conf)
6785 url.addParam("tab", "submitters")
6786 title = _("Pending authors/speakers to become submitters")
6787 target = _("Contribution")
6788 pType = "Submitters"
6790 for key in keys:
6791 list.append((key, self._pendingSubmitters[key][:]))
6793 elif self._tabManagers.isActive():
6794 # Pending managers
6795 keys = self._conf.getPendingQueuesMgr().getPendingManagersKeys(True)
6797 url = urlHandlers.UHConfModifPendingQueuesActionMgr.getURL(self._conf)
6798 url.addParam("tab", "managers")
6799 title = _("Pending conveners to become managers")
6800 target = _("Session")
6801 pType = "Managers"
6803 for key in keys:
6804 list.append((key, self._pendingManagers[key][:]))
6805 #list.sort(conference.SessionChair._cmpFamilyName)
6807 elif self._tabCoordinators.isActive():
6808 # Pending coordinators
6809 keys = self._conf.getPendingQueuesMgr().getPendingCoordinatorsKeys(True)
6811 url = urlHandlers.UHConfModifPendingQueuesActionCoord.getURL(self._conf)
6812 url.addParam("tab", "coordinators")
6813 title = _("Pending conveners to become coordinators")
6814 target = _("Session")
6815 pType = "Coordinators"
6817 for key in keys:
6818 list.append((key, self._pendingCoordinators[key][:]))
6819 list.sort(conference.ConferenceParticipation._cmpFamilyName)
6821 html = WConfModifPendingQueuesList(str(url), title, target, list, pType).getHTML()
6822 vars["pendingQueue"] = wcomponents.WTabControl(self._tabCtrl, self._aw).getHTML(html)
6824 return vars
6827 class WPConfModifPendingQueuesBase(WPConfModifListings):
6829 def __init__(self, rh, conf, activeTab=""):
6830 WPConfModifListings.__init__(self, rh, conf)
6831 self._activeTab = activeTab
6833 def _setActiveSideMenuItem(self):
6834 self._listingsMenuItem.setActive(True)
6837 class WPConfModifPendingQueues(WPConfModifPendingQueuesBase):
6839 def _getTabContent(self, params):
6840 wc = WConfModifPendingQueues(self._conf, self._getAW(), self._activeTab)
6841 return wc.getHTML()
6844 class WPConfModifPendingQueuesRemoveConfMgrConfirm(WPConfModifPendingQueuesBase):
6846 def __init__(self, rh, conf, pendingConfMgrs):
6847 WPConfModifPendingQueuesBase.__init__(self, rh, conf)
6848 self._pendingConfMgrs = pendingConfMgrs
6850 def _getTabContent(self,params):
6851 wc = wcomponents.WConfirmation()
6852 psubs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingConfMgrs))
6854 msg = {'challenge': _("Are you sure you want to delete the following users pending to become conference managers?"),
6855 'target': "<ul>{0}</ul>".format(psubs),
6856 'subtext': _("Please note that they will still remain as user"),
6859 url = urlHandlers.UHConfModifPendingQueuesActionConfMgr.getURL(self._conf)
6860 return wc.getHTML(msg,url,{"pendingUsers":self._pendingConfMgrs, "remove": _("remove")})
6863 class WPConfModifPendingQueuesReminderConfMgrConfirm(WPConfModifPendingQueuesBase):
6865 def __init__(self, rh, conf, pendingConfMgrs):
6866 WPConfModifPendingQueuesBase.__init__(self, rh, conf)
6867 self._pendingConfMgrs = pendingConfMgrs
6869 def _getTabContent(self,params):
6870 wc = wcomponents.WConfirmation()
6871 psubs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingConfMgrs))
6873 msg = {'challenge': _("Are you sure that you want to send these users an email with a reminder to create an account in Indico?"),
6874 'target': "<ul>{0}</ul>".format(psubs)
6876 url = urlHandlers.UHConfModifPendingQueuesActionConfMgr.getURL(self._conf)
6877 return wc.getHTML(
6878 msg,
6879 url, {
6880 "pendingUsers": self._pendingConfMgrs,
6881 "reminder": _("reminder")
6883 severity='accept')
6886 class WPConfModifPendingQueuesRemoveConfSubmConfirm(WPConfModifPendingQueuesBase):
6888 def __init__(self, rh, conf, pendingConfSubms):
6889 WPConfModifPendingQueuesBase.__init__(self, rh, conf)
6890 self._pendingConfSubms = pendingConfSubms
6892 def _getTabContent(self,params):
6893 wc = wcomponents.WConfirmation()
6894 psubs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingConfSubms))
6896 msg = {'challenge': _("Are you sure you want to delete the following users pending to become submitters?"),
6897 'target': "<ul>{0}</ul>".format(psubs),
6898 'subtext': _("Please note that they will still remain as user"),
6901 url = urlHandlers.UHConfModifPendingQueuesActionConfSubm.getURL(self._conf)
6902 return wc.getHTML(msg,url,{"pendingUsers":self._pendingConfSubms, "remove": _("remove")})
6904 class WPConfModifPendingQueuesReminderConfSubmConfirm(WPConfModifPendingQueuesBase):
6906 def __init__(self, rh, conf, pendingConfSubms):
6907 WPConfModifPendingQueuesBase.__init__(self, rh, conf)
6908 self._pendingConfSubms = pendingConfSubms
6910 def _getTabContent(self,params):
6911 wc = wcomponents.WConfirmation()
6912 psubs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingConfSubms))
6914 msg = {'challenge': _("Are you sure that you want to send these users an email with a reminder to create an account in Indico?"),
6915 'target': "<ul>{0}</ul>".format(psubs)
6917 url = urlHandlers.UHConfModifPendingQueuesActionConfSubm.getURL(self._conf)
6918 return wc.getHTML(
6919 msg,
6920 url, {
6921 "pendingUsers": self._pendingConfSubms,
6922 "reminder": _("reminder")
6924 severity='accept')
6926 class WPConfModifPendingQueuesRemoveSubmConfirm(WPConfModifPendingQueuesBase):
6928 def __init__(self, rh, conf, pendingSubms):
6929 WPConfModifPendingQueuesBase.__init__(self, rh, conf)
6930 self._pendingSubms = pendingSubms
6932 def _getTabContent(self, params):
6933 wc = wcomponents.WConfirmation()
6934 psubs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingSubms))
6936 msg = {'challenge': _("Are you sure you want to delete the following participants pending to become submitters?"),
6937 'target': "<ul>{0}</ul>".format(psubs),
6938 'subtext': _("Please note that they will still remain as participants"),
6941 url = urlHandlers.UHConfModifPendingQueuesActionSubm.getURL(self._conf)
6942 return wc.getHTML(msg, url, {"pendingUsers": self._pendingSubms, "remove": _("remove")})
6945 class WPConfModifPendingQueuesReminderSubmConfirm( WPConfModifPendingQueuesBase ):
6947 def __init__(self,rh, conf, pendingSubms):
6948 WPConfModifPendingQueuesBase.__init__(self,rh,conf)
6949 self._pendingSubms = pendingSubms
6951 def _getTabContent(self,params):
6952 wc = wcomponents.WConfirmation()
6954 psubs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingSubms))
6956 msg = {'challenge': _("Are you sure that you want to send these users an email with a reminder to create an account in Indico?"),
6957 'target': "<ul>{0}</ul>".format(psubs)
6960 url = urlHandlers.UHConfModifPendingQueuesActionSubm.getURL(self._conf)
6961 return wc.getHTML(
6962 msg,
6963 url, {
6964 "pendingUsers": self._pendingSubms,
6965 "reminder": _("reminder")
6967 severity='accept')
6969 class WPConfModifPendingQueuesRemoveMgrConfirm( WPConfModifPendingQueuesBase ):
6971 def __init__(self,rh, conf, pendingMgrs):
6972 WPConfModifPendingQueuesBase.__init__(self,rh,conf)
6973 self._pendingMgrs = pendingMgrs
6975 def _getTabContent(self,params):
6976 wc = wcomponents.WConfirmation()
6978 pmgrs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingMgrs))
6980 msg = {'challenge': _("Are you sure you want to delete the following conveners pending to become managers?"),
6981 'target': "<ul>{0}</ul>".format(pmgrs),
6982 'subtext': _("Please note that they will still remain as conveners")
6985 url = urlHandlers.UHConfModifPendingQueuesActionMgr.getURL(self._conf)
6986 return wc.getHTML(msg,url,{"pendingUsers":self._pendingMgrs, "remove": _("remove")})
6988 class WPConfModifPendingQueuesReminderMgrConfirm( WPConfModifPendingQueuesBase ):
6990 def __init__(self,rh, conf, pendingMgrs):
6991 WPConfModifPendingQueuesBase.__init__(self,rh,conf)
6992 self._pendingMgrs = pendingMgrs
6994 def _getTabContent(self,params):
6995 wc = wcomponents.WConfirmation()
6997 pmgrs = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingMgrs))
6999 msg = {'challenge': _("Are you sure that you want to send these users an email with a reminder to create an account in Indico?"),
7000 'target': "<ul>{0}</ul>".format(pmgrs)
7003 url = urlHandlers.UHConfModifPendingQueuesActionMgr.getURL(self._conf)
7004 return wc.getHTML(msg,url,{"pendingUsers":self._pendingMgrs, "reminder": _("reminder")})
7006 class WPConfModifPendingQueuesRemoveCoordConfirm( WPConfModifPendingQueuesBase ):
7008 def __init__(self,rh, conf, pendingCoords):
7009 WPConfModifPendingQueuesBase.__init__(self,rh,conf)
7010 self._pendingCoords = pendingCoords
7012 def _getTabContent(self,params):
7013 wc = wcomponents.WConfirmation()
7015 pcoords = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingMgrs))
7017 msg = {'challenge': _("Are you sure you want to delete the following conveners pending to become coordinators?"),
7018 'target': "<ul>{0}</ul>".format(pcoords),
7019 'subtext': _("Please note that they will still remain as conveners")
7022 url = urlHandlers.UHConfModifPendingQueuesActionCoord.getURL(self._conf)
7023 return wc.getHTML(msg, url,{
7024 "pendingUsers": self._pendingCoords,
7025 "remove": _("remove")
7028 class WPConfModifPendingQueuesReminderCoordConfirm( WPConfModifPendingQueuesBase ):
7030 def __init__(self,rh, conf, pendingCoords):
7031 WPConfModifPendingQueuesBase.__init__(self,rh,conf)
7032 self._pendingCoords = pendingCoords
7034 def _getTabContent(self,params):
7035 wc = wcomponents.WConfirmation()
7037 pcoords = ''.join(list("<li>{0}</li>".format(s) for s in self._pendingMgrs))
7039 msg = {'challenge': _("Are you sure that you want to send these users an email with a reminder to create an account in Indico?"),
7040 'target': "<ul>{0}</ul>".format(pcoords)
7043 url = urlHandlers.UHConfModifPendingQueuesActionCoord.getURL(self._conf)
7044 return wc.getHTML(
7045 msg, url, {
7046 "pendingUsers": self._pendingCoords,
7047 "reminder": _("reminder")
7050 class WAbstractBookCustomise(wcomponents.WTemplated):
7052 def __init__(self, conf):
7053 self._conf = conf
7055 def getVars( self ):
7056 vars = wcomponents.WTemplated.getVars( self )
7057 url=urlHandlers.UHConfAbstractBookPerform.getURL(self._conf)
7058 vars["getPDFURL"]=quoteattr(str(url))
7059 return vars
7061 class WPAbstractBookCustomise( WPConferenceDefaultDisplayBase ):
7062 navigationEntry = navigation.NEAbstractBookCustomise
7064 def _getBody( self, params ):
7065 wc = WAbstractBookCustomise( self._conf )
7066 return wc.getHTML(params)
7068 def _defineSectionMenu( self ):
7069 WPConferenceDefaultDisplayBase._defineSectionMenu( self )
7070 self._sectionMenu.setCurrentItem(self._abstractsBookOpt)
7073 class WConfModifReschedule(wcomponents.WTemplated):
7075 def __init__(self, targetDay):
7076 self._targetDay = targetDay
7078 def getVars(self):
7079 vars = wcomponents.WTemplated.getVars(self)
7080 vars["targetDay"]=quoteattr(str(self._targetDay))
7081 return vars
7083 class WPConfModifReschedule(WPConferenceModifBase):
7085 def __init__(self, rh, conf, targetDay):
7086 WPConferenceModifBase.__init__(self, rh, conf)
7087 self._targetDay=targetDay
7089 def _getPageContent( self, params):
7090 wc=WConfModifReschedule(self._targetDay)
7091 p={"postURL":quoteattr(str(urlHandlers.UHConfModifReschedule.getURL(self._conf)))}
7092 return wc.getHTML(p)
7094 class WPConfModifRelocate(WPConferenceModifBase):
7096 def __init__(self, rh, conf, entry, targetDay):
7097 WPConferenceModifBase.__init__(self, rh, conf)
7098 self._targetDay=targetDay
7099 self._entry=entry
7101 def _getPageContent( self, params):
7102 wc=wcomponents.WSchRelocate(self._entry)
7103 p={"postURL":quoteattr(str(urlHandlers.UHConfModifScheduleRelocate.getURL(self._entry))), \
7104 "targetDay":quoteattr(str(self._targetDay))}
7105 return wc.getHTML(p)
7108 # ============================================================================
7109 # === Badges related =========================================================
7110 # ============================================================================
7112 ##------------------------------------------------------------------------------------------------------------
7114 Badge Printing classes
7116 class WConfModifBadgePrinting(wcomponents.WTemplated):
7117 """ This class corresponds to the screen where badge templates are
7118 listed and can be created, edited, deleted, and tried.
7121 def __init__(self, conference, user=None):
7122 self.__conf = conference
7123 self._user = user
7125 def _getBaseTemplateOptions(self):
7126 dconf = conference.CategoryManager().getDefaultConference()
7127 templates = dconf.getBadgeTemplateManager().getTemplates()
7129 options = [{'value': 'blank', 'label': _('Blank Page')}]
7131 for id, template in templates.iteritems():
7132 options.append({'value': id, 'label': template.getName()})
7134 return options
7136 def getVars(self):
7137 uh = urlHandlers
7138 templates = []
7139 sortedTemplates = self.__conf.getBadgeTemplateManager().getTemplates().items()
7140 sortedTemplates.sort(lambda x, y: cmp(x[1].getName(), y[1].getName()))
7142 for templateId, template in sortedTemplates:
7144 data = {
7145 'id': templateId,
7146 'name': template.getName(),
7147 'urlEdit': str(uh.UHConfModifBadgeDesign.getURL(self.__conf, templateId)),
7148 'urlDelete': str(uh.UHConfModifBadgePrinting.getURL(self.__conf, deleteTemplateId=templateId)),
7149 'urlCopy': str(uh.UHConfModifBadgePrinting.getURL(self.__conf, copyTemplateId=templateId))
7152 templates.append(data)
7154 wcPDFOptions = WConfModifBadgePDFOptions(self.__conf)
7155 vars = wcomponents.WTemplated.getVars(self)
7156 vars['NewTemplateURL'] = str(uh.UHConfModifBadgeDesign.getURL(self.__conf,
7157 self.__conf.getBadgeTemplateManager().getNewTemplateId(),new = True))
7158 vars['CreatePDFURL'] = str(uh.UHConfModifBadgePrintingPDF.getURL(self.__conf))
7159 vars['templateList'] = templates
7160 vars['PDFOptions'] = wcPDFOptions.getHTML()
7161 vars['baseTemplates'] = self._getBaseTemplateOptions()
7163 return vars
7166 class WConfModifBadgePDFOptions(wcomponents.WTemplated):
7168 def __init__(self, conference, showKeepValues=True, showTip=True):
7169 self.__conf = conference
7170 self.__showKeepValues = showKeepValues
7171 self.__showTip = showTip
7173 def getVars(self):
7174 vars = wcomponents.WTemplated.getVars(self)
7176 pagesizeNames = PDFSizes().PDFpagesizes.keys()
7177 pagesizeNames.sort()
7178 vars['PagesizeNames'] = pagesizeNames
7179 vars['PDFOptions'] = self.__conf.getBadgeTemplateManager().getPDFOptions()
7180 vars['ShowKeepValues'] = self.__showKeepValues
7181 vars['ShowTip'] = self.__showTip
7183 return vars
7186 class WPBadgeBase(WPConfModifToolsBase):
7188 def getCSSFiles(self):
7189 return WPConfModifToolsBase.getCSSFiles(self) + self._asset_env['indico_badges_css'].urls()
7191 def getJSFiles(self):
7192 return WPConfModifToolsBase.getJSFiles(self) + self._includeJSPackage('badges_js')
7195 class WPConfModifBadgePrinting(WPBadgeBase):
7197 def _setActiveTab(self):
7198 self._tabBadges.setActive()
7200 def _getTabContent(self, params):
7201 wc = WConfModifBadgePrinting(self._conf)
7202 return wc.getHTML()
7206 ##------------------------------------------------------------------------------------------------------------
7208 Badge Design classes
7210 class WConfModifBadgeDesign(wcomponents.WTemplated):
7211 """ This class corresponds to the screen where a template
7212 is designed inserting, dragging and editing items.
7215 def __init__(self, conference, templateId, new=False, user=None):
7216 self.__conf = conference
7217 self.__templateId = templateId
7218 self.__new = new
7219 self._user = user
7221 def getVars( self ):
7222 vars = wcomponents.WTemplated.getVars( self )
7223 vars["baseURL"] = Config.getInstance().getBaseURL() ##base url of the application, used for the ruler images
7224 vars["cancelURL"] = urlHandlers.UHConfModifBadgePrinting.getURL(self.__conf, templateId = self.__templateId, cancel = True)
7225 vars["saveBackgroundURL"] = urlHandlers.UHConfModifBadgeSaveBackground.getURL(self.__conf, self.__templateId)
7226 vars["loadingIconURL"] = quoteattr(str(Config.getInstance().getSystemIconURL("loading")))
7227 vars["templateId"] = self.__templateId
7229 badgeDesignConfiguration = BadgeDesignConfiguration()
7230 from MaKaC.services.interface.rpc.json import encode as jsonEncode
7231 vars["translateName"]= jsonEncode(dict([(key, value[0]) for key, value in badgeDesignConfiguration.items_actions.iteritems()]))
7233 cases = []
7234 for itemKey in badgeDesignConfiguration.items_actions.keys():
7235 case = []
7236 case.append('case "')
7237 case.append(itemKey)
7238 case.append('":')
7239 case.append('\n')
7240 case.append('items[itemId] = new Item(itemId, "')
7241 case.append(itemKey)
7242 case.append('");')
7243 case.append('\n')
7244 case.append('newDiv.html(items[itemId].toHTML());')
7245 case.append('\n')
7246 case.append('break;')
7247 cases.append("".join(case))
7249 vars['switchCases'] = "\n".join(cases)
7251 optgroups = []
7252 for optgroupName, options in badgeDesignConfiguration.groups:
7253 optgroup = []
7254 optgroup.append('<optgroup label="')
7255 optgroup.append(optgroupName)
7256 optgroup.append('">')
7257 optgroup.append('\n')
7258 for optionName in options:
7259 optgroup.append('<option value="%s">'%optionName)
7260 optgroup.append(badgeDesignConfiguration.items_actions[optionName][0])
7261 optgroup.append('</option>')
7262 optgroup.append('\n')
7263 optgroup.append('</optgroup>')
7264 optgroups.append("".join(optgroup))
7266 vars['selectOptions'] = "\n".join(optgroups)
7267 vars["backgroundPos"] = "Stretch"
7269 if self.__new:
7270 vars["saveTemplateURL"]=urlHandlers.UHConfModifBadgePrinting.getURL(self.__conf, new=True)
7271 vars["titleMessage"]= _("Creating new badge template")
7272 vars["editingTemplate"]="false"
7273 vars["templateData"]="[]"
7274 vars["hasBackground"]="false"
7275 vars["backgroundURL"]="false"
7276 vars["backgroundId"]=-1
7278 elif self.__templateId is None:
7279 vars["saveTemplateURL"]=urlHandlers.UHConfModifBadgePrinting.getURL(self.__conf)
7280 vars["titleMessage"]= _("No template id given")
7281 vars["editingTemplate"]="false"
7282 vars["templateData"]="[]"
7283 vars["hasBackground"]="false"
7284 vars["backgroundURL"]="false"
7285 vars["backgroundId"]=-1
7287 else:
7288 vars["saveTemplateURL"]=urlHandlers.UHConfModifBadgePrinting.getURL(self.__conf)
7289 vars["titleMessage"]= _("Editing badge template")
7290 vars["editingTemplate"]="true"
7292 templateDataString = jsonEncode(self.__conf.getBadgeTemplateManager().getTemplateData(self.__templateId))
7293 vars["templateData"]= templateDataString
7295 usedBackgroundId = self.__conf.getBadgeTemplateManager().getTemplateById(self.__templateId).getUsedBackgroundId()
7296 vars["backgroundId"] = usedBackgroundId
7297 if usedBackgroundId != -1:
7298 vars["hasBackground"]="true"
7299 vars["backgroundURL"]=str(urlHandlers.UHConfModifBadgeGetBackground.getURL(self.__conf, self.__templateId, usedBackgroundId))
7300 else:
7301 vars["hasBackground"]="false"
7302 vars["backgroundURL"]="false"
7305 return vars
7308 class WPConfModifBadgeDesign(WPBadgeBase):
7310 def __init__(self, rh, conf, templateId=None, new=False, baseTemplateId="blank"):
7311 WPBadgeBase.__init__(self, rh, conf)
7312 self.__templateId = templateId
7313 self.__new = new
7314 self.__baseTemplate = baseTemplateId
7316 if baseTemplateId != 'blank':
7317 dconf = conference.CategoryManager().getDefaultConference()
7318 templMan = conf.getBadgeTemplateManager()
7319 newId = templateId
7320 dconf.getBadgeTemplateManager().getTemplateById(baseTemplateId).clone(templMan, newId)
7321 # now, let's pretend nothing happened, and let the code
7322 # handle the template as if it existed before
7323 self.__new = False
7325 def _setActiveTab(self):
7326 self._tabBadges.setActive()
7328 def _getTabContent(self, params):
7329 wc = WConfModifBadgeDesign(self._conf, self.__templateId, self.__new)
7330 return wc.getHTML()
7332 ##------------------------------------------------------------------------------------------------------------
7334 Common PDF Options classes
7336 class WConfCommonPDFOptions( wcomponents.WTemplated ):
7337 """ This class corresponds to a section of options
7338 that are common to each PDF in Indico.
7341 def __init__( self, conference, user=None ):
7342 self.__conf = conference
7343 self._user=user
7345 def getVars(self):
7346 vars = wcomponents.WTemplated.getVars( self )
7348 pagesizeNames = PDFSizes().PDFpagesizes.keys()
7349 pagesizeNames.sort()
7350 pagesizeOptions = []
7351 for pagesizeName in pagesizeNames:
7352 pagesizeOptions.append('<option ')
7353 if pagesizeName == 'A4':
7354 pagesizeOptions.append('selected="selected"')
7355 pagesizeOptions.append('>')
7356 pagesizeOptions.append(pagesizeName)
7357 pagesizeOptions.append('</option>')
7359 vars['pagesizes'] = "".join(pagesizeOptions)
7361 fontsizeOptions = []
7362 for fontsizeName in PDFSizes().PDFfontsizes:
7363 fontsizeOptions.append('<option ')
7364 if fontsizeName == 'normal':
7365 fontsizeOptions.append('selected="selected"')
7366 fontsizeOptions.append('>')
7367 fontsizeOptions.append(fontsizeName)
7368 fontsizeOptions.append('</option>')
7370 vars['fontsizes'] = "".join(fontsizeOptions)
7372 return vars
7375 # ============================================================================
7376 # === Posters related ========================================================
7377 # ============================================================================
7379 ##------------------------------------------------------------------------------------------------------------
7381 Poster Printing classes
7383 class WConfModifPosterPrinting(wcomponents.WTemplated):
7384 """ This class corresponds to the screen where poster templates are
7385 listed and can be created, edited, deleted, and tried.
7388 def __init__(self, conference, user=None):
7389 self.__conf = conference
7390 self._user = user
7392 def _getFullTemplateListOptions(self):
7393 templates = {}
7394 templates['global'] = conference.CategoryManager().getDefaultConference().getPosterTemplateManager().getTemplates()
7395 templates['local'] = self.__conf.getPosterTemplateManager().getTemplates()
7396 options = []
7398 def _iterTemplatesToObjectList(key, templates):
7399 newList = []
7401 for id, template in templates.iteritems():
7402 pKey = ' (' + key + ')'
7403 # Only if the template is 'global' should it have the word prefixed.
7404 value = key + str(id) if key == 'global' else str(id)
7405 newList.append({'value': value,
7406 'label': template.getName() + pKey})
7408 return newList
7410 for k, v in templates.iteritems():
7411 options.extend(_iterTemplatesToObjectList(k, v))
7413 return options
7415 def _getBaseTemplateListOptions(self):
7416 templates = conference.CategoryManager().getDefaultConference().getPosterTemplateManager().getTemplates()
7417 options = [{'value': 'blank', 'label': _('Blank Page')}]
7419 for id, template in templates.iteritems():
7420 options.append({'value': id, 'label': template.getName()})
7422 return options
7424 def getVars(self):
7425 uh = urlHandlers
7426 templates = []
7427 wcPDFOptions = WConfModifPosterPDFOptions(self.__conf)
7428 sortedTemplates = self.__conf.getPosterTemplateManager().getTemplates().items()
7429 sortedTemplates.sort(lambda item1, item2: cmp(item1[1].getName(), item2[1].getName()))
7431 for templateId, template in sortedTemplates:
7433 data = {
7434 'id': templateId,
7435 'name': template.getName(),
7436 'urlEdit': str(uh.UHConfModifPosterDesign.getURL(self.__conf, templateId)),
7437 'urlDelete': str(uh.UHConfModifPosterPrinting.getURL(self.__conf, deleteTemplateId=templateId)),
7438 'urlCopy': str(uh.UHConfModifPosterPrinting.getURL(self.__conf, copyTemplateId=templateId))
7441 templates.append(data)
7443 vars = wcomponents.WTemplated.getVars(self)
7444 vars["NewTemplateURL"] = str(uh.UHConfModifPosterDesign.getURL(self.__conf, self.__conf.getPosterTemplateManager().getNewTemplateId(),new=True))
7445 vars["CreatePDFURL"]= str(uh.UHConfModifPosterPrintingPDF.getURL(self.__conf))
7446 vars["templateList"] = templates
7447 vars['PDFOptions'] = wcPDFOptions.getHTML()
7448 vars['baseTemplates'] = self._getBaseTemplateListOptions()
7449 vars['fullTemplateList'] = self._getFullTemplateListOptions()
7451 return vars
7453 class WConfModifPosterPDFOptions(wcomponents.WTemplated):
7455 def __init__(self, conference, user=None):
7456 self.__conf = conference
7457 self._user= user
7459 def getVars(self):
7460 vars = wcomponents.WTemplated.getVars(self)
7462 pagesizeNames = PDFSizes().PDFpagesizes.keys()
7463 pagesizeNames.sort()
7464 pagesizeOptions = []
7466 for pagesizeName in pagesizeNames:
7467 pagesizeOptions.append('<option ')
7469 if pagesizeName == 'A4':
7470 pagesizeOptions.append('selected="selected"')
7472 pagesizeOptions.append('>')
7473 pagesizeOptions.append(pagesizeName)
7474 pagesizeOptions.append('</option>')
7476 vars['pagesizes'] = "".join(pagesizeOptions)
7478 return vars
7480 class WPConfModifPosterPrinting(WPBadgeBase):
7482 def _setActiveTab(self):
7483 self._tabPosters.setActive()
7485 def _getTabContent(self, params):
7486 wc = WConfModifPosterPrinting(self._conf)
7487 return wc.getHTML()
7489 ##------------------------------------------------------------------------------------------------------------
7491 Poster Design classes
7493 class WConfModifPosterDesign( wcomponents.WTemplated ):
7494 """ This class corresponds to the screen where a template
7495 is designed inserting, dragging and editing items.
7498 def __init__(self, conference, templateId, new=False, user=None):
7499 self.__conf = conference
7500 self.__templateId = templateId
7501 self.__new = new
7502 self._user = user
7505 def getVars(self):
7506 vars = wcomponents.WTemplated.getVars( self )
7507 vars["baseURL"] = Config.getInstance().getBaseURL() # base url of the application, used for the ruler images
7508 vars["cancelURL"] = urlHandlers.UHConfModifPosterPrinting.getURL(self.__conf, templateId = self.__templateId, cancel = True)
7509 vars["saveBackgroundURL"] = urlHandlers.UHConfModifPosterSaveBackground.getURL(self.__conf, self.__templateId)
7510 vars["loadingIconURL"] = quoteattr(str(Config.getInstance().getSystemIconURL("loading")))
7511 vars["templateId"] = self.__templateId
7513 posterDesignConfiguration = PosterDesignConfiguration()
7514 from MaKaC.services.interface.rpc.json import encode as jsonEncode
7515 vars["translateName"]= jsonEncode(dict([(key, value[0]) for key, value in posterDesignConfiguration.items_actions.iteritems()]))
7517 cases = []
7518 for itemKey in posterDesignConfiguration.items_actions.keys():
7519 case = []
7520 case.append('case "')
7521 case.append(itemKey)
7522 case.append('":')
7523 case.append('\n')
7524 case.append('items[itemId] = new Item(itemId, "')
7525 case.append(itemKey)
7526 case.append('");')
7527 case.append('\n')
7528 case.append('newDiv.html(items[itemId].toHTML());')
7529 case.append('\n')
7530 case.append('break;')
7531 cases.append("".join(case))
7533 vars['switchCases'] = "\n".join(cases)
7535 optgroups = []
7536 for optgroupName, options in posterDesignConfiguration.groups:
7537 optgroup = []
7538 optgroup.append('<optgroup label="')
7539 optgroup.append(optgroupName)
7540 optgroup.append('">')
7541 optgroup.append('\n')
7542 for optionName in options:
7543 optgroup.append('<option value="%s">'%optionName)
7544 optgroup.append(posterDesignConfiguration.items_actions[optionName][0])
7545 optgroup.append('</option>')
7546 optgroup.append('\n')
7547 optgroup.append('</optgroup>')
7548 optgroups.append("".join(optgroup))
7550 vars['selectOptions'] = "\n".join(optgroups)
7552 if self.__new:
7553 vars["saveTemplateURL"]=urlHandlers.UHConfModifPosterPrinting.getURL(self.__conf, new=True)
7554 vars["titleMessage"]= _("Creating new poster template")
7555 vars["hasBackground"]="false"
7556 vars["backgroundURL"]="false"
7557 vars["backgroundId"]=-1
7558 vars["backgroundPos"]="Stretch"
7559 vars["templateData"]="[]"
7560 vars["editingTemplate"]="false"
7563 elif self.__templateId is None:
7564 vars["saveTemplateURL"]=urlHandlers.UHConfModifPosterPrinting.getURL(self.__conf)
7565 vars["titleMessage"]= _("No template id given")
7566 vars["hasBackground"]="false"
7567 vars["backgroundURL"]="false"
7568 vars["backgroundId"]=-1
7569 vars["backgroundPos"]="Stretch"
7570 vars["templateData"] = "[]"
7571 vars["editingTemplate"]="false"
7574 else:
7575 vars["saveTemplateURL"]=urlHandlers.UHConfModifPosterPrinting.getURL(self.__conf)
7576 vars["titleMessage"]= _("Editing poster template")
7577 vars["editingTemplate"]="true"
7578 templateDataString = jsonEncode(self.__conf.getPosterTemplateManager().getTemplateData(self.__templateId))
7579 vars["templateData"]= templateDataString
7581 usedBackgroundId = self.__conf.getPosterTemplateManager().getTemplateById(self.__templateId).getUsedBackgroundId()
7582 vars["backgroundId"] = usedBackgroundId
7584 if usedBackgroundId != -1:
7585 vars["hasBackground"]="true"
7586 vars["backgroundURL"]=str(urlHandlers.UHConfModifPosterGetBackground.getURL(self.__conf, self.__templateId, usedBackgroundId))
7587 vars["backgroundPos"]=self.__conf.getPosterTemplateManager().getTemplateById(self.__templateId).getBackgroundPosition(usedBackgroundId)
7588 else:
7589 vars["hasBackground"]="false"
7590 vars["backgroundURL"]="false"
7591 vars["backgroundPos"]="Stretch"
7593 return vars
7596 class WPConfModifPosterDesign(WPBadgeBase):
7598 def __init__(self, rh, conf, templateId=None, new=False, baseTemplateId="blank"):
7599 WPBadgeBase.__init__(self, rh, conf)
7600 self.__templateId = templateId
7601 self.__new = new
7602 self.__baseTemplate = baseTemplateId
7604 def _setActiveTab(self):
7605 self._tabPosters.setActive()
7607 def _getTabContent(self, params):
7608 wc = WConfModifPosterDesign(self._conf, self.__templateId, self.__new)
7609 return wc.getHTML()
7611 def sortByName(x,y):
7612 return cmp(x.getFamilyName(),y.getFamilyName())
7614 class WPConfModifPreviewCSS( WPConferenceDefaultDisplayBase ):
7616 def __init__( self, rh, conf, selectedCSSId):
7617 WPConferenceDefaultDisplayBase.__init__( self, rh, conf )
7619 self._conf = conf
7620 self._cssTplsModule = ModuleHolder().getById("cssTpls")
7621 self._styleMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getStyleManager()
7623 self._selectedCSS = None
7624 if selectedCSSId == "css": # local uploaded file choice
7625 self._selectedCSS = self._styleMgr.getLocalCSS()
7626 elif selectedCSSId:
7627 self._selectedCSS = self._cssTplsModule.getCssTplById(selectedCSSId)
7629 def _applyDecoration( self, body ):
7632 return "%s%s%s"%( self._getHeader(), body, self._getFooter() )
7634 def _getBody( self, params ):
7635 params["URL2Back"] = urlHandlers.UHConfModifDisplay.getURL(self._conf)
7636 params["cssurl"] = ""
7637 params['selectedCSSId'] = ""
7638 if self._selectedCSS:
7639 params["cssurl"] = self._selectedCSS.getURL()
7640 params['selectedCSSId'] = self._selectedCSS.getId()
7641 elif self._styleMgr.getCSS():
7642 params["cssurl"] = self._styleMgr.getCSS().getURL()
7643 params['selectedCSSId'] = self._styleMgr.getCSS().getId()
7644 params["saveCSS"]=urlHandlers.UHUseCSS.getURL(self._conf)
7645 params['confId'] = self._conf.getId()
7646 params["previewURL"]= urlHandlers.UHConfModifPreviewCSS.getURL(self._conf)
7647 params["templatesList"]=[]
7648 if self._styleMgr.getLocalCSS():
7649 params["templatesList"].append(self._styleMgr.getLocalCSS())
7650 params["templatesList"].extend(self._cssTplsModule.getCssTplsList())
7652 ###############################
7653 # injecting ConferenceDisplay #
7654 ###############################
7655 p = WPConferenceDisplay( self._rh, self._conf )
7656 p._defineSectionMenu()
7657 p._toolBar=wcomponents.WebToolBar()
7658 p._defineToolBar()
7659 params["bodyConf"] = p._applyConfDisplayDecoration( p._getBody( params ) )
7660 ###############################
7661 ###############################
7663 wc = WPreviewPage()
7664 return wc.getHTML(params)
7666 def _getHeadContent( self ):
7667 path = Config.getInstance().getCssBaseURL()
7668 timestamp = os.stat(__file__).st_mtime
7669 printCSS = """
7670 <link rel="stylesheet" type="text/css" href="%s/Conf_Basic.css?%d" >
7671 """ % (path, timestamp)
7673 if self._selectedCSS:
7674 printCSS = printCSS + """<link rel="stylesheet" type="text/css" href="%s" >"""%self._selectedCSS.getURL()
7675 elif self._styleMgr.getCSS():
7676 printCSS = printCSS + """<link rel="stylesheet" type="text/css" href="%s" >"""%self._styleMgr.getCSS().getURL()
7677 return printCSS
7680 class WPreviewPage( wcomponents.WTemplated ):
7681 pass