Remove the old scheduler
[cds-indico.git] / indico / MaKaC / webinterface / rh / conferenceModif.py
blob74b86872820445d009a3e29f050a4d43cc970c1d
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 os
18 from cStringIO import StringIO
19 import tempfile
20 import types
21 from flask import session, request
22 from persistent.list import PersistentList
23 from datetime import datetime,timedelta
24 from dateutil.relativedelta import relativedelta
25 from pytz import timezone
26 import MaKaC.common.timezoneUtils as timezoneUtils
27 from BTrees.OOBTree import OOBTree
28 from MaKaC.webinterface.common.abstractDataWrapper import AbstractParam
29 import MaKaC.review as review
30 import MaKaC.webinterface.urlHandlers as urlHandlers
31 import MaKaC.webinterface.materialFactories as materialFactories
32 import MaKaC.webinterface.displayMgr as displayMgr
33 import MaKaC.webinterface.internalPagesMgr as internalPagesMgr
34 import MaKaC.webinterface.pages.conferences as conferences
35 import MaKaC.webinterface.pages.sessions as sessions
36 import MaKaC.conference as conference
37 from MaKaC.webinterface.general import normaliseListParam
38 from MaKaC.webinterface.rh.base import RHModificationBaseProtected
39 from MaKaC.webinterface.pages import admins
40 from MaKaC.webinterface.rh.conferenceBase import RHConferenceBase, RHSubmitMaterialBase
41 from MaKaC.webinterface.rh.categoryDisplay import UtilsConference
42 from indico.core import signals
43 from indico.core.config import Config
44 from MaKaC.errors import MaKaCError, FormValuesError,ModificationError,\
45 ConferenceClosedError, NoReportError, NotFoundError
46 from MaKaC.PDFinterface.conference import ConfManagerAbstractsToPDF, ContribsToPDF, RegistrantsListToBadgesPDF, LectureToPosterPDF
47 from MaKaC.webinterface.common import AbstractStatusList, abstractFilters
48 from MaKaC.webinterface import locators
49 from MaKaC.common.xmlGen import XMLGen
50 from MaKaC.webinterface.common.abstractNotificator import EmailNotificator
51 import MaKaC.webinterface.common.registrantNotificator as registrantNotificator
52 import MaKaC.common.filters as filters
53 import MaKaC.webinterface.common.contribFilters as contribFilters
54 from MaKaC.webinterface.common.contribStatusWrapper import ContribStatusList
55 from MaKaC.common.contribPacker import ZIPFileHandler,AbstractPacker, ContribPacker,ConferencePacker, ProceedingsPacker
56 from MaKaC.common import pendingQueues
57 from MaKaC.export.excel import AbstractListToExcel, ParticipantsListToExcel, ContributionsListToExcel
58 from MaKaC.common import utils
59 from MaKaC.i18n import _
60 from indico.modules.events.requests.util import is_request_manager
61 from indico.util.i18n import i18nformat, set_best_lang
62 from indico.util.signals import values_from_signal
63 from MaKaC.common.timezoneUtils import nowutc
64 from MaKaC.review import AbstractStatusSubmitted, AbstractStatusProposedToAccept, AbstractStatusProposedToReject
65 import MaKaC.webinterface.pages.abstracts as abstracts
66 from MaKaC.fossils.conference import ISessionBasicFossil
68 from indico.util import json
69 from indico.web.http_api.metadata.serializer import Serializer
70 from indico.web.flask.util import send_file, url_for
73 class RHConferenceModifBase(RHConferenceBase, RHModificationBaseProtected):
75 def _checkParams(self, params):
76 RHConferenceBase._checkParams(self, params)
78 def _checkProtection(self):
79 RHModificationBaseProtected._checkProtection(self)
81 def _displayCustomPage(self, wf):
82 return None
84 def _displayDefaultPage(self):
85 return None
87 def _process(self):
88 wf = self.getWebFactory()
89 if wf is not None:
90 res = self._displayCustomPage(wf)
91 if res is not None:
92 return res
93 return self._displayDefaultPage()
96 class RHConferenceModification(RHConferenceModifBase):
97 _uh = urlHandlers.UHConferenceModification
99 def _process( self ):
100 pars={}
101 wf=self.getWebFactory()
102 if wf is not None:
103 pars["type"]=wf.getId()
104 if self._conf.isClosed():
105 p = conferences.WPConferenceModificationClosed( self, self._target )
106 return p.display(**pars)
107 else:
108 p = conferences.WPConferenceModification( self, self._target )
110 if wf is not None:
111 p = wf.getConfModif(self, self._conf)
112 return p.display(**pars)
115 class RHConfScreenDatesEdit(RHConferenceModifBase):
116 _uh = urlHandlers.UHConfScreenDatesEdit
118 def _checkParams(self,params):
119 RHConferenceModifBase._checkParams(self,params)
120 self._action=""
121 if params.has_key("CANCEL"):
122 self._action="CANCEL"
123 elif params.has_key("OK"):
124 self._action="EDIT"
125 self._sDate,self._eDate=None,None
126 tz = self._target.getTimezone()
127 if params.get("start_date","conference")=="own":
128 try:
129 self._sDate=timezone(tz).localize(datetime(int(params["sYear"]),
130 int(params["sMonth"]),
131 int(params["sDay"]),
132 int(params["sHour"]),
133 int(params["sMin"]))).astimezone(timezone('UTC'))
134 except ValueError:
135 raise MaKaCError( _("Please enter integers in all the start date fields"), _("Schedule"))
136 if params.get("end_date","conference")=="own":
137 try:
138 self._eDate=timezone(tz).localize(datetime(int(params["eYear"]),
139 int(params["eMonth"]),
140 int(params["eDay"]),
141 int(params["eHour"]),
142 int(params["eMin"]))).astimezone(timezone('UTC'))
143 except ValueError:
144 raise MaKaCError( _("Please enter integers in all the end date fields"), _("Schedule"))
146 def _process( self ):
147 url=urlHandlers.UHConferenceModification.getURL(self._target)
148 if self._action=="CANCEL":
149 self._redirect(url)
150 return
151 elif self._action=="EDIT":
152 self._target.setScreenStartDate(self._sDate)
153 self._target.setScreenEndDate(self._eDate)
154 self._redirect(url)
155 return
156 p = conferences.WPScreenDatesEdit(self, self._target)
157 return p.display()
160 class RHConferenceModifKey(RHConferenceModifBase):
162 def _checkParams(self, params):
163 RHConferenceBase._checkParams(self, params)
164 self._modifkey = params.get("modifKey", "").strip()
165 self._doNotSanitizeFields.append("modifKey")
166 self._redirectURL = params.get("redirectURL", "")
168 def _checkProtection(self):
169 modif_keys = session.setdefault('modifKeys', {})
170 modif_keys[self._conf.getId()] = self._modifkey
171 session.modified = True
173 RHConferenceModifBase._checkProtection(self)
175 def _process( self ):
176 if self._redirectURL != "":
177 url = self._redirectURL
178 else:
179 url = urlHandlers.UHConferenceDisplay.getURL( self._conf )
180 self._redirect( url )
182 class RHConferenceModifManagementAccess( RHConferenceModifKey ):
183 _uh = urlHandlers.UHConfManagementAccess
184 _tohttps = True
186 def _checkParams(self, params):
187 RHConferenceModifKey._checkParams(self, params)
188 from MaKaC.webinterface.rh.reviewingModif import RCPaperReviewManager, RCReferee
189 self._isRegistrar = self._target.isRegistrar( self._getUser() )
190 self._isPRM = RCPaperReviewManager.hasRights(self)
191 self._isReferee = RCReferee.hasRights(self)
192 self._requests_manager = is_request_manager(session.user)
193 self._plugin_urls = values_from_signal(signals.event_management.management_url.send(self._conf),
194 single_value=True)
196 def _checkProtection(self):
197 if not (self._isRegistrar or self._isPRM or self._isReferee or self._requests_manager or self._plugin_urls):
198 RHConferenceModifKey._checkProtection(self)
200 def _process(self):
201 url = None
202 if self._redirectURL != "":
203 url = self._redirectURL
205 elif self._conf.canModify(self.getAW()):
206 url = urlHandlers.UHConferenceModification.getURL( self._conf )
208 elif self._isRegistrar:
209 url = urlHandlers.UHConfModifRegForm.getURL( self._conf )
210 elif self._isPRM:
211 url = urlHandlers.UHConfModifReviewingPaperSetup.getURL( self._conf )
212 elif self._isReferee:
213 url = urlHandlers.UHConfModifReviewingAssignContributionsList.getURL( self._conf )
214 elif self._requests_manager:
215 url = url_for('requests.event_requests', self._conf)
216 elif self._plugin_urls:
217 url = next(iter(self._plugin_urls), None)
218 if not url:
219 url = urlHandlers.UHConfManagementAccess.getURL( self._conf )
221 self._redirect(url)
224 class RHConferenceCloseModifKey(RHConferenceBase):
226 def _checkParams(self, params):
227 RHConferenceBase._checkParams(self, params)
228 self._modifkey = params.get("modifKey", "").strip()
229 self._doNotSanitizeFields.append("modifKey")
230 self._redirectURL = params.get("redirectURL", "")
232 def _process(self):
233 modif_keys = session.get("modifKeys")
234 if modif_keys and modif_keys.pop(self._conf.getId(), None):
235 session.modified = True
236 if self._redirectURL != "":
237 url = self._redirectURL
238 else:
239 url = urlHandlers.UHConferenceDisplay.getURL(self._conf)
240 self._redirect(url)
243 class RHConferenceClose(RHConferenceModifBase):
244 _uh = urlHandlers.UHConferenceClose
246 def _checkParams(self, params):
247 RHConferenceBase._checkParams(self, params)
248 self._confirm = params.has_key("confirm")
249 self._cancel = params.has_key("cancel")
251 def _process(self):
253 if self._cancel:
254 url = urlHandlers.UHConferenceModification.getURL(self._conf)
255 self._redirect(url)
256 elif self._confirm:
257 self._target.setClosed(True)
258 url = urlHandlers.UHConferenceModification.getURL(self._conf)
259 self._redirect(url)
260 else:
261 return conferences.WPConfClosing(self, self._conf).display()
264 class RHConferenceOpen(RHConferenceModifBase):
265 _allowClosed = True
267 def _checkProtection(self):
268 RHConferenceModifBase._checkProtection(self)
270 user = self._getUser()
271 if user is self._conf.getCreator():
272 return
273 # If we are not the creator, check if we have category admin privileges
274 hasAccess = False
275 for owner in self._conf.getOwnerList():
276 if owner.canUserModify(user): # category or system admin
277 hasAccess = True
278 break
279 if not hasAccess:
280 if self._conf.isClosed():
281 raise ConferenceClosedError(self._target.getConference())
282 else:
283 raise ModificationError()
285 def _checkParams(self, params):
286 RHConferenceBase._checkParams(self, params)
288 def _process(self):
289 self._target.setClosed(False)
290 url = urlHandlers.UHConferenceModification.getURL(self._conf)
291 self._redirect(url)
294 class RHConfDataModif(RHConferenceModifBase):
295 _uh = urlHandlers.UHConfDataModif
297 def _displayCustomPage(self, wf):
298 return None
300 def _displayDefaultPage(self):
301 p = conferences.WPConfDataModif(self, self._target)
302 pars = {}
303 wf = self.getWebFactory()
304 if wf is not None:
305 pars["type"] = wf.getId()
306 return p.display(**pars)
309 class RHConfPerformDataModif(RHConferenceModifBase):
310 _uh = urlHandlers.UHConfPerformDataModif
312 def _checkParams( self, params ):
313 RHConferenceModifBase._checkParams( self, params )
314 if params.get("title", "").strip() =="" and not ("cancel" in params):
315 raise FormValuesError("Please, provide a name for the event")
316 self._cancel = params.has_key("cancel")
318 def _process( self ):
319 if not self._cancel:
320 UtilsConference.setValues( self._conf, self._getRequestParams() )
321 self._redirect( urlHandlers.UHConferenceModification.getURL( self._conf) )
324 #----------------------------------------------------------------
326 class RHConfModifSchedule(RHConferenceModifBase):
327 _uh = urlHandlers.UHConfModifSchedule
329 def _checkParams( self, params ):
330 RHConferenceModifBase._checkParams( self, params )
331 params["sessions"] = self._normaliseListParam( params.get("session", []) )
332 params["slot"] = params.get("slot", [])
333 params["days"] = params.get("day", "all")
334 params["contributions"] = self._normaliseListParam( params.get("contribution", []) )
335 if params.get("session", None) is not None :
336 del params["session"]
337 if params.get("day", None) is not None :
338 del params["day"]
340 def _process( self ):
342 # The timetable management page shouldn't be cached
343 self._disableCaching();
345 params = self._getRequestParams()
347 if self._conf.isClosed():
348 p = conferences.WPConferenceModificationClosed( self, self._target )
349 return p.display()
350 elif params['sessions'] == []:
351 p = conferences.WPConfModifScheduleGraphic( self, self._target )
353 wf=self.getWebFactory()
354 if wf is not None:
355 p=wf.getConfModifSchedule( self, self._target )
356 return p.display(**params)
357 else:
359 session = self._target.getSessionById(params['sessions'][0])
361 p = sessions.WPSessionModifSchedule( self, session )
363 wf=self.getWebFactory()
364 if wf is not None:
365 p=wf.getSessionModifSchedule( self, session )
366 return p.display(**params)
368 class RHScheduleDataEdit(RHConferenceModifBase):
369 _uh = urlHandlers.UHConfModScheduleDataEdit
371 def _checkParams(self,params):
372 RHConferenceModifBase._checkParams(self,params)
373 self._action=""
374 if params.has_key("CANCEL"):
375 self._action="CANCEL"
376 elif params.has_key("OK"):
377 self._action="EDIT"
378 self._sDate,self._eDate=None,None
379 try:
380 self._sDate=datetime(int(params["sYear"]),
381 int(params["sMonth"]),
382 int(params["sDay"]),
383 int(params["sHour"]),
384 int(params["sMin"]))
385 except ValueError:
386 raise MaKaCError( _("Please enter integers in all the start date fields"), _("Schedule"))
387 try:
388 self._eDate=datetime(int(params["eYear"]),
389 int(params["eMonth"]),
390 int(params["eDay"]),
391 int(params["eHour"]),
392 int(params["eMin"]))
393 except ValueError:
394 raise MaKaCError( _("Please enter integers in all the end date fields"), _("Schedule"))
396 def _process( self ):
397 url=urlHandlers.UHConfModifSchedule.getURL(self._target)
398 if self._action=="CANCEL":
399 self._redirect(url)
400 return
401 elif self._action=="EDIT":
403 # The times are naive relative to the conference tz, must
404 # convert to UTC.
406 confTZ = self._target.getTimezone()
407 sd = timezone(confTZ).localize(datetime(self._sDate.year,
408 self._sDate.month,
409 self._sDate.day,
410 self._sDate.hour,
411 self._sDate.minute))
412 sdUTC = sd.astimezone(timezone('UTC'))
413 ed = timezone(confTZ).localize(datetime(self._eDate.year,
414 self._eDate.month,
415 self._eDate.day,
416 self._eDate.hour,
417 self._eDate.minute))
418 edUTC = ed.astimezone(timezone('UTC'))
419 self._target.setDates(sdUTC,edUTC)
420 self._redirect(url)
421 return
422 p=conferences.WPModScheduleDataEdit(self,self._target)
423 return p.display()
426 class RConferenceGetSessions(RHConferenceModifBase):
428 def _process(self):
429 from MaKaC.common.fossilize import fossilize
430 return json.dumps(fossilize(self._conf.getSessionList(), ISessionBasicFossil))
433 #-------------------------------------------------------------------------------------
436 class RHConfModifAC( RHConferenceModifBase ):
437 _uh = urlHandlers.UHConfModifAC
439 def _process( self ):
440 if self._conf.isClosed():
441 p = conferences.WPConferenceModificationClosed( self, self._target )
442 return p.display()
443 else:
444 p = conferences.WPConfModifAC( self, self._target)
445 wf=self.getWebFactory()
446 if wf is not None:
447 p = wf.getConfModifAC(self, self._conf)
448 return p.display()
451 class RHConfSetVisibility( RHConferenceModifBase ):
452 _uh = urlHandlers.UHConfSetVisibility
454 def _checkParams( self, params ):
455 RHConferenceModifBase._checkParams( self, params )
456 if params.has_key("changeToPrivate"):
457 self._protectConference = 1
458 elif params.has_key("changeToInheriting"):
459 self._protectConference = 0
460 elif params.has_key("changeToPublic"):
461 self._protectConference = -1
463 def _process( self ):
464 self._conf.setProtection( self._protectConference )
465 self._redirect( urlHandlers.UHConfModifAC.getURL( self._conf ) )
467 class RHConfGrantSubmissionToAllSpeakers( RHConferenceModifBase ):
468 _uh = urlHandlers.UHConfGrantSubmissionToAllSpeakers
470 def _process( self ):
471 for cont in self._target.getContributionList():
472 speakers = cont.getSpeakerList()[:]
473 for sCont in cont.getSubContributionList():
474 speakers += sCont.getSpeakerList()[:]
475 for speaker in speakers:
476 cont.grantSubmission(speaker,False)
477 self._redirect( urlHandlers.UHConfModifAC.getURL( self._target ) )
479 class RHConfRemoveAllSubmissionRights( RHConferenceModifBase ):
480 _uh = urlHandlers.UHConfRemoveAllSubmissionRights
482 def _process( self ):
483 for cont in self._target.getContributionList():
484 cont.revokeAllSubmitters()
485 self._redirect( urlHandlers.UHConfModifAC.getURL( self._target ) )
487 class RHConfGrantModificationToAllConveners( RHConferenceModifBase ):
488 _uh = urlHandlers.UHConfGrantModificationToAllConveners
490 def _process( self ):
491 for ses in self._target.getSessionList():
492 for slot in ses.getSlotList():
493 for convener in slot.getConvenerList():
494 ses.grantModification(convener,False)
495 self._redirect( urlHandlers.UHConfModifAC.getURL( self._target ) )
498 class RHConfDeletion(RHConferenceModifBase):
499 _uh = urlHandlers.UHConfDeletion
501 def _checkParams( self, params ):
502 RHConferenceModifBase._checkParams( self, params )
503 self._confirm = params.has_key( "confirm" )
504 self._cancel = params.has_key( "cancel" )
506 def _process( self ):
507 if self._cancel:
508 self._redirect( urlHandlers.UHConfModifTools.getURL( self._conf ) )
509 elif self._confirm:
510 parent=None
511 if self._conf.getOwnerList()!=[]:
512 parent=self._conf.getOwnerList()[0]
513 self._conf.delete(session.user)
514 if parent is not None:
515 self._redirect( urlHandlers.UHCategoryModification.getURL(parent) )
516 else:
517 self._redirect( urlHandlers.UHWelcome.getURL() )
518 else:
519 return conferences.WPConfDeletion( self, self._conf ).display()
521 class RHConfModifParticipants( RHConferenceModifBase ):
522 _uh = urlHandlers.UHConfModifParticipants
524 def _process( self ):
525 if self._conf.isClosed():
526 return conferences.WPConferenceModificationClosed( self, self._target ).display()
527 else:
528 return conferences.WPConfModifParticipants( self, self._target ).display()
530 class RHConfModifParticipantsSetup(RHConferenceModifBase):
531 _uh = urlHandlers.UHConfModifParticipantsSetup
533 def _process( self ):
534 if self._conf.isClosed():
535 return conferences.WPConferenceModificationClosed( self, self._target ).display()
536 else:
537 return conferences.WPConfModifParticipantsSetup( self, self._target ).display()
539 class RHConfModifParticipantsPending(RHConferenceModifBase):
540 _uh = urlHandlers.UHConfModifParticipantsPending
542 def _process( self ):
543 if self._conf.isClosed():
544 return conferences.WPConferenceModificationClosed( self, self._target ).display()
545 elif self._target.getParticipation().getPendingParticipantList() and nowutc() < self._target.getStartDate():
546 return conferences.WPConfModifParticipantsPending( self, self._target ).display()
547 else:
548 return self._redirect(RHConfModifParticipants._uh.getURL(self._conf))
550 class RHConfModifParticipantsDeclined(RHConferenceModifBase):
551 _uh = urlHandlers.UHConfModifParticipantsDeclined
553 def _process( self ):
554 if self._conf.isClosed():
555 return conferences.WPConferenceModificationClosed( self, self._target ).display()
556 elif self._target.getParticipation().getDeclinedParticipantList():
557 return conferences.WPConfModifParticipantsDeclined( self, self._target ).display()
558 else:
559 return self._redirect(RHConfModifParticipants._uh.getURL(self._conf))
562 class RHConfModifParticipantsAction(RHConfModifParticipants):
563 _uh = urlHandlers.UHConfModifParticipantsAction
565 def _process( self ):
566 params = self._getRequestParams()
567 selectedList = self._normaliseListParam(self._getRequestParams().get("participants",[]))
568 toList = []
569 if selectedList == []:
570 raise FormValuesError(_("No participant selected! Please select at least one."))
571 else:
572 for id in selectedList :
573 participant = self._conf.getParticipation().getParticipantById(id)
574 toList.append(participant)
575 excel = ParticipantsListToExcel(self._conf, list=toList)
576 return send_file('ParticipantList.csv', StringIO(excel.getExcelFile()), 'CSV')
579 class RHConfModifParticipantsStatistics(RHConferenceModifBase):
580 _uh = urlHandlers.UHConfModifParticipantsStatistics
582 def _process( self ):
583 if self._conf.isClosed():
584 return conferences.WPConferenceModificationClosed( self, self._target ).display()
585 else:
586 return conferences.WPConfModifParticipantsStatistics( self, self._target ).display()
588 #######################################################################################
590 class RHConfAllParticipants( RHConferenceModifBase ):
591 _uh = urlHandlers.UHConfAllSessionsConveners
593 def _process(self):
594 p = conferences.WPConfAllParticipants( self, self._conf )
595 return p.display()
598 class RHConfModifLog (RHConferenceModifBase):
599 _uh = urlHandlers.UHConfModifLog
601 def _checkParams(self, params):
602 RHConferenceModifBase._checkParams( self, params )
604 if params.get("view",None) is not None :
605 if params["view"] == "Action Log" :
606 params["view"] = "action"
607 elif params["view"] == "Email Log" :
608 params["view"] = "email"
609 elif params["view"] == "Custom Log" :
610 params["view"] = "custom"
611 elif params["view"] == "General Log" :
612 params["view"] = "general"
614 def _process(self):
615 params = self._getRequestParams()
616 p = conferences.WPConfModifLog( self, self._target )
617 return p.display(**params)
619 #######################################################################################
621 class RHConfClone( RHConferenceModifBase ):
622 _uh = urlHandlers.UHConfClone
623 _allowClosed = True
625 def _process( self ):
626 p = conferences.WPConfClone( self, self._conf )
627 wf=self.getWebFactory()
628 if wf is not None:
629 p = wf.getConfClone(self, self._conf)
630 return p.display()
633 #######################################################################################
635 class RHConfAllSessionsConveners( RHConferenceModifBase ):
636 _uh = urlHandlers.UHConfAllSessionsConveners
638 def _process(self):
639 p = conferences.WPConfAllSessionsConveners( self, self._conf )
640 # wf=self.getWebFactory()
641 # if wf is not None:
642 # p = wf.getConfClone(self, self._conf)
644 return p.display()
646 class RHConfAllSessionsConvenersAction( RHConferenceModifBase ):
648 def _checkParams( self, params ):
649 RHConferenceModifBase._checkParams(self, params)
650 self._selectedConveners = self._normaliseListParam(params.get("conveners",[]))
652 def _process( self ):
653 if len(self._selectedConveners)>0:
654 p = conferences.WPEMailConveners(self, self._conf, self._selectedConveners)
655 return p.display()
656 else:
657 self._redirect(urlHandlers.UHConfAllSessionsConveners.getURL(self._conf))
659 class RHConvenerSendEmail( RHConferenceModifBase ):
661 def _checkParams(self, params):
662 RHConferenceModifBase._checkParams( self, params )
664 self._toEmails = []
665 cclist = []
667 self._send = params.has_key("OK")
668 if self._send:
669 if len(params.get("toEmails","").strip()) > 0 :
670 self._toEmails = (params.get("toEmails","").strip()).split(",")
671 else :
672 raise FormValuesError( _("'To' address list is empty"))
673 if params.get("from","") == "":
674 raise FormValuesError( _("Please write from address"))
675 if params.get("subject","") == "":
676 raise FormValuesError( _("Please write a subject for the email"))
677 if params.get("body","") == "":
678 raise FormValuesError( _("Please write a body for the email"))
679 #####cclist emails
680 cclist = params.get("cc","").strip().split(",")
681 # remove empty elements
682 if '' in cclist:
683 cclist.remove('')
684 # strip all the elements in the list
685 cclist = map(lambda x: x.strip(), cclist)
686 #####
688 self._params={}
689 self._params["subject"]=params["subject"]
690 self._params["from"]=params["from"]
691 self._params["body"]=params["body"]
692 self._params["cc"]=cclist
693 self._params["conf"] = self._conf
694 self._preview = params.has_key("preview")
696 def _process(self):
697 if self._send:
698 self._params['to'] = self._toEmails
699 registrantNotificator.EmailNotificator().notifyAll(self._params)
700 p = conferences.WPConvenerSentEmail(self, self._target)
701 return p.display()
702 else:
703 self._redirect(urlHandlers.UHConfAllSessionsConveners.getURL(self._conf))
705 #######################################################################################
708 class RHConfAllSpeakers( RHConferenceModifBase ):
709 _uh = urlHandlers.UHConfAllSpeakers
711 def _process(self):
712 p = conferences.WPConfAllSpeakers( self, self._conf )
713 return p.display()
715 class RHConfAllSpeakersAction( RHConferenceModifBase ):
717 def _checkParams( self, params ):
718 RHConferenceModifBase._checkParams(self, params)
719 self._selectedSpeakers = self._normaliseListParam(params.get("participants",[]))
721 def _process( self ):
723 if len(self._selectedSpeakers)>0:
724 p = conferences.WPEMailContribParticipants(self, self._conf, self._selectedSpeakers)
725 return p.display()
726 else:
727 self._redirect(urlHandlers.UHConfAllSpeakers.getURL(self._conf))
729 class RHContribParticipantsSendEmail( RHConferenceModifBase ):
731 def _checkParams(self, params):
732 RHConferenceModifBase._checkParams( self, params )
734 self._toEmails = []
735 cclist = []
737 self._send = params.has_key("OK")
738 if self._send:
739 if len(params.get("toEmails","").strip()) > 0 :
740 self._toEmails = (params.get("toEmails","").strip()).split(",")
741 else :
742 raise FormValuesError( _("'To' address list is empty"))
743 if params.get("from","") == "":
744 raise FormValuesError( _("Please write from address"))
745 if params.get("subject","") == "":
746 raise FormValuesError( _("Please write a subject for the email"))
747 if params.get("body","") == "":
748 raise FormValuesError( _("Please write a body for the email"))
749 #####cclist emails
750 cclist = params.get("cc","").strip().split(",")
751 # remove empty elements
752 if '' in cclist:
753 cclist.remove('')
754 # strip all the elements in the list
755 cclist = map(lambda x: x.strip(), cclist)
756 #####
758 self._params={}
759 self._params["subject"]=params["subject"]
760 self._params["from"]=params["from"]
761 self._params["body"]=params["body"]
762 self._params["cc"]=cclist
763 self._params["conf"] = self._conf
764 self._preview = params.has_key("preview")
766 def _process(self):
767 if self._send:
768 self._params['to'] = self._toEmails
769 registrantNotificator.EmailNotificator().notifyAll(self._params)
770 p = conferences.WPContribParticipationSentEmail(self, self._target)
771 return p.display()
772 else:
773 self._redirect(urlHandlers.UHConfAllSpeakers.getURL(self._conf))
776 #######################################################################################
779 class RHConfPerformCloning(RHConferenceModifBase, object):
781 New version of clone functionality -
782 fully replace the old one, based on three different actions,
783 adds mechanism of selective cloning of materials and access
784 privileges attached to an event
786 _uh = urlHandlers.UHConfPerformCloning
787 _cloneType = "none"
788 _allowClosed = True
790 def _checkParams( self, params ):
791 RHConferenceModifBase._checkParams( self, params )
792 self._date = datetime.today()
793 self._cloneType = params.get("cloneType", None)
794 if self._cloneType is None:
795 raise FormValuesError( _("""Please choose a cloning interval for this event"""))
796 elif self._cloneType == "once" :
797 self._date = datetime( int(params["stdyo"]), \
798 int(params["stdmo"]), \
799 int(params["stddo"]), \
800 int(self._conf.getAdjustedStartDate().hour), \
801 int(self._conf.getAdjustedStartDate().minute) )
802 elif self._cloneType == "intervals" :
803 self._date = datetime( int(params["indyi"]), \
804 int(params["indmi"]), \
805 int(params["inddi"]), \
806 int(self._conf.getAdjustedStartDate().hour), \
807 int(self._conf.getAdjustedStartDate().minute) )
808 elif self._cloneType == "days" :
809 self._date = datetime( int(params["indyd"]), \
810 int(params["indmd"]), \
811 int(params["inddd"]), \
812 int(self._conf.getAdjustedStartDate().hour), \
813 int(self._conf.getAdjustedStartDate().minute) )
814 self._confirm = params.has_key( "confirm" )
815 self._cancel = params.has_key( "cancel" )
817 def _process( self ):
818 params = self._getRequestParams()
819 paramNames = params.keys()
820 options = { "materials" : "cloneMaterials" in paramNames,
821 "access" : "cloneAccess" in paramNames,
822 "keys" : "cloneAccess" in paramNames,
823 "authors" : "cloneTimetable" in paramNames,
824 "contributions" : "cloneTimetable" in paramNames,
825 "subcontribs" : "cloneTimetable" in paramNames,
826 "sessions" : "cloneTimetable" in paramNames,
827 "tracks" : "cloneTracks" in paramNames,
828 "registration" : "cloneRegistration" in paramNames,
829 "abstracts" : "cloneAbstracts" in paramNames,
830 "participants" : "cloneParticipants" in paramNames,
831 "evaluation" : "cloneEvaluation" in paramNames,
832 "managing" : self._getUser()
834 #we notify the event in case any plugin wants to add their options
835 if self._cancel:
836 self._redirect( urlHandlers.UHConfClone.getURL( self._conf ) )
837 elif self._confirm:
838 if self._cloneType == "once" :
839 newConf = self._conf.clone( self._date, options, userPerformingClone = self._aw._currentUser )
840 self._redirect( urlHandlers.UHConferenceModification.getURL( newConf ) )
841 elif self._cloneType == "intervals" :
842 self._withIntervals(options)
843 elif self._cloneType == "days" :
844 self._days(options)
845 else :
846 self._redirect( urlHandlers.UHConfClone.getURL( self._conf ) )
847 else:
848 if self._cloneType == "once" :
849 nbClones = 1
850 elif self._cloneType == "intervals" :
851 nbClones = self._withIntervals(options,0)
852 elif self._cloneType == "days" :
853 nbClones = self._days(options,0)
854 return conferences.WPConfCloneConfirm( self, self._conf, nbClones ).display()
856 def _withIntervals(self, options, confirmed=1):
857 nbClones = 0
858 params = self._getRequestParams()
859 if params["freq"] == "day":
860 inter = timedelta(int(params["period"]))
861 elif params["freq"] == "week":
862 inter = timedelta( 7*int(params["period"]))
864 if params["intEndDateChoice"] == "until":
865 date=self._date
866 endDate = datetime(int(params["stdyi"]),int(params["stdmi"]),int(params["stddi"]), self._conf.getEndDate().hour,self._conf.getEndDate().minute)
867 while date <= endDate:
868 if confirmed:
869 self._conf.clone(date,options, userPerformingClone = self._aw._currentUser)
870 nbClones += 1
871 if params["freq"] == "day" or params["freq"] == "week":
872 date = date + inter
873 elif params["freq"] == "month":
874 month = int(date.month) + int(params["period"])
875 year = int(date.year)
876 while month > 12:
877 month = month - 12
878 year = year + 1
879 date = datetime(year,month,int(date.day), int(date.hour), int(date.minute))
880 elif params["freq"] == "year":
881 date = datetime(int(date.year)+int(params["period"]),int(date.month),int(date.day), int(date.hour), int(date.minute))
883 elif params["intEndDateChoice"] == "ntimes":
884 date = self._date
886 stop = int(params["numi"])
887 while i < stop:
888 i = i + 1
889 if confirmed:
890 self._conf.clone(date,options, userPerformingClone = self._aw._currentUser)
891 nbClones += 1
892 if params["freq"] == "day" or params["freq"] == "week":
893 date = date + inter
894 elif params["freq"] == "month":
895 month = int(date.month) + int(params["period"])
896 year = int(date.year)
897 while month > 12:
898 month = month - 12
899 year = year + 1
900 date = datetime(year,month,int(date.day), int(date.hour), int(date.minute))
901 elif params["freq"] == "year":
902 date = datetime(int(date.year)+int(params["period"]),int(date.month),int(date.day), int(date.hour), int(date.minute))
903 if confirmed:
904 self._redirect( urlHandlers.UHCategoryDisplay.getURL( self._conf.getOwner() ) )
905 return "done"
906 else:
907 return nbClones
909 def _getFirstDay(self, date, day):
911 return the first day 'day' for the month of 'date'
913 td = datetime(int(date.year), int(date.month), 1, int(date.hour), int(date.minute))
915 oneDay = timedelta(1)
916 while 1:
917 if td.weekday() == day:
918 return td
919 td = td + oneDay
921 def _getOpenDay(self, date, day):
923 return the first open day for the month of 'date'
925 if day!="last": # last open day of the month
926 td = datetime(int(date.year), int(date.month), int(date.day), int(date.hour), int(date.minute))
927 if td.weekday() > 4:
928 td = td + timedelta(7 - td.weekday())
929 td += timedelta(int(day)-1)
930 else:
931 td = self._getLastDay(date, -1)
932 if td.weekday() > 4:
933 td = td - timedelta(td.weekday() - 4)
934 return td
936 def _getLastDay(self, date, day):
938 return the last day 'day' for the month of 'date'
940 td = datetime(int(date.year), int(date.month), 28, int(date.hour), int(date.minute))
941 month=td.month
942 while td.month == month:
943 td += timedelta(1)
944 td -= timedelta(1)
945 if day==-1:
946 return td
947 else:
948 while 1:
949 if td.weekday() == day:
950 return td
951 td = td - timedelta(1)
953 def _days(self, options, confirmed=1):
954 nbClones = 0
955 params = self._getRequestParams()
956 #search the first day of the month
958 if params["day"] == "NOVAL":
959 #self._endRequest()
960 self.redirect( urlHandlers.UHConfClone.getURL( self._target ) )
962 if params["daysEndDateChoice"] == "until":
963 date = self._date
965 endDate = datetime(int(params["stdyd"]),int(params["stdmd"]),int(params["stddd"]),self._conf.getEndDate().hour,self._conf.getEndDate().minute)
967 if params["day"] == "OpenDay":
968 rd = self._getOpenDay(date, params["order"])
969 else:
970 if params["order"] == "last":
971 rd = self._getLastDay(date, int(params["day"]))
972 if rd < date:
973 date = (date + relativedelta(months=1)).replace(day=1)
974 else:
975 rd = self._getFirstDay(date, int(params["day"])) + timedelta((int(params["order"])-1)*7)
976 if rd < date:
977 date = (date + relativedelta(months=1)).replace(day=1)
978 while date <= endDate:
979 if params["day"] == "OpenDay":
980 od=self._getOpenDay(date,params["order"])
981 if od <= endDate:
982 if confirmed:
983 self._conf.clone(od, options, userPerformingClone = self._aw._currentUser)
984 nbClones += 1
985 else:
986 if params["order"] == "last":
987 if self._getLastDay(date,int(params["day"])) <= endDate:
988 if confirmed:
989 self._conf.clone(self._getLastDay(date,int(params["day"])), options, userPerformingClone = self._aw._currentUser)
990 nbClones += 1
991 else:
992 if self._getFirstDay(date, int(params["day"])) + timedelta((int(params["order"])-1)*7) <= endDate:
993 if confirmed:
994 self._conf.clone(self._getFirstDay(date, int(params["day"]))+ timedelta((int(params["order"])-1)*7), options, userPerformingClone = self._aw._currentUser)
995 nbClones += 1
996 month = int(date.month) + int(params["monthPeriod"])
997 year = int(date.year)
998 while month > 12:
999 month = month - 12
1000 year = year + 1
1001 date = datetime(year,month,1, int(date.hour), int(date.minute))
1003 elif params["daysEndDateChoice"] == "ntimes":
1005 date = self._date
1006 if params["day"] == "OpenDay":
1007 rd = self._getOpenDay(date,params["order"])
1008 else:
1009 if params["order"] == "last":
1010 rd = self._getLastDay(date, int(params["day"]))
1011 if rd < date:
1012 date = (date + relativedelta(months=1)).replace(day=1)
1013 else:
1014 rd = self._getFirstDay(date, int(params["day"])) + timedelta((int(params["order"])-1)*7)
1015 if rd < date:
1016 date = (date + relativedelta(months=1)).replace(day=1)
1019 stop = int(params["numd"])
1020 while i < stop:
1021 i = i + 1
1022 if params["day"] == "OpenDay":
1023 if confirmed:
1024 self._conf.clone(self._getOpenDay(date, params["order"]), options, userPerformingClone = self._aw._currentUser)
1025 nbClones += 1
1026 else:
1027 if params["order"] == "last":
1028 if confirmed:
1029 self._conf.clone(self._getLastDay(date,int(params["day"])), options, userPerformingClone = self._aw._currentUser)
1030 nbClones += 1
1031 else:
1032 if confirmed:
1033 self._conf.clone(self._getFirstDay(date, int(params["day"]))+ timedelta((int(params["order"])-1)*7), options, userPerformingClone = self._aw._currentUser)
1034 nbClones += 1
1035 month = int(date.month) + int(params["monthPeriod"])
1036 year = int(date.year)
1037 while month > 12:
1038 month = month - 12
1039 year = year + 1
1040 date = datetime(year,month,int(date.day), int(date.hour), int(date.minute))
1041 if confirmed:
1042 self._redirect( urlHandlers.UHCategoryDisplay.getURL( self._conf.getOwner() ) )
1043 else:
1044 return nbClones
1046 ####################################################################################
1049 class RHConfModifProgram( RHConferenceModifBase ):
1051 def _process( self ):
1052 p = conferences.WPConfModifProgram( self, self._target )
1053 return p.display()
1056 class RHConfAddTrack( RHConferenceModifBase ):
1058 def _process( self ):
1059 p = conferences.WPConfAddTrack( self, self._target )
1060 return p.display()
1063 class RHConfPerformAddTrack( RHConferenceModifBase ):
1065 def _checkParams( self, params ):
1066 RHConferenceModifBase._checkParams( self, params )
1067 self._cancel = params.has_key("cancel")
1069 def _process( self ):
1070 if self._cancel:
1071 self._redirect( urlHandlers.UHConfModifProgram.getURL( self._conf ) )
1072 else:
1073 t = self._conf.newTrack()
1074 params = self._getRequestParams()
1075 t.setTitle(params["title"])
1076 t.setDescription(params["description"])
1077 # Filtering criteria: by default make new contribution type checked
1078 dct = session.setdefault("ContributionFilterConf%s" % self._conf.getId(), {})
1079 if 'tracks' in dct:
1080 #Append the new type to the existing list
1081 newDict = dct['tracks'][:]
1082 newDict.append(t.getId())
1083 dct['tracks'] = newDict[:]
1084 else:
1085 #Create a new entry for the dictionary containing the new type
1086 dct['tracks'] = [t.getId()]
1087 session.modified = True
1088 self._redirect( urlHandlers.UHConfModifProgram.getURL( self._conf ) )
1090 class RHConfDelTracks( RHConferenceModifBase ):
1092 def _checkParams( self, params ):
1093 RHConferenceModifBase._checkParams( self, params )
1094 self._trackList = []
1095 for id in self._normaliseListParam( params.get("selTracks", []) ):
1096 self._trackList.append( self._conf.getTrackById( id ) )
1098 def _process( self ):
1099 for track in self._trackList:
1100 self._conf.removeTrack( track )
1101 self._redirect( urlHandlers.UHConfModifProgram.getURL( self._conf ) )
1104 class RHProgramTrackUp(RHConferenceModifBase):
1106 def _checkParams( self, params ):
1107 RHConferenceModifBase._checkParams( self, params )
1108 self._track=self._target.getTrackById(params.get("trackId",""))
1110 def _process( self ):
1111 self._disableCaching()
1112 self._target.moveUpTrack(self._track)
1113 self._redirect(urlHandlers.UHConfModifProgram.getURL(self._conf))
1116 class RHProgramTrackDown(RHConferenceModifBase):
1118 def _checkParams( self, params ):
1119 RHConferenceModifBase._checkParams( self, params )
1120 self._track=self._target.getTrackById(params.get("trackId",""))
1122 def _process( self ):
1123 self._disableCaching()
1124 self._target.moveDownTrack(self._track)
1125 self._redirect(urlHandlers.UHConfModifProgram.getURL(self._conf))
1127 class CFAEnabled(object):
1128 @staticmethod
1129 def checkEnabled(request):
1130 """ Returns true if abstracts has been enabled
1131 Otherwise, throws an exception
1133 if request._conf.hasEnabledSection("cfa"):
1134 return True
1135 else:
1136 raise MaKaCError( _("You cannot access this option because \"Abstracts\" was disabled"))
1138 class RHConfModifCFABase(RHConferenceModifBase):
1140 def _checkProtection(self):
1141 RHConferenceModifBase._checkProtection(self)
1142 CFAEnabled.checkEnabled(self)
1144 class RHConfModifCFA(RHConfModifCFABase):
1146 def _process( self ):
1147 p = conferences.WPConfModifCFA( self, self._target )
1148 return p.display()
1151 class RHConfModifCFAPreview(RHConfModifCFABase):
1153 def _process( self ):
1154 p = conferences.WPConfModifCFAPreview( self, self._target )
1155 return p.display()
1158 class RHConfModifCFAStatus( RHConfModifCFABase ):
1160 def _checkParams( self, params ):
1161 RHConfModifCFABase._checkParams( self, params )
1162 self._newStatus = params["changeTo"]
1164 def _process( self ):
1165 if self._newStatus == "True":
1166 self._conf.getAbstractMgr().activeCFA()
1167 else:
1168 self._conf.getAbstractMgr().desactiveCFA()
1169 self._redirect( urlHandlers.UHConfModifCFA.getURL( self._conf ) )
1172 class RHConfModifCFASwitchMultipleTracks( RHConfModifCFABase ):
1174 def _process( self ):
1175 self._conf.getAbstractMgr().setMultipleTracks(not self._conf.getAbstractMgr().getMultipleTracks())
1176 self._redirect( urlHandlers.UHConfModifCFA.getURL( self._conf ) )
1178 class RHConfModifCFAMakeTracksMandatory( RHConfModifCFABase ):
1180 def _process( self ):
1181 self._conf.getAbstractMgr().setTracksMandatory(not self._conf.getAbstractMgr().areTracksMandatory())
1182 self._redirect( urlHandlers.UHConfModifCFA.getURL( self._conf ) )
1185 class RHConfModifCFASwitchAttachFiles( RHConfModifCFABase ):
1187 def _process( self ):
1188 self._conf.getAbstractMgr().setAllowAttachFiles(not self._conf.getAbstractMgr().canAttachFiles())
1189 self._redirect( urlHandlers.UHConfModifCFA.getURL( self._conf ) )
1192 class RHConfModifCFASwitchShowSelectAsSpeaker( RHConfModifCFABase ):
1194 def _process( self ):
1195 self._conf.getAbstractMgr().setShowSelectAsSpeaker(not self._conf.getAbstractMgr().showSelectAsSpeaker())
1196 self._redirect( urlHandlers.UHConfModifCFA.getURL( self._conf ) )
1198 class RHConfModifCFASwitchSelectSpeakerMandatory( RHConfModifCFABase ):
1200 def _process( self ):
1201 self._conf.getAbstractMgr().setSelectSpeakerMandatory(not self._conf.getAbstractMgr().isSelectSpeakerMandatory())
1202 self._redirect( urlHandlers.UHConfModifCFA.getURL( self._conf ) )
1204 class RHConfModifCFASwitchShowAttachedFilesContribList( RHConfModifCFABase ):
1206 def _process( self ):
1207 self._conf.getAbstractMgr().setSwitchShowAttachedFilesContribList(not self._conf.getAbstractMgr().showAttachedFilesContribList())
1208 self._redirect( urlHandlers.UHConfModifCFA.getURL( self._conf ) )
1211 class RHCFADataModification( RHConfModifCFABase ):
1213 def _process( self ):
1214 p = conferences.WPCFADataModification( self, self._target )
1215 return p.display()
1218 class RHCFAPerformDataModification( RHConfModifCFABase ):
1220 def _checkParams( self, params ):
1221 RHConfModifCFABase._checkParams( self, params )
1222 self._cancel = params.has_key("cancel")
1223 self._modifDL = None
1224 mDay = str( params.get( "mDay", "" ) ).strip()
1225 mMonth = str( params.get( "mMonth", "" ) ).strip()
1226 mYear = str( params.get( "mYear", "" ) ).strip()
1227 if mDay != "" and mMonth !="" and mYear != "":
1228 self._modifDL = datetime( int(mYear), int(mMonth), int(mDay) )
1230 def _process( self ):
1231 if self._cancel:
1232 self._redirect( urlHandlers.UHConfModifCFA.getURL( self._conf ) )
1233 else:
1234 abMgr = self._conf.getAbstractMgr()
1235 params = self._getRequestParams()
1237 abMgr.setStartSubmissionDate(datetime(int(params["sYear"]), int(params["sMonth"]), int(params["sDay"])))
1238 abMgr.setEndSubmissionDate(datetime(int(params["eYear"]), int(params["eMonth"]), int(params["eDay"])))
1239 try:
1240 sDate = datetime(int(params["sYear"]), int(params["sMonth"]), int(params["sDay"]))
1241 except ValueError, e:
1242 raise FormValuesError("The start date you have entered is not correct: %s" % e, "Abstracts")
1243 try:
1244 eDate = datetime(int(params["eYear"]), int(params["eMonth"]), int(params["eDay"]))
1245 except ValueError, e:
1246 raise FormValuesError("The end date you have entered is not correct: %s" % e, "Abstracts")
1247 if eDate < sDate:
1248 raise FormValuesError("End date can't be before start date!", "Abstracts")
1249 try:
1250 mDate = None
1251 if params["mYear"] or params["mMonth"] or params["mDay"]:
1252 mDate = datetime(int(params["mYear"]), int(params["mMonth"]), int(params["mDay"]))
1253 except ValueError, e:
1254 raise FormValuesError("The modification end date you have entered is not correct: %s" % e, "Abstracts")
1255 if mDate is not None and mDate < eDate:
1256 raise FormValuesError("Modification end date must be after end date!", "Abstracts")
1258 abMgr.setAnnouncement(params["announcement"])
1259 abMgr.setModificationDeadline(self._modifDL)
1260 abMgr.getSubmissionNotification().setToList(utils.getEmailList(params.get("toList", "")))
1261 abMgr.getSubmissionNotification().setCCList(utils.getEmailList(params.get("ccList", "")))
1262 self._redirect(urlHandlers.UHConfModifCFA.getURL(self._conf))
1265 class AbstractStatusFilter( filters.FilterField ):
1266 """Contains the filtering criteria for the status of an abstract.
1268 Implements the logic to determine whether abstracts are within a list
1269 of abstract status. Objects of this class will keep a list of status
1270 names; then an abstract will satisfy the filter if it is in an abstract
1271 which name is included in the list of values.
1273 Inherits from: AbstractFilterField
1275 Attributes:
1276 _values -- (list) List of abstract status names; if the name of the
1277 current status of an abstract is included in this list, the
1278 abstract will satisfy the filter field.
1279 _showNoValue -- (bool) Not used for this filter field.
1281 _id = "status"
1283 def satisfies( self, abstract ):
1284 if len(AbstractStatusList.getInstance().getStatusList()) == len(self._values):
1285 return True
1286 else:
1287 status = AbstractStatusList.getInstance().getId( abstract.getCurrentStatus().__class__ )
1288 return status in self._values
1290 def needsToBeApplied(self):
1291 for s in AbstractStatusList.getStatusList():
1292 if AbstractStatusList.getInstance().getId(s) not in self._values:
1293 return True
1294 return False
1297 class AbstractFilterCriteria(filters.FilterCriteria):
1300 _availableFields = {
1301 abstractFilters.TrackFilterField.getId(): \
1302 abstractFilters.TrackFilterField, \
1303 abstractFilters.ContribTypeFilterField.getId(): \
1304 abstractFilters.ContribTypeFilterField, \
1305 AbstractStatusFilter.getId() : AbstractStatusFilter, \
1306 abstractFilters.CommentFilterField.getId(): \
1307 abstractFilters.CommentFilterField, \
1308 abstractFilters.AccContribTypeFilterField.getId():\
1309 abstractFilters.AccContribTypeFilterField,
1310 abstractFilters.AccTrackFilterField.getId():\
1311 abstractFilters.AccTrackFilterField }
1314 class _AbstractStatusSF( filters.SortingField ):
1315 _id = "status"
1317 def compare( self, a1, a2 ):
1318 a1Stat, a2Stat = a1.getCurrentStatus(), a2.getCurrentStatus()
1319 if a1Stat == a2Stat:
1320 return 0
1321 a1StatLabel = AbstractStatusList.getInstance().getCaption( a1Stat.__class__ )
1322 a2StatLabel = AbstractStatusList.getInstance().getCaption( a2Stat.__class__ )
1323 return cmp( a1StatLabel, a2StatLabel )
1326 class _AbstractIdSF( filters.SortingField ):
1327 _id = "number"
1329 def compare( self, a1, a2 ):
1330 try:
1331 a = int(a1.getId())
1332 b = int(a2.getId())
1333 except:
1334 a = a1.getId()
1335 b = a2.getId()
1336 return cmp( a, b )
1338 class _AbstractRatingSF( filters.SortingField ):
1339 _id = "rating"
1341 def compare( self, a1, a2 ):
1342 a = a1.getRating()
1343 b = a2.getRating()
1344 # check if the rating is none because the abstract has no judgement
1345 if a == None:
1346 a = -1.0
1347 if b == None:
1348 b = -1.0
1349 return cmp( a, b )
1351 class _AbstractTrackSF( filters.SortingField ):
1352 _id = "track"
1354 def compare( self, a1, a2 ):
1355 trackList1 = a1.getTrackList()
1356 trackList2 = a2.getTrackList()
1357 # check if there is track assignement for the abstract and get the list of ids if needed
1358 if len(trackList1) == 0:
1359 a = [-1]
1360 else:
1361 a = [track.getId() for track in trackList1]
1362 if len(trackList2) == 0:
1363 b = [-1]
1364 else:
1365 b = [track.getId() for track in trackList2]
1366 return cmp( a, b )
1368 class AbstractSortingCriteria( filters.SortingCriteria ):
1371 _availableFields = {
1372 abstractFilters.ContribTypeSortingField.getId(): \
1373 abstractFilters.ContribTypeSortingField, \
1374 _AbstractTrackSF.getId(): _AbstractTrackSF, \
1375 _AbstractStatusSF.getId(): _AbstractStatusSF, \
1376 _AbstractIdSF.getId(): _AbstractIdSF, \
1377 _AbstractRatingSF.getId(): _AbstractRatingSF, \
1378 abstractFilters.SubmissionDateSortingField.getId() : \
1379 abstractFilters.SubmissionDateSortingField, \
1380 abstractFilters.ModificationDateSortingField.getId() : \
1381 abstractFilters.ModificationDateSortingField
1385 class RHAbstractList(RHConfModifCFABase):
1386 _uh = urlHandlers.UHConfAbstractManagment
1388 def _resetFilters( self, sessionData ):
1390 Brings the filter data to a consistent state (websession),
1391 marking everything as "checked"
1394 sessionData["track"] = sessionData["acc_track"] = [track.getId() for track in self._conf.getTrackList()]
1395 sessionData["type"] = sessionData["acc_type"] = [ct.getId() for ct in self._conf.getContribTypeList()]
1396 abstractStatusList = AbstractStatusList.getInstance()
1397 sessionData["status"] = map(lambda status: abstractStatusList.getId( status ), abstractStatusList.getStatusList())
1398 sessionData['authSearch'] = ""
1400 sessionData["trackShowNoValue"] = True
1401 sessionData["typeShowNoValue"] = True
1402 sessionData["accTypeShowNoValue"] = True
1403 sessionData["accTrackShowNoValue"] = True
1404 sessionData["trackShowMultiple"] = False
1405 sessionData.pop("comment", None)
1407 return sessionData
1409 def _updateFilters( self, sessionData, params ):
1411 Updates the filter parameters in the websession with those
1412 coming from the HTTP request
1414 sessionData['track'] = []
1415 sessionData['acc_track'] = []
1416 sessionData['type'] = []
1417 sessionData['acc_type'] = []
1418 sessionData['status'] = []
1419 sessionData['authSearch'] = ""
1421 sessionData.update(params)
1423 sessionData['track'] = utils.normalizeToList(sessionData.get("track"))
1424 sessionData['status'] = utils.normalizeToList(sessionData.get("status"))
1425 sessionData['acc_track'] = utils.normalizeToList(sessionData.get("acc_track"))
1427 # update these elements in the session so that the parameters that are
1428 # passed are always taken into account (sessionData.update is not
1429 # enough, since the elements that are ommitted in params would just be
1430 # ignored
1432 sessionData['trackShowNoValue'] = params.has_key('trackShowNoValue')
1433 sessionData['trackShowMultiple'] = params.has_key("trackShowMultiple")
1434 sessionData['accTrackShowNoValue'] = params.has_key("accTrackShowNoValue")
1435 sessionData['typeShowNoValue'] = params.has_key('typeShowNoValue')
1436 sessionData['accTypeShowNoValue'] = params.has_key('accTypeShowNoValue')
1437 if params.has_key("comment"):
1438 sessionData['comment'] = ""
1439 elif sessionData.has_key("comment"):
1440 del sessionData['comment']
1441 return sessionData
1443 def _buildFilteringCriteria(self, sessionData):
1445 Creates the Filtering Criteria object, without changing the existing
1446 session data (sessionData is cloned, not directly changed)
1448 sessionCopy = sessionData.copy()
1450 # Build the filtering criteria
1451 filterCrit = AbstractFilterCriteria(self._conf, sessionCopy)
1453 filterCrit.getField("track").setShowNoValue(sessionCopy.get("trackShowNoValue"))
1454 filterCrit.getField("track").setOnlyMultiple(sessionCopy.get("trackShowMultiple"))
1455 filterCrit.getField("acc_track").setShowNoValue(sessionCopy.get("accTrackShowNoValue"))
1456 filterCrit.getField("type").setShowNoValue(sessionCopy.get("typeShowNoValue"))
1457 filterCrit.getField("acc_type").setShowNoValue(sessionCopy.get("accTypeShowNoValue"))
1459 return filterCrit
1461 def _checkAction( self, params, filtersActive, sessionData, operation ):
1463 Decides what to do with the request parameters, depending
1464 on the type of operation that is requested
1466 # user chose to reset the filters
1467 if operation == 'resetFilters':
1468 self._filterUsed = False
1469 sessionData = self._resetFilters(sessionData)
1471 # user set the filters
1472 elif operation == 'setFilters':
1473 self._filterUsed = True
1474 sessionData = self._updateFilters(sessionData, params)
1476 # user has changed the display options
1477 elif operation == 'setDisplay':
1478 self._filterUsed = filtersActive
1479 sessionData['disp'] = params.get('disp',[])
1481 # session is empty (first time)
1482 elif not filtersActive:
1483 self._filterUsed = False
1484 sessionData = self._resetFilters(sessionData)
1485 else:
1486 self._filterUsed = True
1488 # preserve the order and sortBy parameters, whatever happens
1489 sessionData['order'] = params.get('order', 'down')
1490 sessionData['sortBy'] = params.get('sortBy', 'number')
1492 return sessionData
1494 def _checkParams( self, params ):
1495 RHConfModifCFABase._checkParams( self, params )
1497 operationType = params.get('operationType')
1499 # session data
1500 sessionData = session.get('abstractFilterAndSortingConf%s' % self._conf.getId())
1502 # check if there is information already
1503 # set in the session variables
1504 if sessionData:
1505 # work on a copy
1506 sessionData = sessionData.copy()
1507 filtersActive = sessionData['filtersActive']
1508 else:
1509 # set a default, empty dict
1510 sessionData = {}
1511 filtersActive = False
1513 if 'resetFilters' in params:
1514 operation = 'resetFilters'
1515 elif operationType == 'filter':
1516 operation = 'setFilters'
1517 elif operationType == 'display':
1518 operation = 'setDisplay'
1519 else:
1520 operation = None
1522 sessionData = self._checkAction(params, filtersActive, sessionData, operation)
1524 # Maintain the state abotu filter usage
1525 sessionData['filtersActive'] = self._filterUsed
1527 # Save the web session
1528 session['abstractFilterAndSortingConf%s' % self._conf.getId()] = sessionData
1530 self._filterCrit = self._buildFilteringCriteria(sessionData)
1532 self._sortingCrit = AbstractSortingCriteria( [sessionData.get( "sortBy", "number" ).strip()] )
1534 self._order = sessionData.get("order","down")
1536 self._msg = sessionData.get("directAbstractMsg","")
1537 self._authSearch = sessionData.get("authSearch", "")
1539 self._display = utils.normalizeToList(sessionData.get("disp",[]))
1541 def _process( self ):
1542 p = conferences.WPConfAbstractList(self,self._target, self._msg, self._filterUsed)
1543 return p.display( filterCrit = self._filterCrit,
1544 sortingCrit = self._sortingCrit,
1545 authSearch=self._authSearch, order=self._order,
1546 display = self._display)
1548 class RHAbstractsActions:
1550 class to select the action to do with the selected abstracts
1552 def process(self, params):
1553 if params.has_key("newAbstract"):
1554 return RHNewAbstract().process(params)
1555 elif params.has_key("pdf"):
1556 return RHAbstractsToPDF().process(params)
1557 elif params.has_key("excel"):
1558 return RHAbstractsListToExcel().process(params)
1559 elif params.has_key("xml"):
1560 return RHAbstractsToXML().process(params)
1561 elif params.has_key("auth"):
1562 return RHAbstractsParticipantList().process(params)
1563 elif params.has_key("merge"):
1564 return RHAbstractsMerge().process(params)
1565 elif params.has_key("acceptMultiple"):
1566 return RHAbstractManagmentAcceptMultiple().process(params)
1567 elif params.has_key("rejectMultiple"):
1568 return RHAbstractManagmentRejectMultiple().process(params)
1569 elif params.has_key("PKGA"):
1570 return RHMaterialPackageAbstract().process(params)
1571 return "no action to do"
1574 class RHAbstractsMerge(RHConfModifCFABase):
1576 def _checkParams(self, params):
1577 RHConfModifCFABase._checkParams(self, params)
1578 self._abstractIds = normaliseListParam(params.get("abstracts", []))
1579 self._targetAbsId = params.get("targetAbstract", "")
1580 self._inclAuthors = "includeAuthors" in params
1581 self._doNotify = "notify" in params
1582 self._comments = params.get("comments", "")
1583 self._action = ""
1584 if "CANCEL" in params:
1585 self._action = "CANCEL"
1586 elif "OK" in params:
1587 self._action = "MERGE"
1588 self._abstractIds = params.get("selAbstracts", "").split(",")
1589 else:
1590 self._doNotify = True
1592 def _process(self):
1593 errorList = []
1595 if self._action == "CANCEL":
1596 self._redirect(
1597 urlHandlers.UHConfAbstractManagment.getURL(self._target))
1598 return
1599 elif self._action == "MERGE":
1600 absMgr = self._target.getAbstractMgr()
1601 if len(self._abstractIds) == 0:
1602 errorList.append(
1603 _("No ABSTRACT TO BE MERGED has been specified"))
1604 else:
1605 self._abstracts = []
1606 for id in self._abstractIds:
1607 abst = absMgr.getAbstractById(id)
1608 if abst is None:
1609 errorList.append(_("ABSTRACT TO BE MERGED ID '%s' is not valid") % (id))
1610 else:
1611 statusKlass = abst.getCurrentStatus().__class__
1612 if statusKlass in (review.AbstractStatusAccepted,
1613 review.AbstractStatusRejected,
1614 review.AbstractStatusWithdrawn,
1615 review.AbstractStatusDuplicated,
1616 review.AbstractStatusMerged):
1617 label = AbstractStatusList.getInstance(
1618 ).getCaption(statusKlass)
1619 errorList.append(_("ABSTRACT TO BE MERGED %s is in status which does not allow to merge (%s)") % (abst.getId(), label.upper()))
1620 self._abstracts.append(abst)
1621 if self._targetAbsId == "":
1622 errorList.append(_("Invalid TARGET ABSTRACT ID"))
1623 else:
1624 if self._targetAbsId in self._abstractIds:
1625 errorList.append(_("TARGET ABSTRACT ID is among the ABSTRACT IDs TO BE MERGED"))
1626 self._targetAbs = absMgr.getAbstractById(self._targetAbsId)
1627 if self._targetAbs is None:
1628 errorList.append(_("Invalid TARGET ABSTRACT ID"))
1629 else:
1630 statusKlass = self._targetAbs.getCurrentStatus().__class__
1631 if statusKlass in (review.AbstractStatusAccepted,
1632 review.AbstractStatusRejected,
1633 review.AbstractStatusWithdrawn,
1634 review.AbstractStatusMerged,
1635 review.AbstractStatusDuplicated):
1636 label = AbstractStatusList.getInstance(
1637 ).getInstance().getCaption(statusKlass)
1638 errorList.append(_("TARGET ABSTRACT is in status which does not allow to merge (%s)") % label.upper())
1639 if len(errorList) == 0:
1640 for abs in self._abstracts:
1641 abs.mergeInto(self._getUser(), self._targetAbs,
1642 mergeAuthors=self._inclAuthors, comments=self._comments)
1643 if self._doNotify:
1644 abs.notify(EmailNotificator(), self._getUser())
1645 return self._redirect(urlHandlers.UHAbstractManagment.getURL(self._targetAbs))
1646 p = conferences.WPModMergeAbstracts(self, self._target)
1647 return p.display(absIdList=self._abstractIds,
1648 targetAbsId=self._targetAbsId,
1649 inclAuth=self._inclAuthors,
1650 comments=self._comments,
1651 errorMsgList=errorList,
1652 notify=self._doNotify)
1655 #Base class for multi abstract management
1656 class RHAbstractManagmentMultiple( RHConferenceModifBase ):
1658 def _checkParams( self, params ):
1659 RHConferenceModifBase._checkParams(self, params)
1660 abstractIds = params.get("abstracts",[])
1661 abMgr = self._conf.getAbstractMgr()
1662 self._abstracts = []
1663 #if single abstract id is sent it's not a list so it shouldn't be iterated
1664 if isinstance(abstractIds, types.ListType):
1665 for id in abstractIds:
1666 self._abstracts.append(abMgr.getAbstractById(id))
1667 else:
1668 self._abstracts.append(abMgr.getAbstractById(abstractIds))
1669 self._warningShown=params.has_key("confirm")
1670 self._comments = params.get("comments", "")
1671 self._doNotify=params.has_key("notify")
1673 #checks if notification email template is defined for all selected abstracts
1674 #returns List of abstracts which doesn't have required template
1675 def _checkNotificationTemplate(self, statusKlass):
1676 from MaKaC.webinterface.rh.abstractModif import _AbstractWrapper
1678 if statusKlass == review.AbstractStatusAccepted:
1679 cType=self._conf.getContribTypeById(self._typeId)
1681 abstractsWithMissingTemplate = []
1682 for abstract in self._abstracts:
1683 if statusKlass == review.AbstractStatusAccepted:
1684 status=statusKlass(abstract,None,self._track,cType)
1685 elif statusKlass == review.AbstractStatusRejected:
1686 status=statusKlass(abstract,None, None)
1687 else: # In case we pass an improper Status
1688 abstractsWithMissingTemplate.append(abstract)
1689 continue
1690 wrapper=_AbstractWrapper(status)
1691 if abstract.getOwner().getNotifTplForAbstract(wrapper) is None:
1692 abstractsWithMissingTemplate.append(abstract)
1693 return abstractsWithMissingTemplate
1695 #checks the status of selected abstracts
1696 #returns list of abstracts with improper status
1697 def _checkStatus(self):
1698 improperAbstracts = []
1699 for abstract in self._abstracts:
1700 status = abstract.getCurrentStatus()
1701 if not isinstance(status, AbstractStatusSubmitted) and \
1702 not isinstance(status, AbstractStatusProposedToAccept) and \
1703 not isinstance(status, AbstractStatusProposedToReject):
1704 improperAbstracts.append(abstract)
1705 return improperAbstracts
1708 class RHAbstractManagmentAcceptMultiple( RHAbstractManagmentMultiple ):
1710 def _checkParams( self, params ):
1711 RHAbstractManagmentMultiple._checkParams(self, params)
1712 self._accept = params.get("accept", None)
1713 self._track=self._conf.getTrackById(params.get("track", ""))
1714 self._session=self._conf.getSessionById(params.get("session", ""))
1715 self._typeId = params.get("type", "")
1717 def _process( self ):
1718 if self._abstracts != []:
1719 improperAbstracts = self._checkStatus()
1720 if improperAbstracts == []:
1721 if self._accept:
1722 improperTemplates = self._checkNotificationTemplate(review.AbstractStatusAccepted)
1723 if self._doNotify and not self._warningShown and improperTemplates != []:
1724 raise FormValuesError("""The abstracts with the following IDs can not be automatically
1725 notified: %s. Therefore, none of your request has been processed;
1726 go back, uncheck the relevant abstracts and try again."""%(", ".join(map(lambda x:x.getId(),improperTemplates))))
1727 cType=self._conf.getContribTypeById(self._typeId)
1728 for abstract in self._abstracts:
1729 abstract.accept(self._getUser(),self._track,cType,self._comments,self._session)
1730 if self._doNotify:
1731 n=EmailNotificator()
1732 abstract.notify(n,self._getUser())
1733 self._redirect(urlHandlers.UHConfAbstractManagment.getURL(self._conf))
1734 else:
1735 p = abstracts.WPAbstractManagmentAcceptMultiple( self, self._abstracts )
1736 return p.display( **self._getRequestParams() )
1737 else:
1738 raise FormValuesError("""The abstracts with the following IDs cannot be accepted because of their
1739 current status: %s. Therefore, none of your request has been processed;
1740 go back, uncheck the relevant abstracts and try again."""%(", ".join(map(lambda x:x.getId(),improperAbstracts))))
1741 else:
1742 raise FormValuesError("No abstracts selected")
1745 class RHAbstractManagmentRejectMultiple( RHAbstractManagmentMultiple ):
1747 def _checkParams( self, params ):
1748 RHAbstractManagmentMultiple._checkParams(self, params)
1749 self._reject = params.get("reject", None)
1750 self._comments = params.get("comments", "")
1751 self._doNotify=params.has_key("notify")
1752 self._warningShown=params.has_key("confirm")
1754 def _process( self ):
1755 if self._abstracts != []:
1756 improperAbstracts = self._checkStatus()
1757 if improperAbstracts == []:
1758 if self._reject:
1759 improperTemplates = self._checkNotificationTemplate(review.AbstractStatusRejected)
1760 if self._doNotify and not self._warningShown and improperTemplates != []:
1761 raise FormValuesError("""The abstracts with the following IDs can not be automatically
1762 notified: %s. Therefore, none of your request has been processed;
1763 go back, uncheck the relevant abstracts and try again."""%(", ".join(map(lambda x:x.getId(),improperTemplates))))
1764 for abstract in self._abstracts:
1765 abstract.reject(self._getUser(), self._comments)
1766 if self._doNotify:
1767 n=EmailNotificator()
1768 abstract.notify(n,self._getUser())
1769 self._redirect(urlHandlers.UHConfAbstractManagment.getURL(self._conf))
1770 else:
1771 p = abstracts.WPAbstractManagmentRejectMultiple( self, self._abstracts )
1772 return p.display( **self._getRequestParams() )
1773 else:
1774 raise FormValuesError("""The abstracts with the following IDs cannot be rejected because of their
1775 current status: %s. Therefore, none of your request has been processed;
1776 go back, uncheck the relevant abstracts and try again."""%(", ".join(map(lambda x:x.getId(),improperAbstracts))))
1777 else:
1778 raise FormValuesError("No abstracts selected")
1780 class RHAbstractSendNotificationMail(RHConfModifCFABase):
1782 def _checkParams( self, params ):
1783 RHConfModifCFABase._checkParams( self, params )
1784 notifTplId = params.get("notifTpl", "")
1785 self._notifTpl = self._conf.getAbstractMgr().getNotificationTplById(notifTplId)
1786 self._abstractIds = normaliseListParam( params.get("abstracts", []) )
1787 self._abstracts = []
1788 abMgr = self._conf.getAbstractMgr()
1789 for id in self._abstractIds:
1790 self._abstracts.append(abMgr.getAbstractById(id))
1792 def _process( self ):
1793 p = conferences.WPAbstractSendNotificationMail(self, self._conf, count )
1794 return p.display()
1797 class RHAbstractsToPDF(RHConfModifCFABase):
1799 def _checkParams( self, params ):
1800 RHConfModifCFABase._checkParams( self, params )
1801 self._abstractIds = normaliseListParam( params.get("abstracts", []) )
1803 def _process(self):
1804 tz = self._conf.getTimezone()
1805 if not self._abstractIds:
1806 return _("No abstract to print")
1808 pdf = ConfManagerAbstractsToPDF(self._conf, self._abstractIds, tz=tz)
1809 return send_file('Abstracts.pdf', pdf.generate(), 'PDF')
1812 class RHAbstractsToXML(RHConfModifCFABase):
1814 def _checkParams( self, params ):
1815 RHConfModifCFABase._checkParams( self, params )
1816 self._abstractIds = normaliseListParam( params.get("abstracts", []) )
1817 self._abstracts = []
1818 abMgr = self._conf.getAbstractMgr()
1819 for id in self._abstractIds:
1820 #if abMgr.getAbstractById(id).canView( self._aw ):
1821 self._abstracts.append(abMgr.getAbstractById(id))
1823 def _process(self):
1824 x = XMLGen()
1826 x.openTag("AbstractBook")
1827 x.writeTag("Conference", self._target.getConference().getTitle())
1828 for abstract in self._abstracts:
1829 x.openTag("abstract")
1830 x.writeTag("Id", abstract.getId())
1831 x.writeTag("Title", abstract.getTitle())
1832 x.writeTag("Content", abstract.getField("content"))
1833 for f in self._conf.getAbstractMgr().getAbstractFieldsMgr().getFields():
1834 id = f.getId()
1835 x.writeTag("field",abstract.getField(id),[("id",id)])
1836 l = []
1837 for au in abstract.getAuthorList():
1838 if abstract.isPrimaryAuthor(au):
1839 x.openTag("PrimaryAuthor")
1840 x.writeTag("FirstName", au.getFirstName())
1841 x.writeTag("FamilyName", au.getSurName())
1842 x.writeTag("Email", au.getEmail())
1843 x.writeTag("Affiliation", au.getAffiliation())
1844 x.closeTag("PrimaryAuthor")
1845 else:
1846 l.append(au)
1848 for au in l:
1849 x.openTag("Co-Author")
1850 x.writeTag("FirstName", au.getFirstName())
1851 x.writeTag("FamilyName", au.getSurName())
1852 x.writeTag("Email", au.getEmail())
1853 x.writeTag("Affiliation", au.getAffiliation())
1854 x.closeTag("Co-Author")
1856 for au in abstract.getSpeakerList():
1857 x.openTag("Speaker")
1858 x.writeTag("FirstName", au.getFirstName ())
1859 x.writeTag("FamilyName", au.getSurName())
1860 x.writeTag("Email", au.getEmail())
1861 x.writeTag("Affiliation", au.getAffiliation())
1862 x.closeTag("Speaker")
1864 #To change for the new contribution type system to:
1865 #x.writeTag("ContributionType", abstract.getContribType().getName())
1866 if abstract.getContribType() <> None:
1867 x.writeTag("ContributionType", abstract.getContribType().getName())
1868 else:
1869 x.writeTag("ContributionType", None)
1870 #x.writeTag("ContributionType", abstract.getContribType())
1872 for t in abstract.getTrackList():
1873 x.writeTag("Track", t.getTitle())
1875 x.closeTag("abstract")
1877 x.closeTag("AbstractBook")
1879 return send_file('Abstracts.xml', StringIO(x.getXml()), 'XML')
1882 #-------------------------------------------------------------------------------------
1884 class RHAbstractsListToExcel(RHConfModifCFABase):
1886 def _checkParams( self, params ):
1887 RHConfModifCFABase._checkParams( self, params )
1888 self._abstracts = normaliseListParam( params.get("abstracts", []) )
1889 self._display = self._normaliseListParam(params.get("disp",[]))
1891 def _process( self ):
1892 abstractList = []
1893 for abs_id in self._abstracts :
1894 abstractList.append(self._conf.getAbstractMgr().getAbstractById(abs_id))
1896 generator = AbstractListToExcel(self._conf,abstractList, self._display)
1897 return send_file('AbstractList.csv', StringIO(generator.getExcelFile()), 'CSV')
1900 #-------------------------------------------------------------------------------------
1902 class RHConfModifDisplayCustomization( RHConferenceModifBase ):
1903 _uh = urlHandlers.UHConfModifDisplayCustomization
1905 def _checkParams( self, params ):
1906 RHConferenceModifBase._checkParams( self, params )
1908 def _process( self ):
1909 p = conferences.WPConfModifDisplayCustomization(self, self._target)
1910 return p.display()
1912 class RHConfModifDisplayMenu( RHConferenceModifBase ):
1913 _uh = urlHandlers.UHConfModifDisplayMenu
1915 def _checkParams( self, params ):
1916 RHConferenceModifBase._checkParams( self, params )
1917 self._linkId = params.get("linkId", "")
1919 def _process( self ):
1920 p = conferences.WPConfModifDisplayMenu(self, self._target, self._linkId)
1921 return p.display()
1923 class RHConfModifDisplayResources( RHConferenceModifBase ):
1924 _uh = urlHandlers.UHConfModifDisplayResources
1926 def _checkParams( self, params ):
1927 RHConferenceModifBase._checkParams( self, params )
1929 def _process( self ):
1930 p = conferences.WPConfModifDisplayResources(self, self._target)
1931 return p.display()
1933 class RHConfModifDisplayConfHeader( RHConferenceModifBase ):
1934 _uh = urlHandlers.UHConfModifDisplayConfHeader
1936 def _checkParams( self, params ):
1937 RHConferenceModifBase._checkParams( self, params )
1938 self._optionalParams={}
1939 if params.has_key("modifiedText"):
1940 self._optionalParams["modifiedText"]=params.has_key("modifiedText")
1942 def _process( self ):
1943 p = conferences.WPConfModifDisplayConfHeader(self, self._target, optionalParams=self._optionalParams )
1944 return p.display()
1946 class RHConfModifDisplayAddLink( RHConferenceModifBase ):
1947 _uh = urlHandlers.UHConfModifDisplayAddLink
1949 def _checkParams( self, params ):
1950 RHConferenceModifBase._checkParams( self, params )
1951 self._linkId = params.get("linkId", "")
1952 self._cancel = params.get("cancel", "")
1953 self._submit = params.get("submit", "")
1954 self._params = params
1956 def _process( self ):
1957 if self._cancel:
1958 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
1959 target = menu
1960 if self._linkId:
1961 target = menu.getLinkById(self._linkId)
1962 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(target))
1963 elif self._submit:
1964 #create the link
1965 name = self._params.get("name", "[empty name]")
1966 if name.strip()=="":
1967 name="[empty name]"
1968 url = self._params.get("URL", "")
1969 displayTarget = self._params.get("displayTarget", "_blank")
1970 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
1971 target = menu
1972 if self._linkId:
1973 target = menu.getLinkById(self._linkId)
1974 link = displayMgr.ExternLink(name, url)
1975 link.setCaption(name)
1976 link.setDisplayTarget(displayTarget)
1977 target.addLink(link)
1978 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(link))
1979 else:
1980 p = conferences.WPConfModifDisplayAddLink(self, self._target, self._linkId )
1981 return p.display()
1984 class RHConfModifDisplayAddPage( RHConferenceModifBase ):
1985 _uh = urlHandlers.UHConfModifDisplayAddLink
1987 def _checkParams( self, params ):
1988 RHConferenceModifBase._checkParams( self, params )
1989 self._linkId = params.get("linkId", "")
1990 self._cancel = params.get("cancel", "")
1991 self._submit = params.get("submit", "")
1992 self._params = params
1994 def _process( self ):
1995 if self._cancel:
1996 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
1997 target = menu
1998 if self._linkId:
1999 target = menu.getLinkById(self._linkId)
2000 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(target))
2001 elif self._submit:
2002 #create the page
2003 intPagesMgr=internalPagesMgr.InternalPagesMgrRegistery().getInternalPagesMgr(self._conf)
2004 intPage=internalPagesMgr.InternalPage(self._conf)
2005 intPage.setTitle(self._params.get("title","[no title]"))
2006 intPage.setContent(self._params.get("content",""))
2007 intPagesMgr.addPage(intPage)
2008 #create the link
2009 name = self._params.get("name", "[empty name]")
2010 if name.strip()=="":
2011 name="[empty name]"
2012 content = self._params.get("content", "")
2013 displayTarget = self._params.get("displayTarget", "_blank")
2014 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2015 target = menu
2016 if self._linkId:
2017 target = menu.getLinkById(self._linkId)
2018 link = displayMgr.PageLink(name, intPage)
2019 link.setCaption(name)
2020 link.setDisplayTarget(displayTarget)
2021 target.addLink(link)
2022 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(link))
2023 else:
2024 p = conferences.WPConfModifDisplayAddPage(self, self._target, self._linkId )
2025 return p.display()
2027 class RHConfModifDisplayAddSpacer( RHConferenceModifBase ):
2028 _uh = urlHandlers.UHConfModifDisplayAddSpacer
2031 def _process( self ):
2032 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2033 spacer = displayMgr.Spacer()
2034 menu.addLink(spacer)
2035 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(spacer))
2038 class RHConfModifDisplayRemoveLink( RHConferenceModifBase ):
2039 _uh = urlHandlers.UHConfModifDisplayRemoveLink
2041 def _checkParams( self, params ):
2042 RHConferenceModifBase._checkParams( self, params )
2043 self._linkId = params.get("linkId", "")
2044 self._cancel = params.get("cancel", "")
2045 self._confirm = params.get("confirm", "")
2048 def _process( self ):
2049 if self._cancel:
2050 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2051 link = menu.getLinkById(self._linkId)
2052 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(link))
2053 elif self._confirm:
2054 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2055 link = menu.getLinkById(self._linkId)
2056 if isinstance(link, displayMgr.SystemLink):
2057 raise MaKaCError( _("You cannot remove a system link"))
2058 parent = link.getParent()
2059 if link.getType() == "page":
2060 page = link.getPage()
2061 internalPagesMgr.InternalPagesMgrRegistery().getInternalPagesMgr(self._conf).removePage(page)
2062 parent.removeLink(link)
2063 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(self._target))
2064 else:
2065 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2066 link = menu.getLinkById(self._linkId)
2067 if link is None:
2068 raise NotFoundError( _("The link you are trying to delete no longer exists"))
2069 if isinstance(link, displayMgr.SystemLink):
2070 raise MaKaCError( _("You cannot remove a system link"))
2071 p = conferences.WPConfModifDisplayRemoveLink(self, self._target, link )
2072 return p.display()
2075 class RHConfModifDisplayToggleLinkStatus( RHConferenceModifBase ):
2076 _uh = urlHandlers.UHConfModifDisplayToggleLinkStatus
2078 def _checkParams( self, params ):
2079 RHConferenceModifBase._checkParams( self, params )
2080 self._linkId = params.get("linkId", "")
2083 def _process( self ):
2084 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2085 link=menu.getLinkById(self._linkId)
2086 if link.isEnabled():
2087 link.disable()
2088 else:
2089 link.enable()
2090 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(link))
2093 class RHConfModifDisplayToggleHomePage( RHConferenceModifBase ):
2094 _uh = urlHandlers.UHConfModifDisplayToggleHomePage
2096 def _checkParams( self, params ):
2097 RHConferenceModifBase._checkParams( self, params )
2098 self._linkId = params.get("linkId", "")
2101 def _process( self ):
2102 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2103 link=menu.getLinkById(self._linkId)
2104 if link.getPage().isHome():
2105 link.getPage().setHome(False)
2106 else:
2107 for page in internalPagesMgr.InternalPagesMgrRegistery().getInternalPagesMgr(self._conf).getPagesList():
2108 page.setHome(False)
2109 link.getPage().setHome(True)
2110 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(link))
2113 class RHConfModifDisplayUpLink( RHConferenceModifBase ):
2114 _uh = urlHandlers.UHConfModifDisplayUpLink
2116 def _checkParams( self, params ):
2117 RHConferenceModifBase._checkParams( self, params )
2118 self._linkId = params.get("linkId", "")
2121 def _process( self ):
2122 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2123 link = menu.getLinkById(self._linkId)
2124 parent = link.getParent()
2125 parent.upLink(link)
2126 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(link))
2129 class RHConfModifDisplayDownLink( RHConferenceModifBase ):
2130 _uh = urlHandlers.UHConfModifDisplayDownLink
2132 def _checkParams( self, params ):
2133 RHConferenceModifBase._checkParams( self, params )
2134 self._linkId = params.get("linkId", "")
2137 def _process( self ):
2138 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2139 link = menu.getLinkById(self._linkId)
2140 parent = link.getParent()
2141 parent.downLink(link)
2142 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(link))
2145 class RHConfModifDisplayToggleTimetableView(RHConferenceModifBase):
2146 _uh = urlHandlers.UHConfModifDisplayToggleTimetableView
2148 def _checkParams(self, params):
2149 RHConferenceModifBase._checkParams(self, params)
2150 self._linkId = params.get("linkId", "")
2152 def _process(self):
2153 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2154 link = menu.getLinkById(self._linkId)
2155 menu.set_timetable_detailed_view(not menu.is_timetable_detailed_view())
2156 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(link))
2159 class RHConfModifDisplayToggleTTDefaultLayout(RHConferenceModifBase):
2160 _uh = urlHandlers.UHConfModifDisplayToggleTTDefaultLayout
2162 def _checkParams(self, params):
2163 RHConferenceModifBase._checkParams(self, params)
2164 self._linkId = params.get("linkId", "")
2166 def _process(self):
2167 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2168 link = menu.getLinkById(self._linkId)
2169 menu.toggle_timetable_layout()
2170 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(link))
2173 class RHConfModifDisplayModifyData(RHConferenceModifBase):
2174 _uh = urlHandlers.UHConfModifDisplayRemoveLink
2176 def _checkParams(self, params):
2177 RHConferenceModifBase._checkParams(self, params)
2178 self._linkId = params.get("linkId", "")
2179 self._cancel = params.get("cancel", "")
2180 self._confirm = params.get("confirm", "")
2181 self._params = params
2183 def _process(self):
2185 if self._cancel:
2186 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2187 link = menu.getLinkById(self._linkId)
2188 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(link))
2189 elif self._confirm:
2190 #create the link
2191 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2192 link = menu.getLinkById(self._linkId)
2193 if isinstance(link, displayMgr.SystemLink):
2194 raise MaKaCError( _("You cannot modify a system link"))
2195 name=self._params.get("name","[empty name]")
2196 if name.strip()=="":
2197 name="[empty name]"
2198 link.setCaption(name)
2199 if isinstance(link, displayMgr.ExternLink):
2200 link.setURL(self._params["url"])
2201 elif isinstance(link, displayMgr.PageLink):
2202 link.getPage().setContent(self._params.get("content",""))
2203 link.setDisplayTarget(self._params.get("displayTarget", "_blank"))
2204 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(link))
2205 else:
2206 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2207 link = menu.getLinkById(self._linkId)
2208 if isinstance(link, displayMgr.SystemLink):
2209 raise MaKaCError( _("You cannot modify a system link"))
2210 if isinstance(link, displayMgr.ExternLink):
2211 p = conferences.WPConfModifDisplayModifyData(self, self._target, link )
2212 else:
2213 p = conferences.WPConfModifDisplayModifyPage(self, self._target, link )
2214 return p.display()
2216 class RHConfModifDisplayModifySystemData( RHConferenceModifBase ):
2217 _uh = urlHandlers.UHConfModifDisplayRemoveLink
2219 def _checkParams( self, params ):
2220 RHConferenceModifBase._checkParams( self, params )
2221 self._linkId = params.get("linkId", "")
2222 self._cancel = params.get("cancel", "")
2223 self._confirm = params.get("confirm", "")
2224 self._params = params
2226 def _process( self ):
2228 if self._cancel:
2229 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2230 link = menu.getLinkById(self._linkId)
2231 elif self._confirm:
2232 #create the link
2233 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2234 link = menu.getLinkById(self._linkId)
2235 if isinstance(link, displayMgr.SystemLink):
2236 name=self._params.get("name","[empty name]")
2237 if name.strip()=="":
2238 name="[empty name]"
2239 link.setCaption(name)
2240 else:
2241 menu = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getMenu()
2242 link = menu.getLinkById(self._linkId)
2243 if isinstance(link, displayMgr.SystemLink):
2244 p = conferences.WPConfModifDisplayModifySystemData(self, self._target, link )
2245 return p.display()
2246 self._redirect(urlHandlers.UHConfModifDisplayMenu.getURL(link))
2248 class RHConfModifFormatTitleColorBase( RHConferenceModifBase ):
2250 def _checkParams( self, params ):
2251 RHConferenceModifBase._checkParams( self, params )
2252 self._linkId = params.get("linkId", "")
2253 self._formatOption = params.get("formatOption", "")
2254 self._colorCode = params.get("colorCode", "")
2255 self._apply = params.has_key( "apply" )
2256 self._remove = params.has_key( "remove" )
2258 def _process( self ):
2259 format = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getFormat()
2260 if self._formatOption:
2261 if self._apply:
2262 format.setColorCode(self._formatOption, "#" + self._colorCode)
2263 elif self._remove:
2264 format.clearColorCode(self._formatOption)
2265 redirecturl = urlHandlers.UHConfModifDisplayCustomization.getURL(self._conf)
2266 redirecturl.addParam("formatOption", self._formatOption)
2267 self._redirect("%s#colors"%redirecturl)
2269 class RHConfModifFormatTitleBgColor( RHConfModifFormatTitleColorBase ):
2270 _uh = urlHandlers.UHConfModifFormatTitleBgColor
2272 class RHConfModifFormatTitleTextColor( RHConfModifFormatTitleColorBase ):
2273 _uh = urlHandlers.UHConfModifFormatTitleBgColor
2275 class RHConfSaveLogo( RHConferenceModifBase ):
2277 def _getNewTempFile( self ):
2278 cfg = Config.getInstance()
2279 tempPath = cfg.getUploadedFilesTempDir()
2280 tempFileName = tempfile.mkstemp( suffix="IndicoLogo.tmp", dir = tempPath )[1]
2281 return tempFileName
2283 def _saveFileToTemp(self, fs):
2284 fileName = self._getNewTempFile()
2285 fs.save(fileName)
2286 return fileName
2288 def _checkParams( self, params ):
2289 RHConferenceModifBase._checkParams( self, params )
2290 if not hasattr(self,"_filePath"):
2291 self._filePath = self._saveFileToTemp(params["file"])
2292 self._tempFilesToDelete.append(self._filePath)
2293 self._fileName = params["file"].filename
2296 def _process( self ):
2297 f = conference.LocalFile()
2298 f.setName( "Logo" )
2299 f.setDescription( "This is the logo for the conference" )
2300 f.setFileName( self._fileName )
2301 f.setFilePath( self._filePath )
2302 self._conf.setLogo( f )
2303 self._redirect( "%s#logo"%urlHandlers.UHConfModifDisplayCustomization.getURL( self._conf ) )
2306 class RHConfRemoveLogo( RHConferenceModifBase ):
2308 def _checkParams( self, params ):
2309 RHConferenceModifBase._checkParams( self, params )
2311 def _process( self ):
2312 self._conf.removeLogo()
2313 self._redirect( "%s#logo"%urlHandlers.UHConfModifDisplayCustomization.getURL( self._conf ) )
2315 class RHConfSaveCSS( RHConferenceModifBase ):
2317 def _getNewTempFile( self ):
2318 cfg = Config.getInstance()
2319 tempPath = cfg.getUploadedFilesTempDir()
2320 tempFileName = tempfile.mkstemp( suffix="IndicoCSS.tmp", dir = tempPath )[1]
2321 return tempFileName
2323 def _saveFileToTemp(self, fs):
2324 fileName = self._getNewTempFile()
2325 fs.save(fileName)
2326 return fileName
2328 def _checkParams( self, params ):
2329 RHConferenceModifBase._checkParams( self, params )
2330 self._params = params
2331 if self._params.has_key("FP"):
2332 self._filePath = self._params["FP"]
2333 self._fileName = "TemplateInUse"
2334 else:
2335 if not hasattr(self,"_filePath"):
2336 self._filePath = self._saveFileToTemp(params["file"])
2337 self._tempFilesToDelete.append(self._filePath)
2338 self._fileName = params["file"].filename
2339 if self._fileName.strip() == "":
2340 raise FormValuesError(_("Please, choose the file to upload first"))
2342 def _process( self ):
2343 f = conference.LocalFile()
2344 f.setName( "CSS" )
2345 f.setDescription( "This is the css for the conference" )
2346 f.setFileName( self._fileName )
2347 f.setFilePath( self._filePath )
2348 sm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getStyleManager()
2349 sm.setCSS( f )
2350 self._redirect( "%s#css"%urlHandlers.UHConfModifDisplayCustomization.getURL( self._conf ) )
2353 class RHConfRemoveCSS( RHConferenceModifBase ):
2355 def _checkParams( self, params ):
2356 RHConferenceModifBase._checkParams( self, params )
2358 def _process( self ):
2359 sm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getStyleManager()
2360 sm.removeCSS()
2361 # Since this function makes sure no template is used make sure that
2362 # one of the standard ones is not used
2363 sm.useLocalCSS()
2364 self._redirect( "%s#css"%urlHandlers.UHConfModifDisplayCustomization.getURL( self._conf ) )
2367 class RHConfModifPreviewCSS(RHConferenceModifBase):
2369 def _checkParams( self, params ):
2370 RHConferenceModifBase._checkParams( self, params )
2371 self._params = params
2373 def _process( self ):
2374 # Call a webpage that will handle the task
2375 CSS_Temp_Id = self._params.get("cssId", "")
2376 p = conferences.WPConfModifPreviewCSS(self, self._conf, CSS_Temp_Id)
2377 return p.display()
2380 class RHConfUseCSS( RHConferenceModifBase ):
2382 def _checkParams( self, params ):
2383 RHConferenceModifBase._checkParams( self, params )
2384 self._params = params
2385 self._selectedTpl = self._params.get("selectedTpl")
2387 def _process( self ):
2388 styleMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getStyleManager()
2389 if self._selectedTpl == "css":
2390 styleMgr.useLocalCSS()
2391 elif self._selectedTpl:
2392 styleMgr.setCSS(self._selectedTpl)
2393 self._redirect( "%s#css"%urlHandlers.UHConfModifDisplayCustomization.getURL( self._conf ) )
2395 class RHConfSavePic( RHConferenceModifBase ):
2397 def __init__(self):
2398 RHConferenceModifBase.__init__(self)
2399 self._tempFiles = {}
2401 def _getNewTempFile( self ):
2402 cfg = Config.getInstance()
2403 tempPath = cfg.getUploadedFilesTempDir()
2404 tempFileName = tempfile.mkstemp( suffix="IndicoPic.tmp", dir = tempPath )[1]
2405 return tempFileName
2407 def _saveFileToTemp(self, fs):
2408 if fs not in self._tempFiles:
2409 fileName = self._getNewTempFile()
2410 fs.save(fileName)
2411 self._tempFiles[fs] = fileName
2412 return self._tempFiles[fs]
2414 def _checkParams( self, params ):
2415 RHConferenceModifBase._checkParams( self, params )
2416 self._filePath = self._saveFileToTemp(params["file"])
2417 self._tempFilesToDelete.append(self._filePath)
2418 self._fileName = params["file"].filename
2419 self._params = params
2422 def _process( self ):
2423 if self._fileName == "":
2424 return json.dumps({'status': "ERROR", 'info': {'message':_("No file has been attached")}})
2425 f = conference.LocalFile()
2426 f.setFileName( self._fileName )
2427 f.setFilePath( self._filePath )
2428 im = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf).getImagesManager()
2429 pic = im.addPic( f )
2430 info={"name": f.getFileName(),
2431 "id": f.getId(),
2432 "picURL": str(urlHandlers.UHConferencePic.getURL(pic))}
2433 return json.dumps({'status': "OK", 'info': info}, textarea=True)
2435 class RHConfModifTickerTapeAction( RHConferenceModifBase ):
2437 def _checkParams( self, params ):
2438 RHConferenceModifBase._checkParams( self, params )
2439 dm = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf)
2440 self._tickerTape=dm.getTickerTape()
2441 self._status=params.has_key("ttStatus")
2442 self._saveText=params.has_key("savettText")
2443 self._text=params.get("ttText","")
2444 self._simpleTextEnabled=params.has_key("simpleText")
2445 self._nowHappeningEnabled=params.has_key("nowHappening")
2447 def _process( self ):
2448 url=urlHandlers.UHConfModifDisplayConfHeader.getURL( self._conf )
2449 if self._status:
2450 self._tickerTape.setActive(not self._tickerTape.isActive())
2451 if self._saveText:
2452 self._tickerTape.setText(self._text)
2453 url.addParam("modifiedText", "True")
2454 if self._nowHappeningEnabled:
2455 self._tickerTape.setNowHappeningEnabled(not self._tickerTape.isNowHappeningEnabled())
2456 if self._simpleTextEnabled:
2457 self._tickerTape.setSimpleTextEnabled(not self._tickerTape.isSimpleTextEnabled())
2458 self._redirect( "%s#tickertape"%url )
2460 class RHConfModifToggleSearch( RHConferenceModifBase ):
2462 def _checkParams( self, params ):
2463 RHConferenceModifBase._checkParams( self, params )
2464 self._displayMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf)
2465 self._searchEnabled=self._displayMgr.getSearchEnabled()
2467 def _process( self ):
2468 url=urlHandlers.UHConfModifDisplayConfHeader.getURL( self._conf )
2469 self._displayMgr.setSearchEnabled(not self._searchEnabled)
2470 self._redirect( "%s#headerFeatures"%url )
2473 class RHConfModifToggleNavigationBar( RHConferenceModifBase ):
2475 def _checkParams( self, params ):
2476 RHConferenceModifBase._checkParams( self, params )
2477 self._displayMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(self._conf)
2478 self._navigationBarEnabled=self._displayMgr.getDisplayNavigationBar()
2480 def _process( self ):
2481 url=urlHandlers.UHConfModifDisplayConfHeader.getURL( self._conf )
2482 self._displayMgr.setDisplayNavigationBar(not self._navigationBarEnabled)
2483 self._redirect( "%s#headerFeatures"%url )
2485 class RHConfAddContribType(RHConferenceModifBase):
2486 _uh = urlHandlers.UHConfAddContribType
2488 def _checkParams(self, params):
2489 RHConferenceModifBase._checkParams(self, params)
2490 self._typeName = params.get("ctName", "")
2491 self._typeDescription = params.get("ctDescription", "")
2492 self._typeId = params.get("typeId", "")
2493 self._cancel = params.get("cancel", "")
2494 self._save = params.get("save", "")
2496 def _process( self ):
2497 if self._cancel:
2498 self._redirect(urlHandlers.UHConferenceModification.getURL(self._conf))
2499 elif self._save:
2500 ct = self._conf.newContribType(self._typeName, self._typeDescription)
2502 # Filtering criteria: by default make new contribution type checked
2503 filters = session.setdefault('ContributionFilterConf%s' % self._conf.getId(), {})
2504 if 'types' in filters:
2505 #Append the new type to the existing list
2506 newDict = filters['types'][:]
2507 newDict.append(ct.getId())
2508 filters['types'] = newDict[:]
2509 else:
2510 #Create a new entry for the dictionary containing the new type
2511 filters['types'] = [ct.getId()]
2512 session.modified = True
2514 self._redirect(urlHandlers.UHConferenceModification.getURL(self._conf))
2515 else:
2516 p = conferences.WPConfAddContribType(self, self._target )
2517 return p.display()
2520 class RHConfRemoveContribType(RHConferenceModifBase):
2521 _uh = urlHandlers.UHConfRemoveContribType
2523 def _checkParams(self, params):
2524 RHConferenceModifBase._checkParams(self, params)
2525 selTypeId = self._normaliseListParam( params.get( "types", [] ) )
2526 self._contribTypes = []
2527 for id in selTypeId:
2528 self._contribTypes.append(self._conf.getContribTypeById(id))
2531 def _process(self):
2532 for ct in self._contribTypes:
2533 self._conf.removeContribType(ct)
2534 self._redirect(urlHandlers.UHConferenceModification.getURL(self._conf))
2537 class RHConfContribTypeBase(RHConferenceModifBase):
2539 def _checkParams(self, params):
2540 RHConferenceModifBase._checkParams(self, params)
2541 l = locators.WebLocator()
2542 l.setContribType( params )
2543 self._contribType = self._target = l.getObject()
2546 class RHConfEditContribType(RHConfContribTypeBase):
2548 def _checkParams(self, params):
2549 RHConfContribTypeBase._checkParams(self, params)
2550 self._save = params.get("save", "")
2551 self._name = params.get("ctName", "")
2552 self._cancel = params.get("cancel", "")
2553 self._description = params.get("ctDescription", "")
2555 def _process(self):
2556 if self._cancel:
2557 self._redirect(urlHandlers.UHConferenceModification.getURL(self._conf))
2558 elif self._save:
2559 self._target.setName(self._name)
2560 self._target.setDescription(self._description)
2561 self._redirect(urlHandlers.UHConferenceModification.getURL(self._conf))
2562 else:
2563 p = conferences.WPConfEditContribType(self, self._target )
2564 return p.display()
2567 class ContribFilterCrit(filters.FilterCriteria):
2568 _availableFields = { \
2569 contribFilters.TypeFilterField.getId():contribFilters.TypeFilterField, \
2570 contribFilters.StatusFilterField.getId():contribFilters.StatusFilterField, \
2571 contribFilters.TrackFilterField.getId():contribFilters.TrackFilterField, \
2572 contribFilters.MaterialFilterField.getId():contribFilters.MaterialFilterField, \
2573 contribFilters.SessionFilterField.getId():contribFilters.SessionFilterField }
2576 class ContribSortingCrit(filters.SortingCriteria):
2577 _availableFields = {
2578 contribFilters.NumberSF.getId():contribFilters.NumberSF,
2579 contribFilters.DateSF.getId():contribFilters.DateSF,
2580 contribFilters.ContribTypeSF.getId():contribFilters.ContribTypeSF,
2581 contribFilters.TrackSF.getId():contribFilters.TrackSF,
2582 contribFilters.SpeakerSF.getId():contribFilters.SpeakerSF,
2583 contribFilters.BoardNumberSF.getId():contribFilters.BoardNumberSF,
2584 contribFilters.SessionSF.getId():contribFilters.SessionSF,
2585 contribFilters.TitleSF.getId():contribFilters.TitleSF
2589 class RHContributionListBase(RHConferenceModifBase):
2591 def _checkProtection(self):
2592 from MaKaC.webinterface.rh.reviewingModif import RCPaperReviewManager
2593 if not RCPaperReviewManager.hasRights(self):
2594 RHConferenceModifBase._checkProtection(self)
2597 class RHContributionList(RHContributionListBase):
2598 _uh = urlHandlers.UHConfModifContribList
2600 def _checkProtection(self):
2601 from MaKaC.webinterface.rh.reviewingModif import RCPaperReviewManager
2602 if not RCPaperReviewManager.hasRights(self):
2603 RHContributionListBase._checkProtection(self)
2605 def _resetFilters( self, sessionData ):
2607 Brings the filter data to a consistent state (websession),
2608 marking everything as "checked"
2611 sessionData.clear()
2612 sessionData["type"] = map(lambda ctype: ctype.getId(), self._conf.getContribTypeList())
2613 sessionData["track"] = map(lambda track: track.getId(), self._conf.getTrackList())
2614 sessionData["session"] = map(lambda ses: ses.getId(), self._conf.getSessionList())
2615 sessionData["status"] = map(lambda status: ContribStatusList.getId(status), ContribStatusList.getList())
2616 lmaterial = []
2617 paperId = materialFactories.PaperFactory().getId()
2618 slidesId = materialFactories.SlidesFactory().getId()
2619 for matId in ["--other--","--none--",paperId,slidesId]: # wtf? doesn't that simply re-create the list?
2620 lmaterial.append(matId)
2621 sessionData["material"] = lmaterial
2622 sessionData["typeShowNoValue"] = True
2623 sessionData["trackShowNoValue"] = True
2624 sessionData["sessionShowNoValue"] = True
2626 return sessionData
2628 def _updateFilters( self, sessionData, params ):
2630 Updates the filter parameters in the websession with those
2631 coming from the HTTP request
2634 sessionData["status"] = []
2635 sessionData["material"] = []
2636 sessionData.update(params)
2637 sessionData["type"] = utils.normalizeToList(params.get('types', []))
2638 sessionData["track"] = utils.normalizeToList(params.get('tracks', []))
2639 sessionData['session'] = utils.normalizeToList(params.get('sessions', []))
2641 # update these elements in the session so that the parameters that are
2642 # passed are always taken into account (sessionData.update is not
2643 # enough, since the elements that are ommitted in params would just be
2644 # ignored
2646 sessionData['typeShowNoValue'] = params.has_key('typeShowNoValue')
2647 sessionData['trackShowNoValue'] = params.has_key('trackShowNoValue')
2648 sessionData['sessionShowNoValue'] = params.has_key('sessionShowNoValue')
2650 return sessionData
2652 def _buildFilteringCriteria(self, sessionData):
2654 Creates the Filtering Criteria object, without changing the existing
2655 session data (sessionData is cloned, not directly changed)
2657 sessionCopy = sessionData.copy()
2659 # Build the filtering criteria
2660 filterCrit = ContribFilterCrit(self._conf, sessionCopy)
2662 filterCrit.getField("type").setShowNoValue(sessionCopy.get('typeShowNoValue'))
2663 filterCrit.getField("track").setShowNoValue(sessionCopy.get('trackShowNoValue'))
2664 filterCrit.getField("session").setShowNoValue(sessionCopy.get('sessionShowNoValue'))
2666 return filterCrit
2668 def _checkAction(self, params, filtersActive, sessionData, operation, isBookmark):
2670 Decides what to do with the request parameters, depending
2671 on the type of operation that is requested
2674 # user chose to reset the filters
2675 if operation == 'resetFilters':
2676 self._filterUsed = False
2677 sessionData = self._resetFilters(sessionData)
2679 # user set the filters
2680 elif operation == 'setFilters':
2681 self._filterUsed = True
2682 sessionData = self._updateFilters(sessionData, params)
2684 # user has changed the display options
2685 elif operation == 'setDisplay':
2686 self._filterUsed = filtersActive
2688 # session is empty (first time)
2689 elif not filtersActive:
2690 self._filterUsed = False
2691 sessionData = self._resetFilters(sessionData)
2692 else:
2693 self._filterUsed = True
2695 # if this is accessed through a direct link, the session is empty, so set default values
2696 if isBookmark:
2697 sessionData = self._resetFilters(sessionData)
2698 if operation != 'resetFilters':
2699 sessionData = self._updateFilters(sessionData, params)
2701 # preserve the order and sortBy parameters, whatever happens
2702 sessionData['order'] = params.get('order', 'down')
2703 sessionData['sortBy'] = params.get('sortBy', 'number')
2705 return sessionData
2707 def _checkParams( self, params ):
2708 RHContributionListBase._checkParams( self, params )
2709 operationType = params.get('operationType')
2710 sessionData = session.get('ContributionFilterConf%s' % self._conf.getId())
2712 # check if there is information already
2713 # set in the session variables
2714 if sessionData:
2715 # work on a copy
2716 sessionData = sessionData.copy()
2717 filtersActive = sessionData.get('filtersActive', False)
2718 else:
2719 # set a default, empty dict
2720 sessionData = {}
2721 filtersActive = False
2723 if params.has_key("resetFilters"):
2724 operation = 'resetFilters'
2725 elif operationType == 'filter':
2726 operation = 'setFilters'
2727 elif operationType == 'display':
2728 operation = 'setDisplay'
2729 else:
2730 operation = None
2732 isBookmark = params.has_key("isBookmark")
2733 sessionData = self._checkAction(params, filtersActive, sessionData, operation, isBookmark)
2734 # Maintain the state about filter usage
2735 sessionData['filtersActive'] = self._filterUsed;
2736 # Save the web session
2737 session['ContributionFilterConf%s' % self._conf.getId()] = sessionData
2738 self._filterCrit = self._buildFilteringCriteria(sessionData)
2739 self._sortingCrit = ContribSortingCrit([sessionData.get("sortBy", "number").strip()])
2740 self._order = sessionData.get("order", "down")
2741 self._authSearch = sessionData.get("authSearch", "")
2743 def _process( self ):
2744 p = conferences.WPModifContribList(self, self._target, self._filterUsed)
2745 return p.display(authSearch=self._authSearch,\
2746 filterCrit=self._filterCrit, sortingCrit=self._sortingCrit, order=self._order)
2749 class RHContribQuickAccess(RHConferenceModifBase):
2751 def _checkParams(self,params):
2752 RHConferenceModifBase._checkParams(self,params)
2753 self._contrib=self._target.getContributionById(params.get("selContrib",""))
2755 def _process(self):
2756 url=urlHandlers.UHConfModifContribList.getURL(self._target)
2757 if self._contrib is not None:
2758 url=urlHandlers.UHContributionModification.getURL(self._contrib)
2759 self._redirect(url)
2761 #-------------------------------------------------------------------------------------
2763 class RHAbstractsParticipantList(RHConfModifCFABase):
2765 def _checkProtection( self ):
2766 if len( self._conf.getCoordinatedTracks( self._getUser() ) ) == 0:
2767 RHConferenceModifBase._checkProtection( self )
2769 def _checkParams( self, params ):
2770 RHConfModifCFABase._checkParams( self, params )
2771 self._abstractIds = normaliseListParam( params.get("abstracts", []) )
2772 self._displayedGroups = params.get("displayedGroups", [])
2773 if type(self._displayedGroups) != list:
2774 self._displayedGroups = [self._displayedGroups]
2775 self._clickedGroup = params.get("clickedGroup","")
2777 def _setGroupsToDisplay(self):
2778 if self._clickedGroup in self._displayedGroups:
2779 self._displayedGroups.remove(self._clickedGroup)
2780 else:
2781 self._displayedGroups.append(self._clickedGroup)
2783 def _process( self ):
2784 #This is a plain text exception but an exception should be raised here !
2785 if not self._abstractIds:
2786 return _("There is no abstract.")
2788 submitters = OOBTree()
2789 primaryAuthors = OOBTree()
2790 coAuthors = OOBTree()
2791 submitterEmails = set()
2792 primaryAuthorEmails = set()
2793 coAuthorEmails = set()
2795 self._setGroupsToDisplay()
2797 abMgr = self._conf.getAbstractMgr()
2798 for abstId in self._abstractIds:
2799 abst = abMgr.getAbstractById(abstId)
2800 #Submitters
2802 subm = abst.getSubmitter()
2803 if subm.getSurName().lower().strip() != "" or subm.getFirstName().lower().strip() != "" or subm.getEmail().lower().strip() != "":
2804 keySB = "%s-%s-%s"%(subm.getSurName().lower(), subm.getFirstName().lower(), subm.getEmail().lower())
2805 submitters[keySB] = subm
2806 submitterEmails.add(subm.getEmail())
2807 #Primary authors
2808 for pAut in abst.getPrimaryAuthorList():
2809 if pAut.getSurName().lower().strip() == "" and pAut.getFirstName().lower().strip() == "" and pAut.getEmail().lower().strip() == "":
2810 continue
2811 keyPA = "%s-%s-%s"%(pAut.getSurName().lower(), pAut.getFirstName().lower(), pAut.getEmail().lower())
2812 primaryAuthors[keyPA] = pAut
2813 primaryAuthorEmails.add(pAut.getEmail())
2814 #Co-authors
2815 for coAut in abst.getCoAuthorList():
2816 if coAut.getSurName().lower().strip() == "" and coAut.getFirstName().lower().strip() == "" and coAut.getEmail().lower().strip() == "":
2817 continue
2818 keyCA = "%s-%s-%s"%(coAut.getSurName().lower(), coAut.getFirstName().lower(), coAut.getEmail().lower())
2819 coAuthors[keyCA] = coAut
2820 coAuthorEmails.add(coAut.getEmail())
2821 emailList = {"submitters":{},"primaryAuthors":{},"coAuthors":{}}
2822 emailList["submitters"]["tree"] = submitters
2823 emailList["primaryAuthors"]["tree"] = primaryAuthors
2824 emailList["coAuthors"]["tree"] = coAuthors
2825 emailList["submitters"]["emails"] = submitterEmails
2826 emailList["primaryAuthors"]["emails"] = primaryAuthorEmails
2827 emailList["coAuthors"]["emails"] = coAuthorEmails
2828 p = conferences.WPConfParticipantList(self, self._target, emailList, self._displayedGroups, self._abstractIds )
2829 return p.display()
2832 class RHNewAbstract(RHConfModifCFABase, AbstractParam):
2834 def __init__(self):
2835 RHConfModifCFABase.__init__(self)
2836 AbstractParam.__init__(self)
2838 def _checkParams(self, params):
2839 RHConfModifCFABase._checkParams(self, params)
2840 #if the user is not logged in we return immediately as this form needs
2841 # the user to be logged in and therefore all the checking below is not
2842 # necessary
2843 if self._getUser() is None:
2844 return
2845 AbstractParam._checkParams(self, params, self._conf, request.content_length)
2847 def _doValidate(self):
2848 #First, one must validate that the information is fine
2849 errors = self._abstractData.check()
2850 if errors:
2851 p = conferences.WPModNewAbstract(
2852 self, self._target, self._abstractData)
2853 pars = self._abstractData.toDict()
2854 pars["action"] = self._action
2855 return p.display(**pars)
2856 #Then, we create the abstract object and set its data to the one
2857 # received
2858 cfaMgr = self._target.getAbstractMgr()
2859 abstract = cfaMgr.newAbstract(self._getUser())
2860 #self._setAbstractData(abstract)
2861 self._abstractData.setAbstractData(abstract)
2862 #Finally, we display the abstract list page
2863 self._redirect(urlHandlers.UHConfAbstractList.getURL(self._conf))
2865 def _process(self):
2866 if self._action == "CANCEL":
2867 self._redirect(
2868 urlHandlers.UHConfAbstractManagment.getURL(self._target))
2869 elif self._action == "VALIDATE":
2870 return self._doValidate()
2871 else:
2872 p = conferences.WPModNewAbstract(
2873 self, self._target, self._abstractData)
2874 pars = self._abstractData.toDict()
2875 return p.display(**pars)
2879 class RHContribsActions:
2881 class to select the action to do with the selected abstracts
2883 def process(self, params):
2884 if params.has_key("PDF"):
2885 return RHContribsToPDF().process(params)
2886 elif params.has_key("excel.x"):
2887 return RHContribsToExcel().process(params)
2888 elif params.has_key("xml.x"):
2889 return RHContribsToXML().process(params)
2890 elif params.has_key("AUTH"):
2891 return RHContribsParticipantList().process(params)
2892 elif params.has_key("move"):
2893 return RHMoveContribsToSession().process(params)
2894 elif params.has_key("PKG"):
2895 return RHMaterialPackage().process(params)
2896 elif params.has_key("PROC"):
2897 return RHProceedings().process(params)
2898 return "no action to do"
2901 class RHContribsToPDFMenu(RHConferenceModifBase):
2903 def _checkParams( self, params ):
2904 RHConferenceModifBase._checkParams( self, params )
2905 self._contribIds = self._normaliseListParam( params.get("contributions", []) )
2906 self._contribs = []
2907 for id in self._contribIds:
2908 self._contribs.append(self._conf.getContributionById(id))
2909 self._displayType = params.get("displaytype", None)
2911 def _process( self ):
2912 from MaKaC.PDFinterface.conference import ContributionBook
2913 if not self._displayType:
2914 wp = conferences.WPConfModifContribToPDFMenu(self, self._conf, self._contribIds)
2915 return wp.display()
2917 elif self._displayType == "bookOfAbstract":
2918 tz = self._target.getTimezone()
2919 filename = "{0} - Book of abstracts.pdf".format(self._target.getTitle())
2921 pdf = ContributionBook(self._target, self.getAW(), self._contribs, tz=tz)
2922 return send_file(filename, pdf.generate(), 'PDF')
2924 elif self._displayType == "bookOfAbstractBoardNo":
2925 tz = self._target.getTimezone()
2926 filename = "{0} - Book of abstracts.pdf".format(self._target.getTitle())
2927 pdf = ContributionBook(self._target, self.getAW(), self._contribs, tz=tz, sort_by="boardNo")
2928 return send_file(filename, pdf.generate(), 'PDF')
2930 elif self._displayType == "ContributionList":
2931 tz = self._conf.getTimezone()
2932 filename = "{0} - Contributions.pdf".format(self._target.getTitle())
2933 if not self._contribs:
2934 return "No contributions to print"
2936 contrib_pdf = ContribsToPDF(self._conf, self._contribs)
2937 fpath = contrib_pdf.generate()
2939 return send_file(filename, fpath, 'PDF')
2942 class RHContribsToPDF(RHConferenceModifBase):
2944 def _checkParams( self, params ):
2945 RHConferenceModifBase._checkParams( self, params )
2946 self._contribIds = self._normaliseListParam( params.get("contributions", []) )
2947 self._contribs = []
2948 for id in self._contribIds:
2949 self._contribs.append(self._conf.getContributionById(id))
2951 def _process( self ):
2952 tz = self._conf.getTimezone()
2953 filename = "Contributions.pdf"
2954 if not self._contribs:
2955 return "No contributions to print"
2956 pdf = ContribsToPDF(self._conf, self._contribs)
2957 return send_file(filename, pdf.generate(), 'PDF')
2960 class RHContribsToExcel(RHConferenceModifBase):
2962 def _checkParams( self, params ):
2963 RHConferenceModifBase._checkParams( self, params )
2964 self._contribIds = self._normaliseListParam( params.get("contributions", []) )
2965 self._contribs = []
2966 for id in self._contribIds:
2967 self._contribs.append(self._conf.getContributionById(id))
2969 def _process( self ):
2970 tz = self._conf.getTimezone()
2971 filename = "Contributions.csv"
2972 if not self._contribs:
2973 return "No contributions to print"
2974 excel = ContributionsListToExcel(self._conf, self._contribs, tz=tz)
2975 return send_file(filename, StringIO(excel.getExcelFile()), 'CSV')
2978 class RHContribsToXML(RHConferenceModifBase):
2980 def _checkParams( self, params ):
2981 RHConferenceModifBase._checkParams( self, params )
2982 self._contribIds = self._normaliseListParam( params.get("contributions", []) )
2983 self._contribs = []
2984 for id in self._contribIds:
2985 self._contribs.append(self._conf.getContributionById(id))
2986 def _process( self ):
2987 filename = "Contributions.xml"
2988 from MaKaC.common.fossilize import fossilize
2989 resultFossil = fossilize(self._contribs)
2990 serializer = Serializer.create('xml')
2991 return send_file(filename, StringIO(serializer(resultFossil)), 'XML')
2994 class RHContribsParticipantList(RHConferenceModifBase):
2996 def _checkParams( self, params ):
2997 RHConferenceModifBase._checkParams( self, params )
2998 self._contribIds = normaliseListParam( params.get("contributions", []) )
2999 self._displayedGroups = self._normaliseListParam( params.get("displayedGroups", []) )
3000 self._clickedGroup = params.get("clickedGroup","")
3002 def _setGroupsToDisplay(self):
3003 if self._clickedGroup in self._displayedGroups:
3004 self._displayedGroups.remove(self._clickedGroup)
3005 else:
3006 self._displayedGroups.append(self._clickedGroup)
3008 def _process( self ):
3009 if not self._contribIds:
3010 return i18nformat("""<table align=\"center\" width=\"100%%\"><tr><td> _("There are no contributions") </td></tr></table>""")
3012 speakers = OOBTree()
3013 primaryAuthors = OOBTree()
3014 coAuthors = OOBTree()
3015 speakerEmails = set()
3016 primaryAuthorEmails = set()
3017 coAuthorEmails = set()
3019 self._setGroupsToDisplay()
3021 for contribId in self._contribIds:
3022 contrib = self._conf.getContributionById(contribId)
3023 #Primary authors
3024 for pAut in contrib.getPrimaryAuthorList():
3025 if pAut.getFamilyName().lower().strip() == "" and pAut.getFirstName().lower().strip() == "" and pAut.getEmail().lower().strip() == "":
3026 continue
3027 keyPA = "%s-%s-%s"%(pAut.getFamilyName().lower(), pAut.getFirstName().lower(), pAut.getEmail().lower())
3028 primaryAuthors[keyPA] = pAut
3029 if pAut.getEmail() != "":
3030 primaryAuthorEmails.add(pAut.getEmail())
3031 #Co-authors
3032 for coAut in contrib.getCoAuthorList():
3033 if coAut.getFamilyName().lower().strip() == "" and coAut.getFirstName().lower().strip() == "" and coAut.getEmail().lower().strip() == "":
3034 continue
3035 keyCA = "%s-%s-%s"%(coAut.getFamilyName().lower(), coAut.getFirstName().lower(), coAut.getEmail().lower())
3036 coAuthors[keyCA] = coAut
3037 if coAut.getEmail() != "":
3038 coAuthorEmails.add(coAut.getEmail())
3039 #Presenters
3040 for pres in contrib.getSpeakerList():
3041 if pres.getFamilyName().lower().strip() == "" and pres.getFirstName().lower().strip() == "" and pres.getEmail().lower().strip() == "":
3042 continue
3043 keyP = "%s-%s-%s"%(pres.getFamilyName().lower(), pres.getFirstName().lower(), pres.getEmail().lower())
3044 speakers[keyP] = pres
3045 if pres.getEmail() != "":
3046 speakerEmails.add(pres.getEmail())
3047 emailList = {"speakers":{},"primaryAuthors":{},"coAuthors":{}}
3048 emailList["speakers"]["tree"] = speakers
3049 emailList["primaryAuthors"]["tree"] = primaryAuthors
3050 emailList["coAuthors"]["tree"] = coAuthors
3051 emailList["speakers"]["emails"] = speakerEmails
3052 emailList["primaryAuthors"]["emails"] = primaryAuthorEmails
3053 emailList["coAuthors"]["emails"] = coAuthorEmails
3054 p = conferences.WPConfModifParticipantList(self, self._target, emailList, self._displayedGroups, self._contribIds )
3055 return p.display()
3058 class RHMoveContribsToSession(RHConferenceModifBase):
3060 def _checkParams(self,params):
3061 RHConferenceModifBase._checkParams(self,params)
3062 self._action=""
3063 self._session=self._target.getSessionById(params.get("targetSession",""))
3064 self._contribIds=self._normaliseListParam(params.get("contributions",[]))
3065 if params.has_key("OK"):
3066 if self._session is not None and self._session.isClosed():
3067 raise NoReportError(_("""The modification of the session "%s" is not allowed because it is closed""")%self._session.getTitle())
3068 self._contribIds=self._normaliseListParam(params.get("contributions","").split(","))
3069 self._action="MOVE"
3070 elif params.has_key("CANCEL"):
3071 self._action="CANCEL"
3072 elif params.has_key("CONFIRM"):
3073 self._action="MOVE_CONFIRMED"
3074 elif params.has_key("CONFIRM_ALL"):
3075 self._action="MOVE_ALL_CONFIRMED"
3077 def _needsWarning(self,contrib):
3078 return (contrib.getSession() is not None and \
3079 contrib.getSession()!=self._session) or \
3080 (contrib.getSession() is None and \
3081 self._session is not None and \
3082 contrib.isScheduled())
3084 def _process( self ):
3085 url=urlHandlers.UHConfModifContribList.getURL(self._target)
3086 if self._action=="CANCEL":
3087 self._redirect(url)
3088 return
3089 elif self._action in ("MOVE","MOVE_CONFIRMED","MOVE_ALL_CONFIRMED"):
3090 contribList=[]
3091 for id in self._contribIds:
3092 contrib=self._target.getContributionById(id)
3093 if contrib is None:
3094 continue
3095 if self._needsWarning(contrib):
3096 if self._action=="MOVE":
3097 p=conferences.WPModMoveContribsToSessionConfirmation(self,self._target)
3098 return p.display(contribIds=self._contribIds,targetSession=self._session)
3099 elif self._action=="MOVE_CONFIRMED":
3100 continue
3101 if contrib.getSession() is not None and contrib.getSession().isClosed():
3102 raise NoReportError(_("""The contribution "%s" cannot be moved because it is inside of the session "%s" that is closed""")%(contrib.getId(), contrib.getSession().getTitle()))
3103 contribList.append(contrib)
3104 for contrib in contribList:
3105 contrib.setSession(self._session)
3106 self._redirect(url)
3107 return
3108 p=conferences.WPModMoveContribsToSession(self,self._target)
3109 return p.display(contribIds=self._contribIds)
3111 class RHMaterialPackageAbstract(RHConferenceModifBase):
3112 # Export a Zip file
3114 def _checkParams( self, params ):
3115 RHConferenceModifBase._checkParams( self, params )
3116 abstractIds = self._normaliseListParam( params.get("abstracts", []) )
3117 self._abstracts = []
3118 for aID in abstractIds:
3119 self._abstracts.append(self._conf.getAbstractMgr().getAbstractById(aID))
3121 def _process( self ):
3122 if not self._abstracts:
3123 return FormValuesError(_("No abstract selected"))
3124 p = AbstractPacker(self._conf)
3125 path = p.pack(self._abstracts, ZIPFileHandler())
3126 return send_file('abstractFiles.zip', path, 'ZIP', inline=False)
3129 class RHMaterialPackage(RHConferenceModifBase):
3131 def _checkParams(self, params):
3132 RHConferenceModifBase._checkParams(self, params)
3133 self._contribIds = self._normaliseListParam(params.get("contributions", []))
3134 self._contribs = []
3135 for id in self._contribIds:
3136 self._contribs.append(self._conf.getContributionById(id))
3138 def _process(self):
3139 if not self._contribs:
3140 return "No contribution selected"
3141 p=ContribPacker(self._conf)
3142 path=p.pack(self._contribs, ZIPFileHandler())
3143 if not p.getItems():
3144 raise NoReportError(_("The selected package does not contain any items"))
3145 return send_file('material.zip', path, 'ZIP', inline=False)
3148 class RHProceedings(RHConferenceModifBase):
3150 def _process( self ):
3151 set_best_lang() # prevents from having a _LazyString when generating a pdf without session.lang set
3152 p=ProceedingsPacker(self._conf)
3153 path=p.pack(ZIPFileHandler())
3154 return send_file('proceedings.zip', path, 'ZIP', inline=False)
3157 class RHAbstractBook( RHConfModifCFABase ):
3158 _uh = urlHandlers.UHConfModAbstractBook
3160 def _checkParams( self, params ):
3161 RHConfModifCFABase._checkParams( self, params )
3163 def _process( self ):
3164 p = conferences.WPModAbstractBook(self,self._target)
3165 return p.display()
3168 class RHAbstractBookToogleShowIds( RHConfModifCFABase ):
3169 _uh = urlHandlers.UHConfModAbstractBookToogleShowIds
3171 def _process( self ):
3172 self._conf.getBOAConfig().setShowIds(not self._conf.getBOAConfig().getShowIds())
3173 self._redirect( urlHandlers.UHConfModAbstractBook.getURL( self._conf ) )
3175 class RHFullMaterialPackage(RHConferenceModifBase):
3176 _uh=urlHandlers.UHConfModFullMaterialPackage
3178 def _checkParams( self, params ):
3179 RHConferenceModifBase._checkParams( self, params )
3181 def _process( self ):
3182 p = conferences.WPFullMaterialPackage(self,self._target)
3183 return p.display()
3186 class RHFullMaterialPackagePerform(RHConferenceModifBase):
3187 _uh=urlHandlers.UHConfModFullMaterialPackagePerform
3189 def _checkParams( self, params ):
3190 RHConferenceModifBase._checkParams( self, params )
3191 self._days=self._normaliseListParam(params.get("days",[]))
3192 self._mainResource = (params.get("mainResource","") != "")
3193 self._fromDate = ""
3194 fromDay = params.get("fromDay","")
3195 fromMonth = params.get("fromMonth","")
3196 fromYear = params.get("fromYear","")
3197 if fromDay != "" and fromMonth != "" and fromYear != "" and \
3198 fromDay != "dd" and fromMonth != "mm" and fromYear != "yyyy":
3199 self._fromDate = "%s %s %s"%(fromDay, fromMonth, fromYear)
3200 self._cancel = params.has_key("cancel")
3201 self._materialTypes=self._normaliseListParam(params.get("materialType",[]))
3202 self._sessionList = self._normaliseListParam(params.get("sessionList",[]))
3204 def _process( self ):
3205 if not self._cancel:
3206 if self._materialTypes:
3207 p=ConferencePacker(self._conf, self._aw)
3208 path=p.pack(self._materialTypes, self._days, self._mainResource, self._fromDate, ZIPFileHandler(),self._sessionList)
3209 if not p.getItems():
3210 raise NoReportError(_("The selected package does not contain any items."))
3211 return send_file('full-material.zip', path, 'ZIP', inline=False)
3212 raise NoReportError(_("You have to select at least one material type"))
3213 else:
3214 self._redirect( urlHandlers.UHConfModifTools.getURL( self._conf ) )
3216 class RHModifSessionCoordRights( RHConferenceModifBase ):
3217 _uh = urlHandlers.UHConfPerformDataModif
3219 def _checkParams( self, params ):
3220 RHConferenceModifBase._checkParams( self, params )
3221 self._rightId = params.get("rightId", "")
3223 def _process( self ):
3224 if self._rightId != "":
3225 if self._conf.hasSessionCoordinatorRight(self._rightId):
3226 self._conf.removeSessionCoordinatorRight(self._rightId)
3227 else:
3228 self._conf.addSessionCoordinatorRight(self._rightId)
3229 self._redirect( "%s#sessionCoordinatorRights"%urlHandlers.UHConfModifAC.getURL( self._conf) )
3232 class RHConfModifPendingQueues( RHConferenceModifBase ):
3233 _uh = urlHandlers.UHConfModifPendingQueues
3235 def _process( self ):
3236 p = conferences.WPConfModifPendingQueues( self, self._target, self._getRequestParams().get("tab","conf_submitters") )
3237 return p.display()
3239 class RHConfModifPendingQueuesActionConfMgr:
3241 class to select the action to do with the selected pending conference submitters
3244 _uh = urlHandlers.UHConfModifPendingQueuesActionConfMgr
3246 def process(self, params):
3247 if 'remove' in params:
3248 return RHConfModifPendingQueuesRemoveConfMgr().process(params)
3249 elif 'reminder' in params:
3250 return RHConfModifPendingQueuesReminderConfMgr().process(params)
3251 return "no action to do"
3253 class RHConfModifPendingQueuesRemoveConfMgr( RHConferenceModifBase ):
3255 def _checkParams( self, params ):
3256 RHConferenceModifBase._checkParams( self, params )
3257 self._pendingConfMgrIds = self._normaliseListParam( params.get("pendingUsers", []) )
3258 self._pendingConfMgrs = []
3259 for id in self._pendingConfMgrIds:
3260 self._pendingConfMgrs.extend(self._conf.getPendingQueuesMgr().getPendingConfManagersByEmail(id))
3261 self._remove=params.has_key("confirm")
3262 self._confirmed=params.has_key("confirm") or params.has_key("cancel")
3264 def _process( self ):
3265 url=urlHandlers.UHConfModifPendingQueues.getURL(self._conf)
3266 url.addParam("tab","conf_managers")
3267 if self._pendingConfMgrs == []:
3268 self._redirect(url)
3269 if self._confirmed:
3270 if self._remove:
3271 for ps in self._pendingConfMgrs:
3272 self._conf.getPendingQueuesMgr().removePendingConfManager(ps)
3273 self._redirect(url)
3274 else:
3275 wp = conferences.WPConfModifPendingQueuesRemoveConfMgrConfirm(self, self._conf, self._pendingConfMgrIds)
3276 return wp.display()
3278 class RHConfModifPendingQueuesReminderConfMgr( RHConferenceModifBase ):
3280 def _checkParams( self, params ):
3281 RHConferenceModifBase._checkParams( self, params )
3282 self._pendingConfMgrIds = self._normaliseListParam( params.get("pendingUsers", []) )
3283 self._pendingConfMgrs = []
3284 for email in self._pendingConfMgrIds:
3285 self._pendingConfMgrs.append(self._conf.getPendingQueuesMgr().getPendingConfManagersByEmail(email))
3286 self._send=params.has_key("confirm")
3287 self._confirmed=params.has_key("confirm") or params.has_key("cancel")
3290 def _process( self ):
3291 url=urlHandlers.UHConfModifPendingQueues.getURL(self._conf)
3292 url.addParam("tab","conf_managers")
3293 if self._pendingConfMgrs == []:
3294 self._redirect(url)
3295 if self._confirmed:
3296 if self._send:
3297 pendings=pendingQueues.PendingConfManagersHolder()
3298 for pss in self._pendingConfMgrs:
3299 pendings._sendReminderEmail(pss)
3300 self._redirect(url)
3301 else:
3302 wp = conferences.WPConfModifPendingQueuesReminderConfMgrConfirm(self, self._conf, self._pendingConfMgrIds)
3303 return wp.display()
3305 class RHConfModifPendingQueuesActionConfSubm:
3307 class to select the action to do with the selected pending conference submitters
3310 _uh = urlHandlers.UHConfModifPendingQueuesActionConfSubm
3312 def process(self, params):
3313 if 'remove' in params:
3314 return RHConfModifPendingQueuesRemoveConfSubm().process(params)
3315 elif 'reminder' in params:
3316 return RHConfModifPendingQueuesReminderConfSubm().process(params)
3317 return "no action to do"
3319 class RHConfModifPendingQueuesRemoveConfSubm( RHConferenceModifBase ):
3321 def _checkParams( self, params ):
3322 RHConferenceModifBase._checkParams( self, params )
3323 self._pendingConfSubmIds = self._normaliseListParam( params.get("pendingUsers", []) )
3324 self._pendingConfSubms = []
3325 for id in self._pendingConfSubmIds:
3326 self._pendingConfSubms.extend(self._conf.getPendingQueuesMgr().getPendingConfSubmittersByEmail(id))
3327 self._remove=params.has_key("confirm")
3328 self._confirmed=params.has_key("confirm") or params.has_key("cancel")
3330 def _process( self ):
3331 url=urlHandlers.UHConfModifPendingQueues.getURL(self._conf)
3332 url.addParam("tab","conf_submitters")
3333 if self._pendingConfSubms == []:
3334 self._redirect(url)
3335 if self._confirmed:
3336 if self._remove:
3337 for ps in self._pendingConfSubms:
3338 self._conf.getPendingQueuesMgr().removePendingConfSubmitter(ps)
3339 self._redirect(url)
3340 else:
3341 wp = conferences.WPConfModifPendingQueuesRemoveConfSubmConfirm(self, self._conf, self._pendingConfSubmIds)
3342 return wp.display()
3344 class RHConfModifPendingQueuesReminderConfSubm( RHConferenceModifBase ):
3346 def _checkParams( self, params ):
3347 RHConferenceModifBase._checkParams( self, params )
3348 self._pendingConfSubmIds = self._normaliseListParam( params.get("pendingUsers", []) )
3349 self._pendingConfSubms = []
3350 for email in self._pendingConfSubmIds:
3351 self._pendingConfSubms.append(self._conf.getPendingQueuesMgr().getPendingConfSubmittersByEmail(email))
3352 self._send=params.has_key("confirm")
3353 self._confirmed=params.has_key("confirm") or params.has_key("cancel")
3356 def _process( self ):
3357 url=urlHandlers.UHConfModifPendingQueues.getURL(self._conf)
3358 url.addParam("tab","conf_submitters")
3359 if self._pendingConfSubms == []:
3360 self._redirect(url)
3361 if self._confirmed:
3362 if self._send:
3363 pendings=pendingQueues.PendingConfSubmittersHolder()
3364 for pss in self._pendingConfSubms:
3365 pendings._sendReminderEmail(pss)
3366 self._redirect(url)
3367 else:
3368 wp = conferences.WPConfModifPendingQueuesReminderConfSubmConfirm(self, self._conf, self._pendingConfSubmIds)
3369 return wp.display()
3371 class RHConfModifPendingQueuesActionSubm:
3373 class to select the action to do with the selected pending contribution submitters
3376 _uh = urlHandlers.UHConfModifPendingQueuesActionSubm
3378 def process(self, params):
3379 if 'remove' in params:
3380 return RHConfModifPendingQueuesRemoveSubm().process(params)
3381 elif 'reminder' in params:
3382 return RHConfModifPendingQueuesReminderSubm().process(params)
3383 return "no action to do"
3385 class RHConfModifPendingQueuesRemoveSubm( RHConferenceModifBase ):
3387 def _checkParams( self, params ):
3388 RHConferenceModifBase._checkParams( self, params )
3389 self._pendingSubmIds = self._normaliseListParam( params.get("pendingUsers", []) )
3390 self._pendingSubms = []
3391 for id in self._pendingSubmIds:
3392 self._pendingSubms.extend(self._conf.getPendingQueuesMgr().getPendingSubmittersByEmail(id))
3393 self._remove=params.has_key("confirm")
3394 self._confirmed=params.has_key("confirm") or params.has_key("cancel")
3396 def _process( self ):
3397 url=urlHandlers.UHConfModifPendingQueues.getURL(self._conf)
3398 url.addParam("tab","submitters")
3399 if self._pendingSubms == []:
3400 self._redirect(url)
3401 if self._confirmed:
3402 if self._remove:
3403 for ps in self._pendingSubms:
3404 self._conf.getPendingQueuesMgr().removePendingSubmitter(ps)
3405 self._redirect(url)
3406 else:
3407 wp = conferences.WPConfModifPendingQueuesRemoveSubmConfirm(self, self._conf, self._pendingSubmIds)
3408 return wp.display()
3410 class RHConfModifPendingQueuesReminderSubm( RHConferenceModifBase ):
3412 def _checkParams( self, params ):
3413 RHConferenceModifBase._checkParams( self, params )
3414 self._pendingSubmIds = self._normaliseListParam( params.get("pendingUsers", []) )
3415 self._pendingSubms = []
3416 for email in self._pendingSubmIds:
3417 self._pendingSubms.append(self._conf.getPendingQueuesMgr().getPendingSubmittersByEmail(email))
3418 self._send=params.has_key("confirm")
3419 self._confirmed=params.has_key("confirm") or params.has_key("cancel")
3422 def _process( self ):
3423 url=urlHandlers.UHConfModifPendingQueues.getURL(self._conf)
3424 url.addParam("tab","submitters")
3425 if self._pendingSubms == []:
3426 self._redirect(url)
3427 if self._confirmed:
3428 if self._send:
3429 pendings=pendingQueues.PendingSubmittersHolder()
3430 for pss in self._pendingSubms:
3431 pendings._sendReminderEmail(pss)
3432 self._redirect(url)
3433 else:
3434 wp = conferences.WPConfModifPendingQueuesReminderSubmConfirm(self, self._conf, self._pendingSubmIds)
3435 return wp.display()
3437 class RHConfModifPendingQueuesActionMgr:
3439 class to select the action to do with the selected pending submitters
3442 _uh = urlHandlers.UHConfModifPendingQueuesActionMgr
3444 def process(self, params):
3445 if 'remove' in params:
3446 return RHConfModifPendingQueuesRemoveMgr().process(params)
3447 elif 'reminder' in params:
3448 return RHConfModifPendingQueuesReminderMgr().process(params)
3449 return "no action to do"
3451 class RHConfModifPendingQueuesRemoveMgr( RHConferenceModifBase ):
3453 def _checkParams( self, params ):
3454 RHConferenceModifBase._checkParams( self, params )
3455 self._pendingMgrIds = self._normaliseListParam( params.get("pendingUsers", []) )
3456 self._pendingMgrs = []
3457 for id in self._pendingMgrIds:
3458 self._pendingMgrs.extend(self._conf.getPendingQueuesMgr().getPendingManagersByEmail(id))
3459 self._remove=params.has_key("confirm")
3460 self._confirmed=params.has_key("confirm") or params.has_key("cancel")
3463 def _process( self ):
3464 url=urlHandlers.UHConfModifPendingQueues.getURL(self._conf)
3465 url.addParam("tab","managers")
3466 if self._pendingMgrs == []:
3467 self._redirect(url)
3468 if self._confirmed:
3469 if self._remove:
3470 for ps in self._pendingMgrs:
3471 self._conf.getPendingQueuesMgr().removePendingManager(ps)
3472 self._redirect(url)
3473 else:
3474 wp = conferences.WPConfModifPendingQueuesRemoveMgrConfirm(self, self._conf, self._pendingMgrIds)
3475 return wp.display()
3477 class RHConfModifPendingQueuesReminderMgr( RHConferenceModifBase ):
3479 def _checkParams( self, params ):
3480 RHConferenceModifBase._checkParams( self, params )
3481 self._pendingMgrIds = self._normaliseListParam( params.get("pendingUsers", []) )
3482 self._pendingMgrs = []
3483 for email in self._pendingMgrIds:
3484 self._pendingMgrs.append(self._conf.getPendingQueuesMgr().getPendingManagersByEmail(email))
3485 self._send=params.has_key("confirm")
3486 self._confirmed=params.has_key("confirm") or params.has_key("cancel")
3489 def _process( self ):
3490 url=urlHandlers.UHConfModifPendingQueues.getURL(self._conf)
3491 url.addParam("tab","managers")
3492 if self._pendingMgrs == []:
3493 self._redirect(url)
3494 if self._confirmed:
3495 if self._send:
3496 pendings=pendingQueues.PendingManagersHolder()
3497 for pss in self._pendingMgrs:
3498 pendings._sendReminderEmail(pss)
3499 self._redirect(url)
3500 else:
3501 wp = conferences.WPConfModifPendingQueuesReminderMgrConfirm(self, self._conf, self._pendingMgrIds)
3502 return wp.display()
3504 class RHConfModifPendingQueuesActionCoord:
3506 class to select the action to do with the selected pending submitters
3509 _uh = urlHandlers.UHConfModifPendingQueuesActionCoord
3511 def process(self, params):
3512 if 'remove' in params:
3513 return RHConfModifPendingQueuesRemoveCoord().process(params)
3514 elif 'reminder' in params:
3515 return RHConfModifPendingQueuesReminderCoord().process(params)
3516 return "no action to do"
3518 class RHConfModifPendingQueuesRemoveCoord( RHConferenceModifBase ):
3520 def _checkParams( self, params ):
3521 RHConferenceModifBase._checkParams( self, params )
3522 self._pendingCoordIds = self._normaliseListParam( params.get("pendingUsers", []) )
3523 self._pendingCoords = []
3524 for id in self._pendingCoordIds:
3525 self._pendingCoords.extend(self._conf.getPendingQueuesMgr().getPendingCoordinatorsByEmail(id))
3526 self._remove=params.has_key("confirm")
3527 self._confirmed=params.has_key("confirm") or params.has_key("cancel")
3530 def _process( self ):
3531 url=urlHandlers.UHConfModifPendingQueues.getURL(self._conf)
3532 url.addParam("tab", "coordinators")
3533 if self._pendingCoords == []:
3534 self._redirect(url)
3535 if self._confirmed:
3536 if self._remove:
3537 for ps in self._pendingCoords:
3538 self._conf.getPendingQueuesMgr().removePendingCoordinator(ps)
3539 self._redirect(url)
3540 else:
3541 wp = conferences.WPConfModifPendingQueuesRemoveCoordConfirm(self, self._conf, self._pendingCoordIds)
3542 return wp.display()
3544 class RHConfModifPendingQueuesReminderCoord( RHConferenceModifBase ):
3546 def _checkParams( self, params ):
3547 RHConferenceModifBase._checkParams( self, params )
3548 self._pendingCoordIds = self._normaliseListParam( params.get("pendingUsers", []) )
3549 self._pendingCoords = []
3550 for email in self._pendingCoordIds:
3551 self._pendingCoords.append(self._conf.getPendingQueuesMgr().getPendingCoordinatorsByEmail(email))
3552 self._send=params.has_key("confirm")
3553 self._confirmed=params.has_key("confirm") or params.has_key("cancel")
3556 def _process( self ):
3557 url=urlHandlers.UHConfModifPendingQueues.getURL(self._conf)
3558 url.addParam("tab", "coordinators")
3559 if self._pendingCoords == []:
3560 self._redirect(url)
3561 if self._confirmed:
3562 if self._send:
3563 pendings=pendingQueues.PendingCoordinatorsHolder()
3564 for pss in self._pendingCoords:
3565 pendings._sendReminderEmail(pss)
3566 self._redirect(url)
3567 else:
3568 wp = conferences.WPConfModifPendingQueuesReminderCoordConfirm(self, self._conf, self._pendingCoordIds)
3569 return wp.display()
3571 class RHConfAbstractFields( RHConfModifCFABase ):
3572 _uh = urlHandlers.UHConfModifCFAOptFld
3574 def _checkParams( self, params ):
3575 RHConfModifCFABase._checkParams( self, params )
3576 self._fieldId = params.get("fieldId", "")
3577 if self._fieldId.strip()!="":
3578 if not self._conf.getAbstractMgr().getAbstractFieldsMgr().hasField(self._fieldId):
3579 raise MaKaCError( _("The field that you are trying to enable/disable does not exist"))
3581 def _process( self ):
3582 if self._fieldId.strip() != "":
3583 if self._conf.getAbstractMgr().hasEnabledAbstractField(self._fieldId):
3584 self._conf.getAbstractMgr().disableAbstractField(self._fieldId)
3585 else:
3586 self._conf.getAbstractMgr().enableAbstractField(self._fieldId)
3587 self._redirect(urlHandlers.UHConfModifCFA.getURL(self._conf))
3590 class RHConfRemoveAbstractField( RHConfModifCFABase ):
3591 _uh = urlHandlers.UHConfModifCFARemoveOptFld
3593 def _checkParams( self, params ):
3594 RHConfModifCFABase._checkParams( self, params )
3595 self._fieldIds = []
3596 if params.get("fieldId","") != "":
3597 self._fieldIds = self._normaliseListParam( params["fieldId"] )
3599 def _process( self ):
3600 for id in self._fieldIds:
3601 self._conf.getAbstractMgr().removeAbstractField(id)
3602 self._redirect(urlHandlers.UHConfModifCFA.getURL(self._conf))
3604 class RHConfMoveAbsFieldUp( RHConfModifCFABase ):
3605 _uh = urlHandlers.UHConfModifCFAAbsFieldUp
3607 def _checkParams( self, params ):
3608 RHConfModifCFABase._checkParams( self, params )
3609 self._fieldId = params.get("fieldId", "")
3611 def _process( self ):
3612 if self._fieldId != "":
3613 self._conf.getAbstractMgr().moveAbsFieldUp(self._fieldId)
3614 self._redirect(urlHandlers.UHConfModifCFA.getURL(self._conf))
3616 class RHConfMoveAbsFieldDown( RHConfModifCFABase ):
3617 _uh = urlHandlers.UHConfModifCFAAbsFieldDown
3619 def _checkParams( self, params ):
3620 RHConfModifCFABase._checkParams( self, params )
3621 self._fieldId = params.get("fieldId", "")
3623 def _process( self ):
3624 if self._fieldId != "":
3625 self._conf.getAbstractMgr().moveAbsFieldDown(self._fieldId)
3626 self._redirect(urlHandlers.UHConfModifCFA.getURL(self._conf))
3629 class RHScheduleMoveEntryUp(RHConferenceModifBase):
3631 def _checkParams(self, params):
3632 RHConferenceModifBase._checkParams(self, params)
3633 self._entry=self._conf.getSchedule().getEntryById(params.get("schEntryId",""))
3635 def _process(self):
3636 date=None
3637 if self._entry is not None:
3638 self._conf.getSchedule().moveUpEntry(self._entry)
3639 date=self._entry.getStartDate()
3640 if date is None:
3641 self._redirect(urlHandlers.UHConfModifSchedule.getURL(self._conf))
3642 else:
3643 self._redirect("%s#%s"%(urlHandlers.UHConfModifSchedule.getURL(self._conf),date.strftime("%Y-%m-%d")))
3646 class RHScheduleMoveEntryDown(RHConferenceModifBase):
3648 def _checkParams(self, params):
3649 RHConferenceModifBase._checkParams(self, params)
3650 self._entry=self._conf.getSchedule().getEntryById(params.get("schEntryId",""))
3652 def _process(self):
3653 date=None
3654 if self._entry is not None:
3655 self._conf.getSchedule().moveDownEntry(self._entry)
3656 date=self._entry.getStartDate()
3657 if date is None:
3658 self._redirect(urlHandlers.UHConfModifSchedule.getURL(self._conf))
3659 else:
3660 self._redirect("%s#%s"%(urlHandlers.UHConfModifSchedule.getURL(self._conf),date.strftime("%Y-%m-%d")))
3663 class RHReschedule(RHConferenceModifBase):
3665 def _checkParams(self, params):
3666 RHConferenceModifBase._checkParams(self, params)
3667 self._cancel=params.has_key("CANCEL")
3668 self._ok=params.has_key("OK")
3669 self._hour=params.get("hour","")
3670 self._minute=params.get("minute","")
3671 self._action=params.get("action","duration")
3672 self._fit= params.get("fit","noFit") == "doFit"
3673 self._targetDay=params.get("targetDay",None) #comes in format YYYYMMDD, ex: 20100317
3674 self._sessionId = params.get("sessionId", "")
3675 if self._targetDay is None:
3676 raise MaKaCError( _("Error while rescheduling timetable: not target day"))
3677 else:
3678 self._day=timezone(self._conf.getTimezone()).localize(datetime(int(params["targetDay"][0:4]),
3679 int(params["targetDay"][4:6]),
3680 int(params["targetDay"][6:8])))
3681 if self._ok:
3682 if self._hour.strip() == "" or self._minute.strip() == "":
3683 raise FormValuesError( _("Please write the time with the format HH:MM. For instance, 00:05 to indicate 'O hours' and '5 minutes'"))
3684 try:
3685 if int(self._hour) or int(self._hour):
3686 pass
3687 except ValueError, e:
3688 raise FormValuesError( _("Please write a number to specify the time HH:MM. For instance, 00:05 to indicate 'O hours' and '5 minutes'"))
3690 def _process(self):
3691 if not self._cancel:
3692 if not self._ok:
3693 p = conferences.WPConfModifReschedule(self, self._conf, self._targetDay)
3694 return p.display()
3695 else:
3696 t = timedelta(hours=int(self._hour), minutes=int(self._minute))
3697 if self._sessionId:
3698 self._conf.getSessionById(self._sessionId).getSchedule().rescheduleTimes(self._action, t, self._day, self._fit)
3699 self._redirect("%s#%s" % (urlHandlers.UHSessionModifSchedule.getURL(self._conf.getSessionById(self._sessionId)), self._targetDay))
3700 else :
3701 self._conf.getSchedule().rescheduleTimes(self._action, t, self._day, self._fit)
3702 self._redirect("%s#%s" % (urlHandlers.UHConfModifSchedule.getURL(self._conf), self._targetDay))
3705 class RHRelocate(RHConferenceModifBase):
3707 def _checkParams(self, params):
3708 RHConferenceModifBase._checkParams(self, params)
3709 self._entry=None
3710 if params.has_key("contribId"):
3711 self._entry = self._conf.getContributionById(params.get("contribId",""))
3712 self._schEntry = self._entry.getSchEntry()
3713 elif params.has_key("schEntryId"):
3714 if params.has_key("sessionId") and params.has_key("slotId"):
3715 self._oldSch = self._conf.getSessionById(params.get("sessionId","")).getSlotById(params.get("slotId","")).getSchedule()
3716 else:
3717 self._oldSch = self._conf.getSchedule()
3718 try:
3719 self._schEntry = self._entry = self._oldSch.getEntryById(params.get("schEntryId",""))
3720 except:
3721 raise MaKaCError( _("Cannot find target item"))
3722 else:
3723 raise MaKaCError( _("No contribution to relocate"))
3724 self._contribPlace=params.get("targetId","")
3725 self._cancel=params.has_key("CANCEL")
3726 self._ok=params.has_key("OK")
3727 self._targetDay=params.get("targetDay","")
3728 self._check=int(params.get("check","1"))
3730 def _process(self):
3731 if not self._cancel:
3732 if not self._ok:
3733 p=conferences.WPConfModifRelocate(self,self._conf, self._entry, self._targetDay)
3734 return p.display()
3735 else:
3736 if self._contribPlace.strip() != "":
3737 if self._contribPlace!="conf":
3738 s,ss=self._contribPlace.split(":")
3739 session=self._conf.getSessionById(s)
3740 if session is not None:
3741 slot=session.getSlotById(ss)
3742 if slot is not None:
3743 self._schEntry.getSchedule().removeEntry(self._schEntry)
3744 if isinstance(self._entry, conference.Contribution):
3745 self._entry.setSession(session)
3746 slot.getSchedule().addEntry(self._schEntry, check=self._check)
3747 else:
3748 self._schEntry.getSchedule().removeEntry(self._schEntry)
3749 self._conf.getSchedule().addEntry(self._schEntry, check=self._check)
3750 self._redirect("%s#%s"%(urlHandlers.UHConfModifSchedule.getURL(self._conf), self._targetDay))
3752 class RHMaterialsAdd(RHSubmitMaterialBase, RHConferenceModifBase):
3753 _uh = urlHandlers.UHConfModifAddMaterials
3755 def __init__(self):
3756 RHConferenceModifBase.__init__(self)
3757 RHSubmitMaterialBase.__init__(self)
3759 def _checkParams(self, params):
3760 RHConferenceModifBase._checkParams(self, params)
3761 RHSubmitMaterialBase._checkParams(self, params)
3764 class RHMaterialsShow(RHConferenceModifBase):
3765 _uh = urlHandlers.UHConfModifShowMaterials
3767 def _process( self ):
3768 if self._target.isClosed():
3769 p = conferences.WPConferenceModificationClosed( self, self._target )
3770 return p.display()
3772 p = conferences.WPConfModifExistingMaterials( self, self._target )
3773 return p.display()
3775 # ============================================================================
3776 # === Badges related =========================================================
3777 # ============================================================================
3779 ##------------------------------------------------------------------------------------------------------------
3780 class RHConfBadgeBase(RHConferenceModifBase):
3782 def _checkProtection( self ):
3783 if not self._target.canManageRegistration(self.getAW().getUser()):
3784 RHConferenceModifBase._checkProtection(self)
3787 Badge Design and Printing classes
3789 class RHConfBadgePrinting(RHConfBadgeBase):
3790 """ This class corresponds to the screen where templates are
3791 listed and can be created, edited, deleted and tried.
3792 It always displays the list of templates; but we can
3793 arrive to this page in different scenarios:
3794 -A template has just been created (templateId = new template id, new = True). The template
3795 will be stored and the temporary backgrounds stored in the session object archived.
3796 -A template has been edited (templateId = existing template id, new = False or not set).
3797 The template will be updated and the temporary backgrounds stored in it, archived.
3798 -A template had been deleted (deleteTemplateId = id of the template to delete)
3799 -We were creating / editing a template but we pressed the "Cancel" button
3800 (templateId = id of the template that was being created / edited, Cancel = True).
3801 Temporary backgrounds (in the session object or in the template object) will be deleted.
3804 def _checkParams(self, params):
3805 RHConfBadgeBase._checkParams(self, params)
3806 self.__templateId = params.get("templateId",None)
3807 self.__templateData = params.get("templateData",None)
3808 self.__deleteTemplateId = params.get("deleteTemplateId",None)
3809 self.__copyTemplateId = params.get("copyTemplateId",None)
3810 self.__new = params.get("new","False") == "True"
3811 self.__cancel = params.get("cancel","False") == "True"
3813 def _process(self):
3814 if self._target.isClosed():
3815 return conferences.WPConferenceModificationClosed(self, self._target).display()
3816 else:
3817 if self.__templateId and self.__templateData and not self.__deleteTemplateId:
3819 if self.__new:
3820 self._target.getBadgeTemplateManager().storeTemplate(self.__templateId, self.__templateData)
3821 key = "tempBackground-%s-%s" % (self._conf.id, self.__templateId)
3822 filePaths = session.get(key)
3823 if filePaths:
3824 cfg = Config.getInstance()
3825 tempPath = cfg.getUploadedFilesSharedTempDir()
3826 for filePath in filePaths:
3827 self._target.getBadgeTemplateManager().getTemplateById(self.__templateId).addTempBackgroundFilePath(filePath)
3828 self._tempFilesToDelete.append(os.path.join(tempPath, filePath))
3829 self._target.getBadgeTemplateManager().getTemplateById(self.__templateId).archiveTempBackgrounds(self._conf)
3830 else:
3831 self._target.getBadgeTemplateManager().storeTemplate(self.__templateId, self.__templateData)
3833 elif self.__deleteTemplateId:
3834 self._target.getBadgeTemplateManager().deleteTemplate(self.__deleteTemplateId)
3836 elif self.__copyTemplateId:
3837 self._target.getBadgeTemplateManager().copyTemplate(self.__copyTemplateId)
3838 elif self.__cancel:
3839 if self._target.getBadgeTemplateManager().hasTemplate(self.__templateId):
3840 self._target.getBadgeTemplateManager().getTemplateById(self.__templateId).deleteTempBackgrounds()
3841 else:
3842 key = "tempBackground-%s-%s" % (self._conf.id, self.__templateId)
3843 session.pop(key, None)
3845 if self._target.getId() == "default":
3846 p = admins.WPBadgeTemplates(self)
3847 url = urlHandlers.UHBadgeTemplates.getURL()
3848 else:
3849 p = conferences.WPConfModifBadgePrinting(self, self._target)
3850 url = urlHandlers.UHConfModifBadgePrinting.getURL(self._target)
3851 if request.method == 'POST':
3852 self._redirect(url)
3853 else:
3854 return p.display()
3857 class RHConfBadgeDesign(RHConfBadgeBase):
3858 """ This class corresponds to the screen where templates are
3859 designed. We can arrive to this screen from different scenarios:
3860 -We are creating a new template (templateId = new template id, new = True)
3861 -We are editing an existing template (templateId = existing template id, new = False or not set)
3864 def _checkParams(self, params):
3865 RHConfBadgeBase._checkParams(self, params)
3866 self.__templateId = params.get("templateId",None)
3867 new = params.get("new",'False')
3868 if new == 'False':
3869 self.__new = False
3870 else:
3871 self.__new = True
3872 self.__baseTemplate = params.get("baseTemplate",'blank')
3875 def _process(self):
3876 if self._target.isClosed():
3877 p = conferences.WPConferenceModificationClosed( self, self._target )
3878 else:
3879 p = conferences.WPConfModifBadgeDesign(self, self._target, self.__templateId, self.__new, self.__baseTemplate)
3880 return p.display()
3882 class RHConfBadgePrintingPDF(RHConfBadgeBase):
3883 """ This class is used to print the PDF from a badge template.
3884 There are 2 scenarios:
3885 -We are printing badges for all registrants (registrantList = 'all' or not set).
3886 -We are printing badges just for some registrants (registrantList = list of id's of registrants)
3889 def _checkParams(self, params):
3890 """ Default values (1.5, etc...) are CERN's defaults in cm.
3891 These default values also appear in ConfModifBadgePDFOptions.tpl
3892 marginTop: top margin
3893 marginBottom: bottom margin
3894 marginLeft: left margin
3895 marginRight: right margin
3896 marginColumns: margin between columns
3897 marginRows: margin between rows
3898 keepPDFOptions: tells if we should keep the other params for the next time
3899 by storing them in the database (in the conference object)
3901 RHConfBadgeBase._checkParams(self, params)
3903 self.__templateId = params.get("templateId",None)
3905 #we retrieve the present PDF options of the conference in order to use
3906 #its values in case of input error
3907 self.__PDFOptions = self._target.getBadgeTemplateManager().getPDFOptions()
3909 self.__keepPDFOptions = params.get("keepPDFOptions", False)
3910 #in case of input error, this will be set to False
3912 try:
3913 self.__marginTop = float(params.get("marginTop",''))
3914 except ValueError:
3915 self.__marginTop = self.__PDFOptions.getTopMargin()
3916 self.__keepPDFOptions = False
3918 try:
3919 self.__marginBottom = float(params.get("marginBottom",''))
3920 except ValueError:
3921 self.__marginBottom = self.__PDFOptions.getBottomMargin()
3922 self.__keepPDFOptions = False
3924 try:
3925 self.__marginLeft = float(params.get("marginLeft",''))
3926 except ValueError:
3927 self.__marginLeft = self.__PDFOptions.getLeftMargin()
3928 self.__keepPDFOptions = False
3930 try:
3931 self.__marginRight = float(params.get("marginRight",''))
3932 except ValueError:
3933 self.__marginRight = self.__PDFOptions.getRightMargin()
3934 self.__keepPDFOptions = False
3936 try:
3937 self.__marginColumns = float(params.get("marginColumns",''))
3938 except ValueError:
3939 self.__marginColumns = self.__PDFOptions.getMarginColumns()
3940 self.__keepPDFOptions = False
3942 try:
3943 self.__marginRows = float(params.get("marginRows",''))
3944 except ValueError:
3945 self.__marginRows = self.__PDFOptions.getMarginRows()
3946 self.__keepPDFOptions = False
3948 self.__pagesize = params.get("pagesize",'A4')
3950 self.__drawDashedRectangles = params.get("drawDashedRectangles", False) is not False
3951 self.__landscape = params.get('landscape') == '1'
3953 self.__registrantList = params.get("registrantList","all")
3954 if self.__registrantList != "all":
3955 self.__registrantList = self.__registrantList.split(',')
3958 def _process(self):
3959 if self._target.isClosed():
3960 p = conferences.WPConferenceModificationClosed( self, self._target )
3961 return p
3962 else:
3963 if self._conf.getRegistrantsList() == []:
3964 return _("There are no registrants, so no badges to print.")
3965 elif self.__templateId == None:
3966 return _("There is no badge template selected for this conference.")
3968 if self.__keepPDFOptions:
3969 #we store the pdf options into the conference
3970 self.__PDFOptions.setTopMargin(self.__marginTop)
3971 self.__PDFOptions.setBottomMargin(self.__marginBottom)
3972 self.__PDFOptions.setLeftMargin(self.__marginLeft)
3973 self.__PDFOptions.setRightMargin(self.__marginRight)
3974 self.__PDFOptions.setMarginColumns(self.__marginColumns)
3975 self.__PDFOptions.setMarginRows(self.__marginRows)
3976 self.__PDFOptions.setPagesize(self.__pagesize)
3977 self.__PDFOptions.setDrawDashedRectangles(self.__drawDashedRectangles)
3978 self.__PDFOptions.setLandscape(self.__landscape)
3981 pdf = RegistrantsListToBadgesPDF(self._conf,
3982 self._conf.getBadgeTemplateManager().getTemplateById(self.__templateId),
3983 self.__marginTop,
3984 self.__marginBottom,
3985 self.__marginLeft,
3986 self.__marginRight,
3987 self.__marginColumns,
3988 self.__marginRows,
3989 self.__pagesize,
3990 self.__drawDashedRectangles,
3991 self.__registrantList,
3992 self.__landscape)
3993 return send_file('Badges.pdf', StringIO(pdf.getPDFBin()), 'PDF')
3996 class RHConfBadgeSaveTempBackground(RHConfBadgeBase):
3997 """ This class is used to save a background as a temporary file,
3998 before it is archived. Temporary backgrounds are archived
3999 after pressing the "save" button.
4000 The temporary background filepath can be stored in the session
4001 object (if we are creating a new template and it has not been stored yet)
4002 or in the corresponding template if we are editing a template.
4005 def _getNewTempFile( self ):
4006 cfg = Config.getInstance()
4007 tempPath = cfg.getUploadedFilesSharedTempDir()
4008 tempFileName = tempfile.mkstemp( suffix="IndicoBadgeBG.tmp", dir = tempPath )[1]
4009 return tempFileName
4011 def _saveFileToTemp(self, fs):
4012 fileName = self._getNewTempFile()
4013 fs.save(fileName)
4014 return os.path.split(fileName)[-1]
4016 def _checkParams(self, params):
4017 RHConfBadgeBase._checkParams(self, params)
4018 self.__templateId = params.get("templateId",None)
4019 try:
4020 self._tempFilePath = self._saveFileToTemp(params["file"])
4021 except AttributeError:
4022 self._tempFilePath = None
4024 def _process(self):
4025 if self._target.isClosed():
4026 return json.dumps({'status': 'error'}, textarea=True)
4027 else:
4028 if self._tempFilePath is not None:
4029 if self._conf.getBadgeTemplateManager().hasTemplate(self.__templateId):
4030 backgroundId = self._conf.getBadgeTemplateManager().getTemplateById(self.__templateId).addTempBackgroundFilePath(self._tempFilePath)
4031 else:
4032 key = "tempBackground-%s-%s" % (self._conf.id, self.__templateId)
4033 value = session.get(key)
4034 if value is None:
4035 tempFilePathList = PersistentList()
4036 tempFilePathList.append(self._tempFilePath)
4037 session[key] = tempFilePathList
4038 backgroundId = 0
4039 else:
4040 value.append(self._tempFilePath)
4041 backgroundId = len(value) - 1
4042 session.modified = True
4044 return json.dumps({
4045 'status': 'OK',
4046 'id': backgroundId,
4047 'url': str(urlHandlers.UHConfModifBadgeGetBackground.getURL(self._conf, self.__templateId, backgroundId))
4048 }, textarea=True)
4050 class RHConfBadgeGetBackground(RHConfBadgeBase):
4051 """ Class used to obtain a background in order to display it
4052 on the Badge Design screen.
4053 The background can be obtained from the archived files
4054 or from the temporary files.
4057 def _checkParams(self, params):
4058 RHConfBadgeBase._checkParams(self, params)
4059 self.__templateId = params.get("templateId",None)
4060 self.__backgroundId = int(params.get("backgroundId",None))
4061 self.__width = int(params.get("width","-1"))
4062 self.__height = int(params.get("height","-1"))
4064 def __imageBin(self, image):
4065 mimetype = image.getFileType() or 'application/octet-stream'
4066 return send_file(image.getFileName(), image.getFilePath(), mimetype)
4068 def __fileBin(self, filePath):
4069 return send_file('tempBackground', filePath, 'application/octet-stream')
4071 def _process(self):
4072 if self._target.isClosed():
4073 p = conferences.WPConferenceModificationClosed( self, self._target )
4074 return p
4075 else:
4076 cfg = Config.getInstance()
4077 tempPath = cfg.getUploadedFilesSharedTempDir()
4078 if self._conf.getBadgeTemplateManager().hasTemplate(self.__templateId):
4079 isArchived, image = self._conf.getBadgeTemplateManager().getTemplateById(self.__templateId).getBackground(self.__backgroundId)
4080 if image is not None:
4081 if isArchived:
4082 return self.__imageBin(image)
4083 else:
4084 image = os.path.join(tempPath,image)
4085 return self.__fileBin(image)
4087 else:
4088 key = "tempBackground-%s-%s" % (self._conf.id, self.__templateId)
4089 filePath = os.path.join(tempPath, session[key][int(self.__backgroundId)])
4090 return self.__fileBin(filePath)
4093 # ============================================================================
4094 # === Posters related ========================================================
4095 # ============================================================================
4097 ##------------------------------------------------------------------------------------------------------------
4099 Poster Design and Printing classes
4101 class RHConfPosterPrinting(RHConferenceModifBase):
4102 """ This class corresponds to the screen where templates are
4103 listed and can be created, edited, deleted and tried.
4104 It always displays the list of templates; but we can
4105 arrive to this page in different scenarios:
4106 -A template has just been created (templateId = new template id, new = True). The template
4107 will be stored and the temporary backgrounds stored in the session object archived.
4108 -A template has been edited (templateId = existing template id, new = False or not set).
4109 The template will be updated and the temporary backgrounds stored in it, archived.
4110 -A template had been deleted (deleteTemplateId = id of the template to delete)
4111 -We were creating / editing a template but we pressed the "Cancel" button
4112 (templateId = id of the template that was being created / edited, Cancel = True).
4113 Temporary backgrounds (in the session object or in the template object) will be deleted.
4116 def _checkParams(self, params):
4117 RHConferenceModifBase._checkParams(self, params)
4118 self.__templateId = params.get("templateId",None)
4119 self.__templateData = params.get("templateData",None)
4120 self.__deleteTemplateId = params.get("deleteTemplateId",None)
4121 self.__copyTemplateId = params.get("copyTemplateId",None)
4122 self.__bgPosition = params.get("bgPosition",None)
4123 self.__new = params.get("new","False") == "True"
4124 self.__cancel = params.get("cancel","False") == "True"
4127 def _process(self):
4128 if self._target.isClosed():
4129 return conferences.WPConferenceModificationClosed(self, self._target).display()
4130 else:
4131 if self.__templateId and self.__templateData and not self.__deleteTemplateId:
4132 if self.__new:
4133 # template is new
4134 self._target.getPosterTemplateManager().storeTemplate(self.__templateId, self.__templateData)
4135 key = "tempBackground-%s-%s" % (self._conf.id, self.__templateId)
4136 filePaths = session.get(key)
4137 if filePaths:
4138 for filePath in filePaths:
4139 self._target.getPosterTemplateManager().getTemplateById(self.__templateId).addTempBackgroundFilePath(filePath[0],filePath[1])
4140 self._target.getPosterTemplateManager().getTemplateById(self.__templateId).archiveTempBackgrounds(self._conf)
4141 else:
4142 # template already exists
4143 self._target.getPosterTemplateManager().storeTemplate(self.__templateId, self.__templateData)
4144 elif self.__deleteTemplateId:
4145 self._target.getPosterTemplateManager().deleteTemplate(self.__deleteTemplateId)
4146 elif self.__copyTemplateId:
4147 self._target.getPosterTemplateManager().copyTemplate(self.__copyTemplateId)
4148 elif self.__cancel:
4149 if self._target.getPosterTemplateManager().hasTemplate(self.__templateId):
4150 self._target.getPosterTemplateManager().getTemplateById(self.__templateId).deleteTempBackgrounds()
4151 else:
4152 fkey = "tempBackground-%s-%s" % (self._conf.id, self.__templateId)
4153 session.pop(fkey, None)
4155 if self._target.getId() == "default":
4156 p = admins.WPPosterTemplates(self)
4157 url = urlHandlers.UHPosterTemplates.getURL()
4158 else:
4159 p = conferences.WPConfModifPosterPrinting(self, self._target)
4160 url = urlHandlers.UHConfModifPosterPrinting.getURL(self._target)
4161 if request.method == 'POST':
4162 self._redirect(url)
4163 else:
4164 return p.display()
4167 class RHConfPosterDesign(RHConferenceModifBase):
4168 """ This class corresponds to the screen where templates are
4169 designed. We can arrive to this screen from different scenarios:
4170 -We are creating a new template (templateId = new template id, new = True)
4171 -We are editing an existing template (templateId = existing template id, new = False or not set)
4174 def _checkParams(self, params):
4175 RHConferenceModifBase._checkParams(self, params)
4176 self.__templateId = params.get("templateId",None)
4177 new = params.get("new",'False')
4178 if new == 'False':
4179 self.__new = False
4180 else:
4181 self.__new = True
4182 self.__baseTemplate = params.get("baseTemplate",'blank')
4184 def _process(self):
4185 if self._target.isClosed():
4186 p = conferences.WPConferenceModificationClosed( self, self._target )
4187 else:
4188 if (self._target.getId() == "default"):
4189 p = admins.WPPosterTemplateDesign(self, self._target, self.__templateId, self.__new)
4190 else:
4191 if self.__new == True and self.__baseTemplate != 'blank':
4192 dconf = conference.CategoryManager().getDefaultConference()
4193 templMan = self._target.getPosterTemplateManager()
4194 newId = self.__templateId
4195 dconf.getPosterTemplateManager().getTemplateById(self.__baseTemplate).clone(templMan, newId)
4196 url = urlHandlers.UHConfModifPosterPrinting().getURL(self._target)
4197 self._redirect(url)
4198 return
4199 else:
4200 p = conferences.WPConfModifPosterDesign(self, self._target, self.__templateId, self.__new, self.__baseTemplate)
4201 return p.display()
4203 class RHConfPosterPrintingPDF(RHConferenceModifBase):
4205 This class is used to print the PDF from a poster template.
4207 def _checkParams(self, params):
4208 RHConferenceModifBase._checkParams(self, params)
4209 self.__templateId = params.get("templateId",None)
4210 if self.__templateId == None:
4211 raise FormValuesError(_("Poster not selected"))
4212 if self.__templateId.find('global') != -1:
4213 self.__templateId = self.__templateId.replace('global','')
4214 self.__template = conference.CategoryManager().getDefaultConference().getPosterTemplateManager().getTemplateById(self.__templateId)
4215 else:
4216 self.__template = self._conf.getPosterTemplateManager().getTemplateById(self.__templateId)
4217 try:
4218 self.__marginH = int(params.get("marginH",'2'))
4219 except ValueError:
4220 self.__marginH = 2
4221 try:
4222 self.__marginV = int(params.get("marginV",'2'))
4223 except ValueError:
4224 self.__marginV = 2
4225 self.__pagesize = params.get("pagesize",'A4')
4228 def _process(self):
4229 if self._target.isClosed():
4230 p = conferences.WPConferenceModificationClosed( self, self._target )
4231 return p
4232 else:
4233 pdf = LectureToPosterPDF(self._conf,
4234 self.__template,
4235 self.__marginH,
4236 self.__marginV,
4237 self.__pagesize)
4239 return send_file('Poster.pdf', StringIO(pdf.getPDFBin()), 'PDF')
4242 class RHConfPosterSaveTempBackground(RHConferenceModifBase):
4243 """ This class is used to save a background as a temporary file,
4244 before it is archived. Temporary backgrounds are archived
4245 after pressing the "save" button.
4246 The temporary background filepath can be stored in the session
4247 object (if we are creating a new template and it has not been stored yet)
4248 or in the corresponding template if we are editing a template.
4251 def _getNewTempFile( self ):
4252 cfg = Config.getInstance()
4253 tempPath = cfg.getUploadedFilesSharedTempDir()
4254 tempFileName = tempfile.mkstemp( suffix="IndicoPosterBG.tmp", dir = tempPath )[1]
4255 return tempFileName
4257 def _saveFileToTemp(self, fs):
4258 fileName = self._getNewTempFile()
4259 fs.save(fileName)
4260 return os.path.split(fileName)[-1]
4262 def _checkParams(self, params):
4263 RHConferenceModifBase._checkParams(self, params)
4264 self.__templateId = params.get("templateId",None)
4266 self._bgPosition = params.get("bgPosition",None)
4268 try:
4269 self._tempFilePath = self._saveFileToTemp(params["file"])
4270 except AttributeError:
4271 self._tempFilePath = None
4273 def _process(self):
4274 if self._target.isClosed():
4275 return json.dumps({'status': 'error'}, textarea=True)
4276 else:
4277 if self._tempFilePath is not None:
4278 if self._conf.getPosterTemplateManager().hasTemplate(self.__templateId):
4279 # Save
4280 backgroundId = self._conf.getPosterTemplateManager().getTemplateById(self.__templateId).addTempBackgroundFilePath(self._tempFilePath,self._bgPosition)
4281 else:
4282 # New
4283 key = "tempBackground-%s-%s" % (self._conf.id, self.__templateId)
4284 value = session.get(key)
4285 if value is None:
4286 # First background
4287 tempFilePathList = PersistentList()
4288 tempFilePathList.append((self._tempFilePath,self._bgPosition))
4289 session[key] = tempFilePathList
4290 backgroundId = 0
4291 else:
4292 # We have more
4293 value.append((self._tempFilePath, self._bgPosition))
4294 backgroundId = len(value) - 1
4295 session.modified = True
4297 return json.dumps({
4298 'status': 'OK',
4299 'id': backgroundId,
4300 'url': str(urlHandlers.UHConfModifPosterGetBackground.getURL(self._conf, self.__templateId, backgroundId)),
4301 'pos': self._bgPosition
4302 }, textarea=True)
4305 class RHConfPosterGetBackground(RHConferenceModifBase):
4306 """ Class used to obtain a background in order to display it
4307 on the Poster Design screen.
4308 The background can be obtained from the archived files
4309 or from the temporary files.
4312 def _checkParams(self, params):
4313 RHConferenceModifBase._checkParams(self, params)
4314 self.__templateId = params.get("templateId",None)
4315 self.__backgroundId = int(params.get("backgroundId",None))
4316 self.__width = int(params.get("width","-1"))
4317 self.__height = int(params.get("height","-1"))
4319 def __imageBin(self, image):
4320 mimetype = image.getFileType() or 'application/octet-stream'
4321 return send_file(image.getFileName(), image.getFilePath(), mimetype)
4323 def __fileBin(self, filePath):
4324 return send_file('tempBackground', filePath, mimetype='application/octet-stream')
4326 def _process(self):
4328 if self._target.isClosed():
4329 p = conferences.WPConferenceModificationClosed( self, self._target )
4330 return p
4331 else:
4332 cfg = Config.getInstance()
4333 tempPath = cfg.getUploadedFilesSharedTempDir()
4335 if self._conf.getPosterTemplateManager().hasTemplate(self.__templateId):
4337 isArchived, image = self._conf.getPosterTemplateManager().getTemplateById(self.__templateId).getBackground(self.__backgroundId)
4339 if image is not None:
4340 if isArchived:
4341 return self.__imageBin(image)
4342 else:
4343 image = os.path.join(tempPath,image)
4344 return self.__fileBin(image)
4346 else:
4347 key = "tempBackground-%s-%s" % (self._conf.id, self.__templateId)
4348 filePath = os.path.join(tempPath, session[key][int(self.__backgroundId)][0])
4349 return self.__fileBin(filePath)