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/>.
18 from cStringIO
import StringIO
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
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
):
84 def _displayDefaultPage(self
):
88 wf
= self
.getWebFactory()
90 res
= self
._displayCustomPage
(wf
)
93 return self
._displayDefaultPage
()
96 class RHConferenceModification(RHConferenceModifBase
):
97 _uh
= urlHandlers
.UHConferenceModification
101 wf
=self
.getWebFactory()
103 pars
["type"]=wf
.getId()
104 if self
._conf
.isClosed():
105 p
= conferences
.WPConferenceModificationClosed( self
, self
._target
)
106 return p
.display(**pars
)
108 p
= conferences
.WPConferenceModification( self
, self
._target
)
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
)
121 if params
.has_key("CANCEL"):
122 self
._action
="CANCEL"
123 elif params
.has_key("OK"):
125 self
._sDate
,self
._eDate
=None,None
126 tz
= self
._target
.getTimezone()
127 if params
.get("start_date","conference")=="own":
129 self
._sDate
=timezone(tz
).localize(datetime(int(params
["sYear"]),
130 int(params
["sMonth"]),
132 int(params
["sHour"]),
133 int(params
["sMin"]))).astimezone(timezone('UTC'))
135 raise MaKaCError( _("Please enter integers in all the start date fields"), _("Schedule"))
136 if params
.get("end_date","conference")=="own":
138 self
._eDate
=timezone(tz
).localize(datetime(int(params
["eYear"]),
139 int(params
["eMonth"]),
141 int(params
["eHour"]),
142 int(params
["eMin"]))).astimezone(timezone('UTC'))
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":
151 elif self
._action
=="EDIT":
152 self
._target
.setScreenStartDate(self
._sDate
)
153 self
._target
.setScreenEndDate(self
._eDate
)
156 p
= conferences
.WPScreenDatesEdit(self
, self
._target
)
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
179 url
= urlHandlers
.UHConferenceDisplay
.getURL( self
._conf
)
180 self
._redirect
( url
)
182 class RHConferenceModifManagementAccess( RHConferenceModifKey
):
183 _uh
= urlHandlers
.UHConfManagementAccess
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
),
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
)
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
)
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)
219 url
= urlHandlers
.UHConfManagementAccess
.getURL( self
._conf
)
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", "")
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
239 url
= urlHandlers
.UHConferenceDisplay
.getURL(self
._conf
)
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")
254 url
= urlHandlers
.UHConferenceModification
.getURL(self
._conf
)
257 self
._target
.setClosed(True)
258 url
= urlHandlers
.UHConferenceModification
.getURL(self
._conf
)
261 return conferences
.WPConfClosing(self
, self
._conf
).display()
264 class RHConferenceOpen(RHConferenceModifBase
):
267 def _checkProtection(self
):
268 RHConferenceModifBase
._checkProtection
(self
)
270 user
= self
._getUser
()
271 if user
is self
._conf
.getCreator():
273 # If we are not the creator, check if we have category admin privileges
275 for owner
in self
._conf
.getOwnerList():
276 if owner
.canUserModify(user
): # category or system admin
280 if self
._conf
.isClosed():
281 raise ConferenceClosedError(self
._target
.getConference())
283 raise ModificationError()
285 def _checkParams(self
, params
):
286 RHConferenceBase
._checkParams
(self
, params
)
289 self
._target
.setClosed(False)
290 url
= urlHandlers
.UHConferenceModification
.getURL(self
._conf
)
294 class RHConfDataModif(RHConferenceModifBase
):
295 _uh
= urlHandlers
.UHConfDataModif
297 def _displayCustomPage(self
, wf
):
300 def _displayDefaultPage(self
):
301 p
= conferences
.WPConfDataModif(self
, self
._target
)
303 wf
= self
.getWebFactory()
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
):
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 :
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
)
350 elif params
['sessions'] == []:
351 p
= conferences
.WPConfModifScheduleGraphic( self
, self
._target
)
353 wf
=self
.getWebFactory()
355 p
=wf
.getConfModifSchedule( self
, self
._target
)
356 return p
.display(**params
)
359 session
= self
._target
.getSessionById(params
['sessions'][0])
361 p
= sessions
.WPSessionModifSchedule( self
, session
)
363 wf
=self
.getWebFactory()
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
)
374 if params
.has_key("CANCEL"):
375 self
._action
="CANCEL"
376 elif params
.has_key("OK"):
378 self
._sDate
,self
._eDate
=None,None
380 self
._sDate
=datetime(int(params
["sYear"]),
381 int(params
["sMonth"]),
383 int(params
["sHour"]),
386 raise MaKaCError( _("Please enter integers in all the start date fields"), _("Schedule"))
388 self
._eDate
=datetime(int(params
["eYear"]),
389 int(params
["eMonth"]),
391 int(params
["eHour"]),
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":
401 elif self
._action
=="EDIT":
403 # The times are naive relative to the conference tz, must
406 confTZ
= self
._target
.getTimezone()
407 sd
= timezone(confTZ
).localize(datetime(self
._sDate
.year
,
412 sdUTC
= sd
.astimezone(timezone('UTC'))
413 ed
= timezone(confTZ
).localize(datetime(self
._eDate
.year
,
418 edUTC
= ed
.astimezone(timezone('UTC'))
419 self
._target
.setDates(sdUTC
,edUTC
)
422 p
=conferences
.WPModScheduleDataEdit(self
,self
._target
)
426 class RConferenceGetSessions(RHConferenceModifBase
):
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
)
444 p
= conferences
.WPConfModifAC( self
, self
._target
)
445 wf
=self
.getWebFactory()
447 p
= wf
.getConfModifAC(self
, self
._conf
)
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
):
508 self
._redirect
( urlHandlers
.UHConfModifTools
.getURL( self
._conf
) )
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
) )
517 self
._redirect
( urlHandlers
.UHWelcome
.getURL() )
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()
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()
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()
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()
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",[]))
569 if selectedList
== []:
570 raise FormValuesError(_("No participant selected! Please select at least one."))
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()
586 return conferences
.WPConfModifParticipantsStatistics( self
, self
._target
).display()
588 #######################################################################################
590 class RHConfAllParticipants( RHConferenceModifBase
):
591 _uh
= urlHandlers
.UHConfAllSessionsConveners
594 p
= conferences
.WPConfAllParticipants( self
, self
._conf
)
598 #######################################################################################
600 class RHConfClone( RHConferenceModifBase
):
601 _uh
= urlHandlers
.UHConfClone
604 def _process( self
):
605 p
= conferences
.WPConfClone( self
, self
._conf
)
606 wf
=self
.getWebFactory()
608 p
= wf
.getConfClone(self
, self
._conf
)
612 #######################################################################################
614 class RHConfAllSessionsConveners( RHConferenceModifBase
):
615 _uh
= urlHandlers
.UHConfAllSessionsConveners
618 p
= conferences
.WPConfAllSessionsConveners( self
, self
._conf
)
619 # wf=self.getWebFactory()
621 # p = wf.getConfClone(self, self._conf)
625 class RHConfAllSessionsConvenersAction( RHConferenceModifBase
):
627 def _checkParams( self
, params
):
628 RHConferenceModifBase
._checkParams
(self
, params
)
629 self
._selectedConveners
= self
._normaliseListParam
(params
.get("conveners",[]))
631 def _process( self
):
632 if len(self
._selectedConveners
)>0:
633 p
= conferences
.WPEMailConveners(self
, self
._conf
, self
._selectedConveners
)
636 self
._redirect
(urlHandlers
.UHConfAllSessionsConveners
.getURL(self
._conf
))
638 class RHConvenerSendEmail( RHConferenceModifBase
):
640 def _checkParams(self
, params
):
641 RHConferenceModifBase
._checkParams
( self
, params
)
646 self
._send
= params
.has_key("OK")
648 if len(params
.get("toEmails","").strip()) > 0 :
649 self
._toEmails
= (params
.get("toEmails","").strip()).split(",")
651 raise FormValuesError( _("'To' address list is empty"))
652 if params
.get("from","") == "":
653 raise FormValuesError( _("Please write from address"))
654 if params
.get("subject","") == "":
655 raise FormValuesError( _("Please write a subject for the email"))
656 if params
.get("body","") == "":
657 raise FormValuesError( _("Please write a body for the email"))
659 cclist
= params
.get("cc","").strip().split(",")
660 # remove empty elements
663 # strip all the elements in the list
664 cclist
= map(lambda x
: x
.strip(), cclist
)
668 self
._params
["subject"]=params
["subject"]
669 self
._params
["from"]=params
["from"]
670 self
._params
["body"]=params
["body"]
671 self
._params
["cc"]=cclist
672 self
._params
["conf"] = self
._conf
673 self
._preview
= params
.has_key("preview")
677 self
._params
['to'] = self
._toEmails
678 registrantNotificator
.EmailNotificator().notifyAll(self
._params
)
679 p
= conferences
.WPConvenerSentEmail(self
, self
._target
)
682 self
._redirect
(urlHandlers
.UHConfAllSessionsConveners
.getURL(self
._conf
))
684 #######################################################################################
687 class RHConfAllSpeakers( RHConferenceModifBase
):
688 _uh
= urlHandlers
.UHConfAllSpeakers
691 p
= conferences
.WPConfAllSpeakers( self
, self
._conf
)
694 class RHConfAllSpeakersAction( RHConferenceModifBase
):
696 def _checkParams( self
, params
):
697 RHConferenceModifBase
._checkParams
(self
, params
)
698 self
._selectedSpeakers
= self
._normaliseListParam
(params
.get("participants",[]))
700 def _process( self
):
702 if len(self
._selectedSpeakers
)>0:
703 p
= conferences
.WPEMailContribParticipants(self
, self
._conf
, self
._selectedSpeakers
)
706 self
._redirect
(urlHandlers
.UHConfAllSpeakers
.getURL(self
._conf
))
708 class RHContribParticipantsSendEmail( RHConferenceModifBase
):
710 def _checkParams(self
, params
):
711 RHConferenceModifBase
._checkParams
( self
, params
)
716 self
._send
= params
.has_key("OK")
718 if len(params
.get("toEmails","").strip()) > 0 :
719 self
._toEmails
= (params
.get("toEmails","").strip()).split(",")
721 raise FormValuesError( _("'To' address list is empty"))
722 if params
.get("from","") == "":
723 raise FormValuesError( _("Please write from address"))
724 if params
.get("subject","") == "":
725 raise FormValuesError( _("Please write a subject for the email"))
726 if params
.get("body","") == "":
727 raise FormValuesError( _("Please write a body for the email"))
729 cclist
= params
.get("cc","").strip().split(",")
730 # remove empty elements
733 # strip all the elements in the list
734 cclist
= map(lambda x
: x
.strip(), cclist
)
738 self
._params
["subject"]=params
["subject"]
739 self
._params
["from"]=params
["from"]
740 self
._params
["body"]=params
["body"]
741 self
._params
["cc"]=cclist
742 self
._params
["conf"] = self
._conf
743 self
._preview
= params
.has_key("preview")
747 self
._params
['to'] = self
._toEmails
748 registrantNotificator
.EmailNotificator().notifyAll(self
._params
)
749 p
= conferences
.WPContribParticipationSentEmail(self
, self
._target
)
752 self
._redirect
(urlHandlers
.UHConfAllSpeakers
.getURL(self
._conf
))
755 #######################################################################################
758 class RHConfPerformCloning(RHConferenceModifBase
, object):
760 New version of clone functionality -
761 fully replace the old one, based on three different actions,
762 adds mechanism of selective cloning of materials and access
763 privileges attached to an event
765 _uh
= urlHandlers
.UHConfPerformCloning
769 def _checkParams( self
, params
):
770 RHConferenceModifBase
._checkParams
( self
, params
)
771 self
._date
= datetime
.today()
772 self
._cloneType
= params
.get("cloneType", None)
773 if self
._cloneType
is None:
774 raise FormValuesError( _("""Please choose a cloning interval for this event"""))
775 elif self
._cloneType
== "once" :
776 self
._date
= datetime( int(params
["stdyo"]), \
777 int(params
["stdmo"]), \
778 int(params
["stddo"]), \
779 int(self
._conf
.getAdjustedStartDate().hour
), \
780 int(self
._conf
.getAdjustedStartDate().minute
) )
781 elif self
._cloneType
== "intervals" :
782 self
._date
= datetime( int(params
["indyi"]), \
783 int(params
["indmi"]), \
784 int(params
["inddi"]), \
785 int(self
._conf
.getAdjustedStartDate().hour
), \
786 int(self
._conf
.getAdjustedStartDate().minute
) )
787 elif self
._cloneType
== "days" :
788 self
._date
= datetime( int(params
["indyd"]), \
789 int(params
["indmd"]), \
790 int(params
["inddd"]), \
791 int(self
._conf
.getAdjustedStartDate().hour
), \
792 int(self
._conf
.getAdjustedStartDate().minute
) )
793 self
._confirm
= params
.has_key( "confirm" )
794 self
._cancel
= params
.has_key( "cancel" )
796 def _process( self
):
797 params
= self
._getRequestParams
()
798 paramNames
= params
.keys()
799 options
= { "materials" : "cloneMaterials" in paramNames
,
800 "access" : "cloneAccess" in paramNames
,
801 "keys" : "cloneAccess" in paramNames
,
802 "authors" : "cloneTimetable" in paramNames
,
803 "contributions" : "cloneTimetable" in paramNames
,
804 "subcontribs" : "cloneTimetable" in paramNames
,
805 "sessions" : "cloneTimetable" in paramNames
,
806 "tracks" : "cloneTracks" in paramNames
,
807 "registration" : "cloneRegistration" in paramNames
,
808 "abstracts" : "cloneAbstracts" in paramNames
,
809 "participants" : "cloneParticipants" in paramNames
,
810 "evaluation" : "cloneEvaluation" in paramNames
,
811 "managing" : self
._getUser
()
813 #we notify the event in case any plugin wants to add their options
815 self
._redirect
( urlHandlers
.UHConfClone
.getURL( self
._conf
) )
817 if self
._cloneType
== "once" :
818 newConf
= self
._conf
.clone( self
._date
, options
, userPerformingClone
= self
._aw
._currentUser
)
819 self
._redirect
( urlHandlers
.UHConferenceModification
.getURL( newConf
) )
820 elif self
._cloneType
== "intervals" :
821 self
._withIntervals
(options
)
822 elif self
._cloneType
== "days" :
825 self
._redirect
( urlHandlers
.UHConfClone
.getURL( self
._conf
) )
827 if self
._cloneType
== "once" :
829 elif self
._cloneType
== "intervals" :
830 nbClones
= self
._withIntervals
(options
,0)
831 elif self
._cloneType
== "days" :
832 nbClones
= self
._days
(options
,0)
833 return conferences
.WPConfCloneConfirm( self
, self
._conf
, nbClones
).display()
835 def _withIntervals(self
, options
, confirmed
=1):
837 params
= self
._getRequestParams
()
838 if params
["freq"] == "day":
839 inter
= timedelta(int(params
["period"]))
840 elif params
["freq"] == "week":
841 inter
= timedelta( 7*int(params
["period"]))
843 if params
["intEndDateChoice"] == "until":
845 endDate
= datetime(int(params
["stdyi"]),int(params
["stdmi"]),int(params
["stddi"]), self
._conf
.getEndDate().hour
,self
._conf
.getEndDate().minute
)
846 while date
<= endDate
:
848 self
._conf
.clone(date
,options
, userPerformingClone
= self
._aw
._currentUser
)
850 if params
["freq"] == "day" or params
["freq"] == "week":
852 elif params
["freq"] == "month":
853 month
= int(date
.month
) + int(params
["period"])
854 year
= int(date
.year
)
858 date
= datetime(year
,month
,int(date
.day
), int(date
.hour
), int(date
.minute
))
859 elif params
["freq"] == "year":
860 date
= datetime(int(date
.year
)+int(params
["period"]),int(date
.month
),int(date
.day
), int(date
.hour
), int(date
.minute
))
862 elif params
["intEndDateChoice"] == "ntimes":
865 stop
= int(params
["numi"])
869 self
._conf
.clone(date
,options
, userPerformingClone
= self
._aw
._currentUser
)
871 if params
["freq"] == "day" or params
["freq"] == "week":
873 elif params
["freq"] == "month":
874 month
= int(date
.month
) + int(params
["period"])
875 year
= int(date
.year
)
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 self
._redirect
( urlHandlers
.UHCategoryDisplay
.getURL( self
._conf
.getOwner() ) )
888 def _getFirstDay(self
, date
, day
):
890 return the first day 'day' for the month of 'date'
892 td
= datetime(int(date
.year
), int(date
.month
), 1, int(date
.hour
), int(date
.minute
))
894 oneDay
= timedelta(1)
896 if td
.weekday() == day
:
900 def _getOpenDay(self
, date
, day
):
902 return the first open day for the month of 'date'
904 if day
!="last": # last open day of the month
905 td
= datetime(int(date
.year
), int(date
.month
), int(date
.day
), int(date
.hour
), int(date
.minute
))
907 td
= td
+ timedelta(7 - td
.weekday())
908 td
+= timedelta(int(day
)-1)
910 td
= self
._getLastDay
(date
, -1)
912 td
= td
- timedelta(td
.weekday() - 4)
915 def _getLastDay(self
, date
, day
):
917 return the last day 'day' for the month of 'date'
919 td
= datetime(int(date
.year
), int(date
.month
), 28, int(date
.hour
), int(date
.minute
))
921 while td
.month
== month
:
928 if td
.weekday() == day
:
930 td
= td
- timedelta(1)
932 def _days(self
, options
, confirmed
=1):
934 params
= self
._getRequestParams
()
935 #search the first day of the month
937 if params
["day"] == "NOVAL":
939 self
.redirect( urlHandlers
.UHConfClone
.getURL( self
._target
) )
941 if params
["daysEndDateChoice"] == "until":
944 endDate
= datetime(int(params
["stdyd"]),int(params
["stdmd"]),int(params
["stddd"]),self
._conf
.getEndDate().hour
,self
._conf
.getEndDate().minute
)
946 if params
["day"] == "OpenDay":
947 rd
= self
._getOpenDay
(date
, params
["order"])
949 if params
["order"] == "last":
950 rd
= self
._getLastDay
(date
, int(params
["day"]))
952 date
= (date
+ relativedelta(months
=1)).replace(day
=1)
954 rd
= self
._getFirstDay
(date
, int(params
["day"])) + timedelta((int(params
["order"])-1)*7)
956 date
= (date
+ relativedelta(months
=1)).replace(day
=1)
957 while date
<= endDate
:
958 if params
["day"] == "OpenDay":
959 od
=self
._getOpenDay
(date
,params
["order"])
962 self
._conf
.clone(od
, options
, userPerformingClone
= self
._aw
._currentUser
)
965 if params
["order"] == "last":
966 if self
._getLastDay
(date
,int(params
["day"])) <= endDate
:
968 self
._conf
.clone(self
._getLastDay
(date
,int(params
["day"])), options
, userPerformingClone
= self
._aw
._currentUser
)
971 if self
._getFirstDay
(date
, int(params
["day"])) + timedelta((int(params
["order"])-1)*7) <= endDate
:
973 self
._conf
.clone(self
._getFirstDay
(date
, int(params
["day"]))+ timedelta((int(params
["order"])-1)*7), options
, userPerformingClone
= self
._aw
._currentUser
)
975 month
= int(date
.month
) + int(params
["monthPeriod"])
976 year
= int(date
.year
)
980 date
= datetime(year
,month
,1, int(date
.hour
), int(date
.minute
))
982 elif params
["daysEndDateChoice"] == "ntimes":
985 if params
["day"] == "OpenDay":
986 rd
= self
._getOpenDay
(date
,params
["order"])
988 if params
["order"] == "last":
989 rd
= self
._getLastDay
(date
, int(params
["day"]))
991 date
= (date
+ relativedelta(months
=1)).replace(day
=1)
993 rd
= self
._getFirstDay
(date
, int(params
["day"])) + timedelta((int(params
["order"])-1)*7)
995 date
= (date
+ relativedelta(months
=1)).replace(day
=1)
998 stop
= int(params
["numd"])
1001 if params
["day"] == "OpenDay":
1003 self
._conf
.clone(self
._getOpenDay
(date
, params
["order"]), options
, userPerformingClone
= self
._aw
._currentUser
)
1006 if params
["order"] == "last":
1008 self
._conf
.clone(self
._getLastDay
(date
,int(params
["day"])), options
, userPerformingClone
= self
._aw
._currentUser
)
1012 self
._conf
.clone(self
._getFirstDay
(date
, int(params
["day"]))+ timedelta((int(params
["order"])-1)*7), options
, userPerformingClone
= self
._aw
._currentUser
)
1014 month
= int(date
.month
) + int(params
["monthPeriod"])
1015 year
= int(date
.year
)
1019 date
= datetime(year
,month
,int(date
.day
), int(date
.hour
), int(date
.minute
))
1021 self
._redirect
( urlHandlers
.UHCategoryDisplay
.getURL( self
._conf
.getOwner() ) )
1025 ####################################################################################
1028 class RHConfModifProgram( RHConferenceModifBase
):
1030 def _process( self
):
1031 p
= conferences
.WPConfModifProgram( self
, self
._target
)
1035 class RHConfAddTrack( RHConferenceModifBase
):
1037 def _process( self
):
1038 p
= conferences
.WPConfAddTrack( self
, self
._target
)
1042 class RHConfPerformAddTrack( RHConferenceModifBase
):
1044 def _checkParams( self
, params
):
1045 RHConferenceModifBase
._checkParams
( self
, params
)
1046 self
._cancel
= params
.has_key("cancel")
1048 def _process( self
):
1050 self
._redirect
( urlHandlers
.UHConfModifProgram
.getURL( self
._conf
) )
1052 t
= self
._conf
.newTrack()
1053 params
= self
._getRequestParams
()
1054 t
.setTitle(params
["title"])
1055 t
.setDescription(params
["description"])
1056 # Filtering criteria: by default make new contribution type checked
1057 dct
= session
.setdefault("ContributionFilterConf%s" % self
._conf
.getId(), {})
1059 #Append the new type to the existing list
1060 newDict
= dct
['tracks'][:]
1061 newDict
.append(t
.getId())
1062 dct
['tracks'] = newDict
[:]
1064 #Create a new entry for the dictionary containing the new type
1065 dct
['tracks'] = [t
.getId()]
1066 session
.modified
= True
1067 self
._redirect
( urlHandlers
.UHConfModifProgram
.getURL( self
._conf
) )
1069 class RHConfDelTracks( RHConferenceModifBase
):
1071 def _checkParams( self
, params
):
1072 RHConferenceModifBase
._checkParams
( self
, params
)
1073 self
._trackList
= []
1074 for id in self
._normaliseListParam
( params
.get("selTracks", []) ):
1075 self
._trackList
.append( self
._conf
.getTrackById( id ) )
1077 def _process( self
):
1078 for track
in self
._trackList
:
1079 self
._conf
.removeTrack( track
)
1080 self
._redirect
( urlHandlers
.UHConfModifProgram
.getURL( self
._conf
) )
1083 class RHProgramTrackUp(RHConferenceModifBase
):
1085 def _checkParams( self
, params
):
1086 RHConferenceModifBase
._checkParams
( self
, params
)
1087 self
._track
=self
._target
.getTrackById(params
.get("trackId",""))
1089 def _process( self
):
1090 self
._disableCaching
()
1091 self
._target
.moveUpTrack(self
._track
)
1092 self
._redirect
(urlHandlers
.UHConfModifProgram
.getURL(self
._conf
))
1095 class RHProgramTrackDown(RHConferenceModifBase
):
1097 def _checkParams( self
, params
):
1098 RHConferenceModifBase
._checkParams
( self
, params
)
1099 self
._track
=self
._target
.getTrackById(params
.get("trackId",""))
1101 def _process( self
):
1102 self
._disableCaching
()
1103 self
._target
.moveDownTrack(self
._track
)
1104 self
._redirect
(urlHandlers
.UHConfModifProgram
.getURL(self
._conf
))
1106 class CFAEnabled(object):
1108 def checkEnabled(request
):
1109 """ Returns true if abstracts has been enabled
1110 Otherwise, throws an exception
1112 if request
._conf
.hasEnabledSection("cfa"):
1115 raise MaKaCError( _("You cannot access this option because \"Abstracts\" was disabled"))
1117 class RHConfModifCFABase(RHConferenceModifBase
):
1119 def _checkProtection(self
):
1120 RHConferenceModifBase
._checkProtection
(self
)
1121 CFAEnabled
.checkEnabled(self
)
1123 class RHConfModifCFA(RHConfModifCFABase
):
1125 def _process( self
):
1126 p
= conferences
.WPConfModifCFA( self
, self
._target
)
1130 class RHConfModifCFAPreview(RHConfModifCFABase
):
1132 def _process( self
):
1133 p
= conferences
.WPConfModifCFAPreview( self
, self
._target
)
1137 class RHConfModifCFAStatus( RHConfModifCFABase
):
1139 def _checkParams( self
, params
):
1140 RHConfModifCFABase
._checkParams
( self
, params
)
1141 self
._newStatus
= params
["changeTo"]
1143 def _process( self
):
1144 if self
._newStatus
== "True":
1145 self
._conf
.getAbstractMgr().activeCFA()
1147 self
._conf
.getAbstractMgr().desactiveCFA()
1148 self
._redirect
( urlHandlers
.UHConfModifCFA
.getURL( self
._conf
) )
1151 class RHConfModifCFASwitchMultipleTracks( RHConfModifCFABase
):
1153 def _process( self
):
1154 self
._conf
.getAbstractMgr().setMultipleTracks(not self
._conf
.getAbstractMgr().getMultipleTracks())
1155 self
._redirect
( urlHandlers
.UHConfModifCFA
.getURL( self
._conf
) )
1157 class RHConfModifCFAMakeTracksMandatory( RHConfModifCFABase
):
1159 def _process( self
):
1160 self
._conf
.getAbstractMgr().setTracksMandatory(not self
._conf
.getAbstractMgr().areTracksMandatory())
1161 self
._redirect
( urlHandlers
.UHConfModifCFA
.getURL( self
._conf
) )
1164 class RHConfModifCFASwitchAttachFiles( RHConfModifCFABase
):
1166 def _process( self
):
1167 self
._conf
.getAbstractMgr().setAllowAttachFiles(not self
._conf
.getAbstractMgr().canAttachFiles())
1168 self
._redirect
( urlHandlers
.UHConfModifCFA
.getURL( self
._conf
) )
1171 class RHConfModifCFASwitchShowSelectAsSpeaker( RHConfModifCFABase
):
1173 def _process( self
):
1174 self
._conf
.getAbstractMgr().setShowSelectAsSpeaker(not self
._conf
.getAbstractMgr().showSelectAsSpeaker())
1175 self
._redirect
( urlHandlers
.UHConfModifCFA
.getURL( self
._conf
) )
1177 class RHConfModifCFASwitchSelectSpeakerMandatory( RHConfModifCFABase
):
1179 def _process( self
):
1180 self
._conf
.getAbstractMgr().setSelectSpeakerMandatory(not self
._conf
.getAbstractMgr().isSelectSpeakerMandatory())
1181 self
._redirect
( urlHandlers
.UHConfModifCFA
.getURL( self
._conf
) )
1183 class RHConfModifCFASwitchShowAttachedFilesContribList( RHConfModifCFABase
):
1185 def _process( self
):
1186 self
._conf
.getAbstractMgr().setSwitchShowAttachedFilesContribList(not self
._conf
.getAbstractMgr().showAttachedFilesContribList())
1187 self
._redirect
( urlHandlers
.UHConfModifCFA
.getURL( self
._conf
) )
1190 class RHCFADataModification( RHConfModifCFABase
):
1192 def _process( self
):
1193 p
= conferences
.WPCFADataModification( self
, self
._target
)
1197 class RHCFAPerformDataModification( RHConfModifCFABase
):
1199 def _checkParams( self
, params
):
1200 RHConfModifCFABase
._checkParams
( self
, params
)
1201 self
._cancel
= params
.has_key("cancel")
1202 self
._modifDL
= None
1203 mDay
= str( params
.get( "mDay", "" ) ).strip()
1204 mMonth
= str( params
.get( "mMonth", "" ) ).strip()
1205 mYear
= str( params
.get( "mYear", "" ) ).strip()
1206 if mDay
!= "" and mMonth
!="" and mYear
!= "":
1207 self
._modifDL
= datetime( int(mYear
), int(mMonth
), int(mDay
) )
1209 def _process( self
):
1211 self
._redirect
( urlHandlers
.UHConfModifCFA
.getURL( self
._conf
) )
1213 abMgr
= self
._conf
.getAbstractMgr()
1214 params
= self
._getRequestParams
()
1216 abMgr
.setStartSubmissionDate(datetime(int(params
["sYear"]), int(params
["sMonth"]), int(params
["sDay"])))
1217 abMgr
.setEndSubmissionDate(datetime(int(params
["eYear"]), int(params
["eMonth"]), int(params
["eDay"])))
1219 sDate
= datetime(int(params
["sYear"]), int(params
["sMonth"]), int(params
["sDay"]))
1220 except ValueError, e
:
1221 raise FormValuesError("The start date you have entered is not correct: %s" % e
, "Abstracts")
1223 eDate
= datetime(int(params
["eYear"]), int(params
["eMonth"]), int(params
["eDay"]))
1224 except ValueError, e
:
1225 raise FormValuesError("The end date you have entered is not correct: %s" % e
, "Abstracts")
1227 raise FormValuesError("End date can't be before start date!", "Abstracts")
1230 if params
["mYear"] or params
["mMonth"] or params
["mDay"]:
1231 mDate
= datetime(int(params
["mYear"]), int(params
["mMonth"]), int(params
["mDay"]))
1232 except ValueError, e
:
1233 raise FormValuesError("The modification end date you have entered is not correct: %s" % e
, "Abstracts")
1234 if mDate
is not None and mDate
< eDate
:
1235 raise FormValuesError("Modification end date must be after end date!", "Abstracts")
1237 abMgr
.setAnnouncement(params
["announcement"])
1238 abMgr
.setModificationDeadline(self
._modifDL
)
1239 abMgr
.getSubmissionNotification().setToList(utils
.getEmailList(params
.get("toList", "")))
1240 abMgr
.getSubmissionNotification().setCCList(utils
.getEmailList(params
.get("ccList", "")))
1241 self
._redirect
(urlHandlers
.UHConfModifCFA
.getURL(self
._conf
))
1244 class AbstractStatusFilter( filters
.FilterField
):
1245 """Contains the filtering criteria for the status of an abstract.
1247 Implements the logic to determine whether abstracts are within a list
1248 of abstract status. Objects of this class will keep a list of status
1249 names; then an abstract will satisfy the filter if it is in an abstract
1250 which name is included in the list of values.
1252 Inherits from: AbstractFilterField
1255 _values -- (list) List of abstract status names; if the name of the
1256 current status of an abstract is included in this list, the
1257 abstract will satisfy the filter field.
1258 _showNoValue -- (bool) Not used for this filter field.
1262 def satisfies( self
, abstract
):
1263 if len(AbstractStatusList
.getInstance().getStatusList()) == len(self
._values
):
1266 status
= AbstractStatusList
.getInstance().getId( abstract
.getCurrentStatus().__class
__ )
1267 return status
in self
._values
1269 def needsToBeApplied(self
):
1270 for s
in AbstractStatusList
.getStatusList():
1271 if AbstractStatusList
.getInstance().getId(s
) not in self
._values
:
1276 class AbstractFilterCriteria(filters
.FilterCriteria
):
1279 _availableFields
= {
1280 abstractFilters
.TrackFilterField
.getId(): \
1281 abstractFilters
.TrackFilterField
, \
1282 abstractFilters
.ContribTypeFilterField
.getId(): \
1283 abstractFilters
.ContribTypeFilterField
, \
1284 AbstractStatusFilter
.getId() : AbstractStatusFilter
, \
1285 abstractFilters
.CommentFilterField
.getId(): \
1286 abstractFilters
.CommentFilterField
, \
1287 abstractFilters
.AccContribTypeFilterField
.getId():\
1288 abstractFilters
.AccContribTypeFilterField
,
1289 abstractFilters
.AccTrackFilterField
.getId():\
1290 abstractFilters
.AccTrackFilterField
}
1293 class _AbstractStatusSF( filters
.SortingField
):
1296 def compare( self
, a1
, a2
):
1297 a1Stat
, a2Stat
= a1
.getCurrentStatus(), a2
.getCurrentStatus()
1298 if a1Stat
== a2Stat
:
1300 a1StatLabel
= AbstractStatusList
.getInstance().getCaption( a1Stat
.__class
__ )
1301 a2StatLabel
= AbstractStatusList
.getInstance().getCaption( a2Stat
.__class
__ )
1302 return cmp( a1StatLabel
, a2StatLabel
)
1305 class _AbstractIdSF( filters
.SortingField
):
1308 def compare( self
, a1
, a2
):
1317 class _AbstractRatingSF( filters
.SortingField
):
1320 def compare( self
, a1
, a2
):
1323 # check if the rating is none because the abstract has no judgement
1330 class _AbstractTrackSF( filters
.SortingField
):
1333 def compare( self
, a1
, a2
):
1334 trackList1
= a1
.getTrackList()
1335 trackList2
= a2
.getTrackList()
1336 # check if there is track assignement for the abstract and get the list of ids if needed
1337 if len(trackList1
) == 0:
1340 a
= [track
.getId() for track
in trackList1
]
1341 if len(trackList2
) == 0:
1344 b
= [track
.getId() for track
in trackList2
]
1347 class AbstractSortingCriteria( filters
.SortingCriteria
):
1350 _availableFields
= {
1351 abstractFilters
.ContribTypeSortingField
.getId(): \
1352 abstractFilters
.ContribTypeSortingField
, \
1353 _AbstractTrackSF
.getId(): _AbstractTrackSF
, \
1354 _AbstractStatusSF
.getId(): _AbstractStatusSF
, \
1355 _AbstractIdSF
.getId(): _AbstractIdSF
, \
1356 _AbstractRatingSF
.getId(): _AbstractRatingSF
, \
1357 abstractFilters
.SubmissionDateSortingField
.getId() : \
1358 abstractFilters
.SubmissionDateSortingField
, \
1359 abstractFilters
.ModificationDateSortingField
.getId() : \
1360 abstractFilters
.ModificationDateSortingField
1364 class RHAbstractList(RHConfModifCFABase
):
1365 _uh
= urlHandlers
.UHConfAbstractManagment
1367 def _resetFilters( self
, sessionData
):
1369 Brings the filter data to a consistent state (websession),
1370 marking everything as "checked"
1373 sessionData
["track"] = sessionData
["acc_track"] = [track
.getId() for track
in self
._conf
.getTrackList()]
1374 sessionData
["type"] = sessionData
["acc_type"] = [ct
.getId() for ct
in self
._conf
.getContribTypeList()]
1375 abstractStatusList
= AbstractStatusList
.getInstance()
1376 sessionData
["status"] = map(lambda status
: abstractStatusList
.getId( status
), abstractStatusList
.getStatusList())
1377 sessionData
['authSearch'] = ""
1379 sessionData
["trackShowNoValue"] = True
1380 sessionData
["typeShowNoValue"] = True
1381 sessionData
["accTypeShowNoValue"] = True
1382 sessionData
["accTrackShowNoValue"] = True
1383 sessionData
["trackShowMultiple"] = False
1384 sessionData
.pop("comment", None)
1388 def _updateFilters( self
, sessionData
, params
):
1390 Updates the filter parameters in the websession with those
1391 coming from the HTTP request
1393 sessionData
['track'] = []
1394 sessionData
['acc_track'] = []
1395 sessionData
['type'] = []
1396 sessionData
['acc_type'] = []
1397 sessionData
['status'] = []
1398 sessionData
['authSearch'] = ""
1400 sessionData
.update(params
)
1402 sessionData
['track'] = utils
.normalizeToList(sessionData
.get("track"))
1403 sessionData
['status'] = utils
.normalizeToList(sessionData
.get("status"))
1404 sessionData
['acc_track'] = utils
.normalizeToList(sessionData
.get("acc_track"))
1406 # update these elements in the session so that the parameters that are
1407 # passed are always taken into account (sessionData.update is not
1408 # enough, since the elements that are ommitted in params would just be
1411 sessionData
['trackShowNoValue'] = params
.has_key('trackShowNoValue')
1412 sessionData
['trackShowMultiple'] = params
.has_key("trackShowMultiple")
1413 sessionData
['accTrackShowNoValue'] = params
.has_key("accTrackShowNoValue")
1414 sessionData
['typeShowNoValue'] = params
.has_key('typeShowNoValue')
1415 sessionData
['accTypeShowNoValue'] = params
.has_key('accTypeShowNoValue')
1416 if params
.has_key("comment"):
1417 sessionData
['comment'] = ""
1418 elif sessionData
.has_key("comment"):
1419 del sessionData
['comment']
1422 def _buildFilteringCriteria(self
, sessionData
):
1424 Creates the Filtering Criteria object, without changing the existing
1425 session data (sessionData is cloned, not directly changed)
1427 sessionCopy
= sessionData
.copy()
1429 # Build the filtering criteria
1430 filterCrit
= AbstractFilterCriteria(self
._conf
, sessionCopy
)
1432 filterCrit
.getField("track").setShowNoValue(sessionCopy
.get("trackShowNoValue"))
1433 filterCrit
.getField("track").setOnlyMultiple(sessionCopy
.get("trackShowMultiple"))
1434 filterCrit
.getField("acc_track").setShowNoValue(sessionCopy
.get("accTrackShowNoValue"))
1435 filterCrit
.getField("type").setShowNoValue(sessionCopy
.get("typeShowNoValue"))
1436 filterCrit
.getField("acc_type").setShowNoValue(sessionCopy
.get("accTypeShowNoValue"))
1440 def _checkAction( self
, params
, filtersActive
, sessionData
, operation
):
1442 Decides what to do with the request parameters, depending
1443 on the type of operation that is requested
1445 # user chose to reset the filters
1446 if operation
== 'resetFilters':
1447 self
._filterUsed
= False
1448 sessionData
= self
._resetFilters
(sessionData
)
1450 # user set the filters
1451 elif operation
== 'setFilters':
1452 self
._filterUsed
= True
1453 sessionData
= self
._updateFilters
(sessionData
, params
)
1455 # user has changed the display options
1456 elif operation
== 'setDisplay':
1457 self
._filterUsed
= filtersActive
1458 sessionData
['disp'] = params
.get('disp',[])
1460 # session is empty (first time)
1461 elif not filtersActive
:
1462 self
._filterUsed
= False
1463 sessionData
= self
._resetFilters
(sessionData
)
1465 self
._filterUsed
= True
1467 # preserve the order and sortBy parameters, whatever happens
1468 sessionData
['order'] = params
.get('order', 'down')
1469 sessionData
['sortBy'] = params
.get('sortBy', 'number')
1473 def _checkParams( self
, params
):
1474 RHConfModifCFABase
._checkParams
( self
, params
)
1476 operationType
= params
.get('operationType')
1479 sessionData
= session
.get('abstractFilterAndSortingConf%s' % self
._conf
.getId())
1481 # check if there is information already
1482 # set in the session variables
1485 sessionData
= sessionData
.copy()
1486 filtersActive
= sessionData
['filtersActive']
1488 # set a default, empty dict
1490 filtersActive
= False
1492 if 'resetFilters' in params
:
1493 operation
= 'resetFilters'
1494 elif operationType
== 'filter':
1495 operation
= 'setFilters'
1496 elif operationType
== 'display':
1497 operation
= 'setDisplay'
1501 sessionData
= self
._checkAction
(params
, filtersActive
, sessionData
, operation
)
1503 # Maintain the state abotu filter usage
1504 sessionData
['filtersActive'] = self
._filterUsed
1506 # Save the web session
1507 session
['abstractFilterAndSortingConf%s' % self
._conf
.getId()] = sessionData
1509 self
._filterCrit
= self
._buildFilteringCriteria
(sessionData
)
1511 self
._sortingCrit
= AbstractSortingCriteria( [sessionData
.get( "sortBy", "number" ).strip()] )
1513 self
._order
= sessionData
.get("order","down")
1515 self
._msg
= sessionData
.get("directAbstractMsg","")
1516 self
._authSearch
= sessionData
.get("authSearch", "")
1518 self
._display
= utils
.normalizeToList(sessionData
.get("disp",[]))
1520 def _process( self
):
1521 p
= conferences
.WPConfAbstractList(self
,self
._target
, self
._msg
, self
._filterUsed
)
1522 return p
.display( filterCrit
= self
._filterCrit
,
1523 sortingCrit
= self
._sortingCrit
,
1524 authSearch
=self
._authSearch
, order
=self
._order
,
1525 display
= self
._display
)
1527 class RHAbstractsActions
:
1529 class to select the action to do with the selected abstracts
1531 def process(self
, params
):
1532 if params
.has_key("newAbstract"):
1533 return RHNewAbstract().process(params
)
1534 elif params
.has_key("pdf"):
1535 return RHAbstractsToPDF().process(params
)
1536 elif params
.has_key("excel"):
1537 return RHAbstractsListToExcel().process(params
)
1538 elif params
.has_key("xml"):
1539 return RHAbstractsToXML().process(params
)
1540 elif params
.has_key("auth"):
1541 return RHAbstractsParticipantList().process(params
)
1542 elif params
.has_key("merge"):
1543 return RHAbstractsMerge().process(params
)
1544 elif params
.has_key("acceptMultiple"):
1545 return RHAbstractManagmentAcceptMultiple().process(params
)
1546 elif params
.has_key("rejectMultiple"):
1547 return RHAbstractManagmentRejectMultiple().process(params
)
1548 elif params
.has_key("PKGA"):
1549 return RHMaterialPackageAbstract().process(params
)
1550 return "no action to do"
1553 class RHAbstractsMerge(RHConfModifCFABase
):
1555 def _checkParams(self
, params
):
1556 RHConfModifCFABase
._checkParams
(self
, params
)
1557 self
._abstractIds
= normaliseListParam(params
.get("abstracts", []))
1558 self
._targetAbsId
= params
.get("targetAbstract", "")
1559 self
._inclAuthors
= "includeAuthors" in params
1560 self
._doNotify
= "notify" in params
1561 self
._comments
= params
.get("comments", "")
1563 if "CANCEL" in params
:
1564 self
._action
= "CANCEL"
1565 elif "OK" in params
:
1566 self
._action
= "MERGE"
1567 self
._abstractIds
= params
.get("selAbstracts", "").split(",")
1569 self
._doNotify
= True
1574 if self
._action
== "CANCEL":
1576 urlHandlers
.UHConfAbstractManagment
.getURL(self
._target
))
1578 elif self
._action
== "MERGE":
1579 absMgr
= self
._target
.getAbstractMgr()
1580 if len(self
._abstractIds
) == 0:
1582 _("No ABSTRACT TO BE MERGED has been specified"))
1584 self
._abstracts
= []
1585 for id in self
._abstractIds
:
1586 abst
= absMgr
.getAbstractById(id)
1588 errorList
.append(_("ABSTRACT TO BE MERGED ID '%s' is not valid") % (id))
1590 statusKlass
= abst
.getCurrentStatus().__class
__
1591 if statusKlass
in (review
.AbstractStatusAccepted
,
1592 review
.AbstractStatusRejected
,
1593 review
.AbstractStatusWithdrawn
,
1594 review
.AbstractStatusDuplicated
,
1595 review
.AbstractStatusMerged
):
1596 label
= AbstractStatusList
.getInstance(
1597 ).getCaption(statusKlass
)
1598 errorList
.append(_("ABSTRACT TO BE MERGED %s is in status which does not allow to merge (%s)") % (abst
.getId(), label
.upper()))
1599 self
._abstracts
.append(abst
)
1600 if self
._targetAbsId
== "":
1601 errorList
.append(_("Invalid TARGET ABSTRACT ID"))
1603 if self
._targetAbsId
in self
._abstractIds
:
1604 errorList
.append(_("TARGET ABSTRACT ID is among the ABSTRACT IDs TO BE MERGED"))
1605 self
._targetAbs
= absMgr
.getAbstractById(self
._targetAbsId
)
1606 if self
._targetAbs
is None:
1607 errorList
.append(_("Invalid TARGET ABSTRACT ID"))
1609 statusKlass
= self
._targetAbs
.getCurrentStatus().__class
__
1610 if statusKlass
in (review
.AbstractStatusAccepted
,
1611 review
.AbstractStatusRejected
,
1612 review
.AbstractStatusWithdrawn
,
1613 review
.AbstractStatusMerged
,
1614 review
.AbstractStatusDuplicated
):
1615 label
= AbstractStatusList
.getInstance(
1616 ).getInstance().getCaption(statusKlass
)
1617 errorList
.append(_("TARGET ABSTRACT is in status which does not allow to merge (%s)") % label
.upper())
1618 if len(errorList
) == 0:
1619 for abs in self
._abstracts
:
1620 abs.mergeInto(self
._getUser
(), self
._targetAbs
,
1621 mergeAuthors
=self
._inclAuthors
, comments
=self
._comments
)
1623 abs.notify(EmailNotificator(), self
._getUser
())
1624 return self
._redirect
(urlHandlers
.UHAbstractManagment
.getURL(self
._targetAbs
))
1625 p
= conferences
.WPModMergeAbstracts(self
, self
._target
)
1626 return p
.display(absIdList
=self
._abstractIds
,
1627 targetAbsId
=self
._targetAbsId
,
1628 inclAuth
=self
._inclAuthors
,
1629 comments
=self
._comments
,
1630 errorMsgList
=errorList
,
1631 notify
=self
._doNotify
)
1634 #Base class for multi abstract management
1635 class RHAbstractManagmentMultiple( RHConferenceModifBase
):
1637 def _checkParams( self
, params
):
1638 RHConferenceModifBase
._checkParams
(self
, params
)
1639 abstractIds
= params
.get("abstracts",[])
1640 abMgr
= self
._conf
.getAbstractMgr()
1641 self
._abstracts
= []
1642 #if single abstract id is sent it's not a list so it shouldn't be iterated
1643 if isinstance(abstractIds
, types
.ListType
):
1644 for id in abstractIds
:
1645 self
._abstracts
.append(abMgr
.getAbstractById(id))
1647 self
._abstracts
.append(abMgr
.getAbstractById(abstractIds
))
1648 self
._warningShown
=params
.has_key("confirm")
1649 self
._comments
= params
.get("comments", "")
1650 self
._doNotify
=params
.has_key("notify")
1652 #checks if notification email template is defined for all selected abstracts
1653 #returns List of abstracts which doesn't have required template
1654 def _checkNotificationTemplate(self
, statusKlass
):
1655 from MaKaC
.webinterface
.rh
.abstractModif
import _AbstractWrapper
1657 if statusKlass
== review
.AbstractStatusAccepted
:
1658 cType
=self
._conf
.getContribTypeById(self
._typeId
)
1660 abstractsWithMissingTemplate
= []
1661 for abstract
in self
._abstracts
:
1662 if statusKlass
== review
.AbstractStatusAccepted
:
1663 status
=statusKlass(abstract
,None,self
._track
,cType
)
1664 elif statusKlass
== review
.AbstractStatusRejected
:
1665 status
=statusKlass(abstract
,None, None)
1666 else: # In case we pass an improper Status
1667 abstractsWithMissingTemplate
.append(abstract
)
1669 wrapper
=_AbstractWrapper(status
)
1670 if abstract
.getOwner().getNotifTplForAbstract(wrapper
) is None:
1671 abstractsWithMissingTemplate
.append(abstract
)
1672 return abstractsWithMissingTemplate
1674 #checks the status of selected abstracts
1675 #returns list of abstracts with improper status
1676 def _checkStatus(self
):
1677 improperAbstracts
= []
1678 for abstract
in self
._abstracts
:
1679 status
= abstract
.getCurrentStatus()
1680 if not isinstance(status
, AbstractStatusSubmitted
) and \
1681 not isinstance(status
, AbstractStatusProposedToAccept
) and \
1682 not isinstance(status
, AbstractStatusProposedToReject
):
1683 improperAbstracts
.append(abstract
)
1684 return improperAbstracts
1687 class RHAbstractManagmentAcceptMultiple( RHAbstractManagmentMultiple
):
1689 def _checkParams( self
, params
):
1690 RHAbstractManagmentMultiple
._checkParams
(self
, params
)
1691 self
._accept
= params
.get("accept", None)
1692 self
._track
=self
._conf
.getTrackById(params
.get("track", ""))
1693 self
._session
=self
._conf
.getSessionById(params
.get("session", ""))
1694 self
._typeId
= params
.get("type", "")
1696 def _process( self
):
1697 if self
._abstracts
!= []:
1698 improperAbstracts
= self
._checkStatus
()
1699 if improperAbstracts
== []:
1701 improperTemplates
= self
._checkNotificationTemplate
(review
.AbstractStatusAccepted
)
1702 if self
._doNotify
and not self
._warningShown
and improperTemplates
!= []:
1703 raise FormValuesError("""The abstracts with the following IDs can not be automatically
1704 notified: %s. Therefore, none of your request has been processed;
1705 go back, uncheck the relevant abstracts and try again."""%(", ".join(map(lambda x
:x
.getId(),improperTemplates
))))
1706 cType
=self
._conf
.getContribTypeById(self
._typeId
)
1707 for abstract
in self
._abstracts
:
1708 abstract
.accept(self
._getUser
(),self
._track
,cType
,self
._comments
,self
._session
)
1710 n
=EmailNotificator()
1711 abstract
.notify(n
,self
._getUser
())
1712 self
._redirect
(urlHandlers
.UHConfAbstractManagment
.getURL(self
._conf
))
1714 p
= abstracts
.WPAbstractManagmentAcceptMultiple( self
, self
._abstracts
)
1715 return p
.display( **self
._getRequestParams
() )
1717 raise FormValuesError("""The abstracts with the following IDs cannot be accepted because of their
1718 current status: %s. Therefore, none of your request has been processed;
1719 go back, uncheck the relevant abstracts and try again."""%(", ".join(map(lambda x
:x
.getId(),improperAbstracts
))))
1721 raise FormValuesError("No abstracts selected")
1724 class RHAbstractManagmentRejectMultiple( RHAbstractManagmentMultiple
):
1726 def _checkParams( self
, params
):
1727 RHAbstractManagmentMultiple
._checkParams
(self
, params
)
1728 self
._reject
= params
.get("reject", None)
1729 self
._comments
= params
.get("comments", "")
1730 self
._doNotify
=params
.has_key("notify")
1731 self
._warningShown
=params
.has_key("confirm")
1733 def _process( self
):
1734 if self
._abstracts
!= []:
1735 improperAbstracts
= self
._checkStatus
()
1736 if improperAbstracts
== []:
1738 improperTemplates
= self
._checkNotificationTemplate
(review
.AbstractStatusRejected
)
1739 if self
._doNotify
and not self
._warningShown
and improperTemplates
!= []:
1740 raise FormValuesError("""The abstracts with the following IDs can not be automatically
1741 notified: %s. Therefore, none of your request has been processed;
1742 go back, uncheck the relevant abstracts and try again."""%(", ".join(map(lambda x
:x
.getId(),improperTemplates
))))
1743 for abstract
in self
._abstracts
:
1744 abstract
.reject(self
._getUser
(), self
._comments
)
1746 n
=EmailNotificator()
1747 abstract
.notify(n
,self
._getUser
())
1748 self
._redirect
(urlHandlers
.UHConfAbstractManagment
.getURL(self
._conf
))
1750 p
= abstracts
.WPAbstractManagmentRejectMultiple( self
, self
._abstracts
)
1751 return p
.display( **self
._getRequestParams
() )
1753 raise FormValuesError("""The abstracts with the following IDs cannot be rejected because of their
1754 current status: %s. Therefore, none of your request has been processed;
1755 go back, uncheck the relevant abstracts and try again."""%(", ".join(map(lambda x
:x
.getId(),improperAbstracts
))))
1757 raise FormValuesError("No abstracts selected")
1759 class RHAbstractSendNotificationMail(RHConfModifCFABase
):
1761 def _checkParams( self
, params
):
1762 RHConfModifCFABase
._checkParams
( self
, params
)
1763 notifTplId
= params
.get("notifTpl", "")
1764 self
._notifTpl
= self
._conf
.getAbstractMgr().getNotificationTplById(notifTplId
)
1765 self
._abstractIds
= normaliseListParam( params
.get("abstracts", []) )
1766 self
._abstracts
= []
1767 abMgr
= self
._conf
.getAbstractMgr()
1768 for id in self
._abstractIds
:
1769 self
._abstracts
.append(abMgr
.getAbstractById(id))
1771 def _process( self
):
1772 p
= conferences
.WPAbstractSendNotificationMail(self
, self
._conf
, count
)
1776 class RHAbstractsToPDF(RHConfModifCFABase
):
1778 def _checkParams( self
, params
):
1779 RHConfModifCFABase
._checkParams
( self
, params
)
1780 self
._abstractIds
= normaliseListParam( params
.get("abstracts", []) )
1783 tz
= self
._conf
.getTimezone()
1784 if not self
._abstractIds
:
1785 return _("No abstract to print")
1787 pdf
= ConfManagerAbstractsToPDF(self
._conf
, self
._abstractIds
, tz
=tz
)
1788 return send_file('Abstracts.pdf', pdf
.generate(), 'PDF')
1791 class RHAbstractsToXML(RHConfModifCFABase
):
1793 def _checkParams( self
, params
):
1794 RHConfModifCFABase
._checkParams
( self
, params
)
1795 self
._abstractIds
= normaliseListParam( params
.get("abstracts", []) )
1796 self
._abstracts
= []
1797 abMgr
= self
._conf
.getAbstractMgr()
1798 for id in self
._abstractIds
:
1799 #if abMgr.getAbstractById(id).canView( self._aw ):
1800 self
._abstracts
.append(abMgr
.getAbstractById(id))
1805 x
.openTag("AbstractBook")
1806 x
.writeTag("Conference", self
._target
.getConference().getTitle())
1807 for abstract
in self
._abstracts
:
1808 x
.openTag("abstract")
1809 x
.writeTag("Id", abstract
.getId())
1810 x
.writeTag("Title", abstract
.getTitle())
1811 x
.writeTag("Content", abstract
.getField("content"))
1812 for f
in self
._conf
.getAbstractMgr().getAbstractFieldsMgr().getFields():
1814 x
.writeTag("field",abstract
.getField(id),[("id",id)])
1816 for au
in abstract
.getAuthorList():
1817 if abstract
.isPrimaryAuthor(au
):
1818 x
.openTag("PrimaryAuthor")
1819 x
.writeTag("FirstName", au
.getFirstName())
1820 x
.writeTag("FamilyName", au
.getSurName())
1821 x
.writeTag("Email", au
.getEmail())
1822 x
.writeTag("Affiliation", au
.getAffiliation())
1823 x
.closeTag("PrimaryAuthor")
1828 x
.openTag("Co-Author")
1829 x
.writeTag("FirstName", au
.getFirstName())
1830 x
.writeTag("FamilyName", au
.getSurName())
1831 x
.writeTag("Email", au
.getEmail())
1832 x
.writeTag("Affiliation", au
.getAffiliation())
1833 x
.closeTag("Co-Author")
1835 for au
in abstract
.getSpeakerList():
1836 x
.openTag("Speaker")
1837 x
.writeTag("FirstName", au
.getFirstName ())
1838 x
.writeTag("FamilyName", au
.getSurName())
1839 x
.writeTag("Email", au
.getEmail())
1840 x
.writeTag("Affiliation", au
.getAffiliation())
1841 x
.closeTag("Speaker")
1843 #To change for the new contribution type system to:
1844 #x.writeTag("ContributionType", abstract.getContribType().getName())
1845 if abstract
.getContribType() <> None:
1846 x
.writeTag("ContributionType", abstract
.getContribType().getName())
1848 x
.writeTag("ContributionType", None)
1849 #x.writeTag("ContributionType", abstract.getContribType())
1851 for t
in abstract
.getTrackList():
1852 x
.writeTag("Track", t
.getTitle())
1853 accepted_track
= abstract
.getAcceptedTrack()
1855 x
.writeTag('AcceptedTrack', accepted_track
.getTitle())
1857 x
.closeTag("abstract")
1859 x
.closeTag("AbstractBook")
1861 return send_file('Abstracts.xml', StringIO(x
.getXml()), 'XML')
1864 #-------------------------------------------------------------------------------------
1866 class RHAbstractsListToExcel(RHConfModifCFABase
):
1868 def _checkParams( self
, params
):
1869 RHConfModifCFABase
._checkParams
( self
, params
)
1870 self
._abstracts
= normaliseListParam( params
.get("abstracts", []) )
1871 self
._display
= self
._normaliseListParam
(params
.get("disp",[]))
1873 def _process( self
):
1875 for abs_id
in self
._abstracts
:
1876 abstractList
.append(self
._conf
.getAbstractMgr().getAbstractById(abs_id
))
1878 generator
= AbstractListToExcel(self
._conf
,abstractList
, self
._display
)
1879 return send_file('AbstractList.csv', StringIO(generator
.getExcelFile()), 'CSV')
1882 #-------------------------------------------------------------------------------------
1884 class RHConfModifDisplayCustomization( RHConferenceModifBase
):
1885 _uh
= urlHandlers
.UHConfModifDisplayCustomization
1887 def _checkParams( self
, params
):
1888 RHConferenceModifBase
._checkParams
( self
, params
)
1890 def _process( self
):
1891 p
= conferences
.WPConfModifDisplayCustomization(self
, self
._target
)
1894 class RHConfModifDisplayMenu( RHConferenceModifBase
):
1895 _uh
= urlHandlers
.UHConfModifDisplayMenu
1897 def _checkParams( self
, params
):
1898 RHConferenceModifBase
._checkParams
( self
, params
)
1899 self
._linkId
= params
.get("linkId", "")
1901 def _process( self
):
1902 p
= conferences
.WPConfModifDisplayMenu(self
, self
._target
, self
._linkId
)
1905 class RHConfModifDisplayResources( RHConferenceModifBase
):
1906 _uh
= urlHandlers
.UHConfModifDisplayResources
1908 def _checkParams( self
, params
):
1909 RHConferenceModifBase
._checkParams
( self
, params
)
1911 def _process( self
):
1912 p
= conferences
.WPConfModifDisplayResources(self
, self
._target
)
1915 class RHConfModifDisplayConfHeader( RHConferenceModifBase
):
1916 _uh
= urlHandlers
.UHConfModifDisplayConfHeader
1918 def _checkParams( self
, params
):
1919 RHConferenceModifBase
._checkParams
( self
, params
)
1920 self
._optionalParams
={}
1921 if params
.has_key("modifiedText"):
1922 self
._optionalParams
["modifiedText"]=params
.has_key("modifiedText")
1924 def _process( self
):
1925 p
= conferences
.WPConfModifDisplayConfHeader(self
, self
._target
, optionalParams
=self
._optionalParams
)
1928 class RHConfModifDisplayAddLink( RHConferenceModifBase
):
1929 _uh
= urlHandlers
.UHConfModifDisplayAddLink
1931 def _checkParams( self
, params
):
1932 RHConferenceModifBase
._checkParams
( self
, params
)
1933 self
._linkId
= params
.get("linkId", "")
1934 self
._cancel
= params
.get("cancel", "")
1935 self
._submit
= params
.get("submit", "")
1936 self
._params
= params
1938 def _process( self
):
1940 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
1943 target
= menu
.getLinkById(self
._linkId
)
1944 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(target
))
1947 name
= self
._params
.get("name", "[empty name]")
1948 if name
.strip()=="":
1950 url
= self
._params
.get("URL", "")
1951 displayTarget
= self
._params
.get("displayTarget", "_blank")
1952 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
1955 target
= menu
.getLinkById(self
._linkId
)
1956 link
= displayMgr
.ExternLink(name
, url
)
1957 link
.setCaption(name
)
1958 link
.setDisplayTarget(displayTarget
)
1959 target
.addLink(link
)
1960 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(link
))
1962 p
= conferences
.WPConfModifDisplayAddLink(self
, self
._target
, self
._linkId
)
1966 class RHConfModifDisplayAddPage( RHConferenceModifBase
):
1967 _uh
= urlHandlers
.UHConfModifDisplayAddLink
1969 def _checkParams( self
, params
):
1970 RHConferenceModifBase
._checkParams
( self
, params
)
1971 self
._linkId
= params
.get("linkId", "")
1972 self
._cancel
= params
.get("cancel", "")
1973 self
._submit
= params
.get("submit", "")
1974 self
._params
= params
1976 def _process( self
):
1978 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
1981 target
= menu
.getLinkById(self
._linkId
)
1982 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(target
))
1985 intPagesMgr
=internalPagesMgr
.InternalPagesMgrRegistery().getInternalPagesMgr(self
._conf
)
1986 intPage
=internalPagesMgr
.InternalPage(self
._conf
)
1987 intPage
.setTitle(self
._params
.get("title","[no title]"))
1988 intPage
.setContent(self
._params
.get("content",""))
1989 intPagesMgr
.addPage(intPage
)
1991 name
= self
._params
.get("name", "[empty name]")
1992 if name
.strip()=="":
1994 content
= self
._params
.get("content", "")
1995 displayTarget
= self
._params
.get("displayTarget", "_blank")
1996 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
1999 target
= menu
.getLinkById(self
._linkId
)
2000 link
= displayMgr
.PageLink(name
, intPage
)
2001 link
.setCaption(name
)
2002 link
.setDisplayTarget(displayTarget
)
2003 target
.addLink(link
)
2004 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(link
))
2006 p
= conferences
.WPConfModifDisplayAddPage(self
, self
._target
, self
._linkId
)
2009 class RHConfModifDisplayAddSpacer( RHConferenceModifBase
):
2010 _uh
= urlHandlers
.UHConfModifDisplayAddSpacer
2013 def _process( self
):
2014 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2015 spacer
= displayMgr
.Spacer()
2016 menu
.addLink(spacer
)
2017 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(spacer
))
2020 class RHConfModifDisplayRemoveLink( RHConferenceModifBase
):
2021 _uh
= urlHandlers
.UHConfModifDisplayRemoveLink
2023 def _checkParams( self
, params
):
2024 RHConferenceModifBase
._checkParams
( self
, params
)
2025 self
._linkId
= params
.get("linkId", "")
2026 self
._cancel
= params
.get("cancel", "")
2027 self
._confirm
= params
.get("confirm", "")
2030 def _process( self
):
2032 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2033 link
= menu
.getLinkById(self
._linkId
)
2034 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(link
))
2036 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2037 link
= menu
.getLinkById(self
._linkId
)
2038 if isinstance(link
, displayMgr
.SystemLink
):
2039 raise MaKaCError( _("You cannot remove a system link"))
2040 parent
= link
.getParent()
2041 if link
.getType() == "page":
2042 page
= link
.getPage()
2043 internalPagesMgr
.InternalPagesMgrRegistery().getInternalPagesMgr(self
._conf
).removePage(page
)
2044 parent
.removeLink(link
)
2045 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(self
._target
))
2047 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2048 link
= menu
.getLinkById(self
._linkId
)
2050 raise NotFoundError( _("The link you are trying to delete no longer exists"))
2051 if isinstance(link
, displayMgr
.SystemLink
):
2052 raise MaKaCError( _("You cannot remove a system link"))
2053 p
= conferences
.WPConfModifDisplayRemoveLink(self
, self
._target
, link
)
2057 class RHConfModifDisplayToggleLinkStatus( RHConferenceModifBase
):
2058 _uh
= urlHandlers
.UHConfModifDisplayToggleLinkStatus
2060 def _checkParams( self
, params
):
2061 RHConferenceModifBase
._checkParams
( self
, params
)
2062 self
._linkId
= params
.get("linkId", "")
2065 def _process( self
):
2066 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2067 link
=menu
.getLinkById(self
._linkId
)
2068 if link
.isEnabled():
2072 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(link
))
2075 class RHConfModifDisplayToggleHomePage( RHConferenceModifBase
):
2076 _uh
= urlHandlers
.UHConfModifDisplayToggleHomePage
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
.getPage().isHome():
2087 link
.getPage().setHome(False)
2089 for page
in internalPagesMgr
.InternalPagesMgrRegistery().getInternalPagesMgr(self
._conf
).getPagesList():
2091 link
.getPage().setHome(True)
2092 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(link
))
2095 class RHConfModifDisplayUpLink( RHConferenceModifBase
):
2096 _uh
= urlHandlers
.UHConfModifDisplayUpLink
2098 def _checkParams( self
, params
):
2099 RHConferenceModifBase
._checkParams
( self
, params
)
2100 self
._linkId
= params
.get("linkId", "")
2103 def _process( self
):
2104 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2105 link
= menu
.getLinkById(self
._linkId
)
2106 parent
= link
.getParent()
2108 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(link
))
2111 class RHConfModifDisplayDownLink( RHConferenceModifBase
):
2112 _uh
= urlHandlers
.UHConfModifDisplayDownLink
2114 def _checkParams( self
, params
):
2115 RHConferenceModifBase
._checkParams
( self
, params
)
2116 self
._linkId
= params
.get("linkId", "")
2119 def _process( self
):
2120 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2121 link
= menu
.getLinkById(self
._linkId
)
2122 parent
= link
.getParent()
2123 parent
.downLink(link
)
2124 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(link
))
2127 class RHConfModifDisplayToggleTimetableView(RHConferenceModifBase
):
2128 _uh
= urlHandlers
.UHConfModifDisplayToggleTimetableView
2130 def _checkParams(self
, params
):
2131 RHConferenceModifBase
._checkParams
(self
, params
)
2132 self
._linkId
= params
.get("linkId", "")
2135 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2136 link
= menu
.getLinkById(self
._linkId
)
2137 menu
.set_timetable_detailed_view(not menu
.is_timetable_detailed_view())
2138 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(link
))
2141 class RHConfModifDisplayToggleTTDefaultLayout(RHConferenceModifBase
):
2142 _uh
= urlHandlers
.UHConfModifDisplayToggleTTDefaultLayout
2144 def _checkParams(self
, params
):
2145 RHConferenceModifBase
._checkParams
(self
, params
)
2146 self
._linkId
= params
.get("linkId", "")
2149 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2150 link
= menu
.getLinkById(self
._linkId
)
2151 menu
.toggle_timetable_layout()
2152 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(link
))
2155 class RHConfModifDisplayModifyData(RHConferenceModifBase
):
2156 _uh
= urlHandlers
.UHConfModifDisplayRemoveLink
2158 def _checkParams(self
, params
):
2159 RHConferenceModifBase
._checkParams
(self
, params
)
2160 self
._linkId
= params
.get("linkId", "")
2161 self
._cancel
= params
.get("cancel", "")
2162 self
._confirm
= params
.get("confirm", "")
2163 self
._params
= params
2168 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2169 link
= menu
.getLinkById(self
._linkId
)
2170 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(link
))
2173 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2174 link
= menu
.getLinkById(self
._linkId
)
2175 if isinstance(link
, displayMgr
.SystemLink
):
2176 raise MaKaCError( _("You cannot modify a system link"))
2177 name
=self
._params
.get("name","[empty name]")
2178 if name
.strip()=="":
2180 link
.setCaption(name
)
2181 if isinstance(link
, displayMgr
.ExternLink
):
2182 link
.setURL(self
._params
["url"])
2183 elif isinstance(link
, displayMgr
.PageLink
):
2184 link
.getPage().setContent(self
._params
.get("content",""))
2185 link
.setDisplayTarget(self
._params
.get("displayTarget", "_blank"))
2186 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(link
))
2188 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2189 link
= menu
.getLinkById(self
._linkId
)
2190 if isinstance(link
, displayMgr
.SystemLink
):
2191 raise MaKaCError( _("You cannot modify a system link"))
2192 if isinstance(link
, displayMgr
.ExternLink
):
2193 p
= conferences
.WPConfModifDisplayModifyData(self
, self
._target
, link
)
2195 p
= conferences
.WPConfModifDisplayModifyPage(self
, self
._target
, link
)
2198 class RHConfModifDisplayModifySystemData( RHConferenceModifBase
):
2199 _uh
= urlHandlers
.UHConfModifDisplayRemoveLink
2201 def _checkParams( self
, params
):
2202 RHConferenceModifBase
._checkParams
( self
, params
)
2203 self
._linkId
= params
.get("linkId", "")
2204 self
._cancel
= params
.get("cancel", "")
2205 self
._confirm
= params
.get("confirm", "")
2206 self
._params
= params
2208 def _process( self
):
2211 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2212 link
= menu
.getLinkById(self
._linkId
)
2215 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2216 link
= menu
.getLinkById(self
._linkId
)
2217 if isinstance(link
, displayMgr
.SystemLink
):
2218 name
=self
._params
.get("name","[empty name]")
2219 if name
.strip()=="":
2221 link
.setCaption(name
)
2223 menu
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getMenu()
2224 link
= menu
.getLinkById(self
._linkId
)
2225 if isinstance(link
, displayMgr
.SystemLink
):
2226 p
= conferences
.WPConfModifDisplayModifySystemData(self
, self
._target
, link
)
2228 self
._redirect
(urlHandlers
.UHConfModifDisplayMenu
.getURL(link
))
2230 class RHConfModifFormatTitleColorBase( RHConferenceModifBase
):
2232 def _checkParams( self
, params
):
2233 RHConferenceModifBase
._checkParams
( self
, params
)
2234 self
._linkId
= params
.get("linkId", "")
2235 self
._formatOption
= params
.get("formatOption", "")
2236 self
._colorCode
= params
.get("colorCode", "")
2237 self
._apply
= params
.has_key( "apply" )
2238 self
._remove
= params
.has_key( "remove" )
2240 def _process( self
):
2241 format
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getFormat()
2242 if self
._formatOption
:
2244 format
.setColorCode(self
._formatOption
, "#" + self
._colorCode
)
2246 format
.clearColorCode(self
._formatOption
)
2247 redirecturl
= urlHandlers
.UHConfModifDisplayCustomization
.getURL(self
._conf
)
2248 redirecturl
.addParam("formatOption", self
._formatOption
)
2249 self
._redirect
("%s#colors"%redirecturl
)
2251 class RHConfModifFormatTitleBgColor( RHConfModifFormatTitleColorBase
):
2252 _uh
= urlHandlers
.UHConfModifFormatTitleBgColor
2254 class RHConfModifFormatTitleTextColor( RHConfModifFormatTitleColorBase
):
2255 _uh
= urlHandlers
.UHConfModifFormatTitleBgColor
2257 class RHConfSaveLogo( RHConferenceModifBase
):
2259 def _getNewTempFile( self
):
2260 cfg
= Config
.getInstance()
2261 tempPath
= cfg
.getUploadedFilesTempDir()
2262 tempFileName
= tempfile
.mkstemp( suffix
="IndicoLogo.tmp", dir = tempPath
)[1]
2265 def _saveFileToTemp(self
, fs
):
2266 fileName
= self
._getNewTempFile
()
2270 def _checkParams( self
, params
):
2271 RHConferenceModifBase
._checkParams
( self
, params
)
2272 if not hasattr(self
,"_filePath"):
2273 self
._filePath
= self
._saveFileToTemp
(params
["file"])
2274 self
._tempFilesToDelete
.append(self
._filePath
)
2275 self
._fileName
= params
["file"].filename
2278 def _process( self
):
2279 f
= conference
.LocalFile()
2281 f
.setDescription( "This is the logo for the conference" )
2282 f
.setFileName( self
._fileName
)
2283 f
.setFilePath( self
._filePath
)
2284 self
._conf
.setLogo( f
)
2285 self
._redirect
( "%s#logo"%urlHandlers
.UHConfModifDisplayCustomization
.getURL( self
._conf
) )
2288 class RHConfRemoveLogo( RHConferenceModifBase
):
2290 def _checkParams( self
, params
):
2291 RHConferenceModifBase
._checkParams
( self
, params
)
2293 def _process( self
):
2294 self
._conf
.removeLogo()
2295 self
._redirect
( "%s#logo"%urlHandlers
.UHConfModifDisplayCustomization
.getURL( self
._conf
) )
2297 class RHConfSaveCSS( RHConferenceModifBase
):
2299 def _getNewTempFile( self
):
2300 cfg
= Config
.getInstance()
2301 tempPath
= cfg
.getUploadedFilesTempDir()
2302 tempFileName
= tempfile
.mkstemp( suffix
="IndicoCSS.tmp", dir = tempPath
)[1]
2305 def _saveFileToTemp(self
, fs
):
2306 fileName
= self
._getNewTempFile
()
2310 def _checkParams( self
, params
):
2311 RHConferenceModifBase
._checkParams
( self
, params
)
2312 self
._params
= params
2313 if self
._params
.has_key("FP"):
2314 self
._filePath
= self
._params
["FP"]
2315 self
._fileName
= "TemplateInUse"
2317 if not hasattr(self
,"_filePath"):
2318 self
._filePath
= self
._saveFileToTemp
(params
["file"])
2319 self
._tempFilesToDelete
.append(self
._filePath
)
2320 self
._fileName
= params
["file"].filename
2321 if self
._fileName
.strip() == "":
2322 raise FormValuesError(_("Please, choose the file to upload first"))
2324 def _process( self
):
2325 f
= conference
.LocalFile()
2327 f
.setDescription( "This is the css for the conference" )
2328 f
.setFileName( self
._fileName
)
2329 f
.setFilePath( self
._filePath
)
2330 sm
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getStyleManager()
2332 self
._redirect
( "%s#css"%urlHandlers
.UHConfModifDisplayCustomization
.getURL( self
._conf
) )
2335 class RHConfRemoveCSS( RHConferenceModifBase
):
2337 def _checkParams( self
, params
):
2338 RHConferenceModifBase
._checkParams
( self
, params
)
2340 def _process( self
):
2341 sm
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getStyleManager()
2343 # Since this function makes sure no template is used make sure that
2344 # one of the standard ones is not used
2346 self
._redirect
( "%s#css"%urlHandlers
.UHConfModifDisplayCustomization
.getURL( self
._conf
) )
2349 class RHConfModifPreviewCSS(RHConferenceModifBase
):
2351 def _checkParams( self
, params
):
2352 RHConferenceModifBase
._checkParams
( self
, params
)
2353 self
._params
= params
2355 def _process( self
):
2356 # Call a webpage that will handle the task
2357 CSS_Temp_Id
= self
._params
.get("cssId", "")
2358 p
= conferences
.WPConfModifPreviewCSS(self
, self
._conf
, CSS_Temp_Id
)
2362 class RHConfUseCSS( RHConferenceModifBase
):
2364 def _checkParams( self
, params
):
2365 RHConferenceModifBase
._checkParams
( self
, params
)
2366 self
._params
= params
2367 self
._selectedTpl
= self
._params
.get("selectedTpl")
2369 def _process( self
):
2370 styleMgr
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getStyleManager()
2371 if self
._selectedTpl
== "css":
2372 styleMgr
.useLocalCSS()
2373 elif self
._selectedTpl
:
2374 styleMgr
.setCSS(self
._selectedTpl
)
2375 self
._redirect
( "%s#css"%urlHandlers
.UHConfModifDisplayCustomization
.getURL( self
._conf
) )
2377 class RHConfSavePic( RHConferenceModifBase
):
2380 RHConferenceModifBase
.__init
__(self
)
2381 self
._tempFiles
= {}
2383 def _getNewTempFile( self
):
2384 cfg
= Config
.getInstance()
2385 tempPath
= cfg
.getUploadedFilesTempDir()
2386 tempFileName
= tempfile
.mkstemp( suffix
="IndicoPic.tmp", dir = tempPath
)[1]
2389 def _saveFileToTemp(self
, fs
):
2390 if fs
not in self
._tempFiles
:
2391 fileName
= self
._getNewTempFile
()
2393 self
._tempFiles
[fs
] = fileName
2394 return self
._tempFiles
[fs
]
2396 def _checkParams( self
, params
):
2397 RHConferenceModifBase
._checkParams
( self
, params
)
2398 self
._filePath
= self
._saveFileToTemp
(params
["file"])
2399 self
._tempFilesToDelete
.append(self
._filePath
)
2400 self
._fileName
= params
["file"].filename
2401 self
._params
= params
2404 def _process( self
):
2405 if self
._fileName
== "":
2406 return json
.dumps({'status': "ERROR", 'info': {'message':_("No file has been attached")}})
2407 f
= conference
.LocalFile()
2408 f
.setFileName( self
._fileName
)
2409 f
.setFilePath( self
._filePath
)
2410 im
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
).getImagesManager()
2411 pic
= im
.addPic( f
)
2412 info
={"name": f
.getFileName(),
2414 "picURL": str(urlHandlers
.UHConferencePic
.getURL(pic
))}
2415 return json
.dumps({'status': "OK", 'info': info
}, textarea
=True)
2417 class RHConfModifTickerTapeAction( RHConferenceModifBase
):
2419 def _checkParams( self
, params
):
2420 RHConferenceModifBase
._checkParams
( self
, params
)
2421 dm
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
)
2422 self
._tickerTape
=dm
.getTickerTape()
2423 self
._status
=params
.has_key("ttStatus")
2424 self
._saveText
=params
.has_key("savettText")
2425 self
._text
=params
.get("ttText","")
2426 self
._simpleTextEnabled
=params
.has_key("simpleText")
2427 self
._nowHappeningEnabled
=params
.has_key("nowHappening")
2429 def _process( self
):
2430 url
=urlHandlers
.UHConfModifDisplayConfHeader
.getURL( self
._conf
)
2432 self
._tickerTape
.setActive(not self
._tickerTape
.isActive())
2434 self
._tickerTape
.setText(self
._text
)
2435 url
.addParam("modifiedText", "True")
2436 if self
._nowHappeningEnabled
:
2437 self
._tickerTape
.setNowHappeningEnabled(not self
._tickerTape
.isNowHappeningEnabled())
2438 if self
._simpleTextEnabled
:
2439 self
._tickerTape
.setSimpleTextEnabled(not self
._tickerTape
.isSimpleTextEnabled())
2440 self
._redirect
( "%s#tickertape"%url
)
2442 class RHConfModifToggleSearch( RHConferenceModifBase
):
2444 def _checkParams( self
, params
):
2445 RHConferenceModifBase
._checkParams
( self
, params
)
2446 self
._displayMgr
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
)
2447 self
._searchEnabled
=self
._displayMgr
.getSearchEnabled()
2449 def _process( self
):
2450 url
=urlHandlers
.UHConfModifDisplayConfHeader
.getURL( self
._conf
)
2451 self
._displayMgr
.setSearchEnabled(not self
._searchEnabled
)
2452 self
._redirect
( "%s#headerFeatures"%url
)
2455 class RHConfModifToggleNavigationBar( RHConferenceModifBase
):
2457 def _checkParams( self
, params
):
2458 RHConferenceModifBase
._checkParams
( self
, params
)
2459 self
._displayMgr
= displayMgr
.ConfDisplayMgrRegistery().getDisplayMgr(self
._conf
)
2460 self
._navigationBarEnabled
=self
._displayMgr
.getDisplayNavigationBar()
2462 def _process( self
):
2463 url
=urlHandlers
.UHConfModifDisplayConfHeader
.getURL( self
._conf
)
2464 self
._displayMgr
.setDisplayNavigationBar(not self
._navigationBarEnabled
)
2465 self
._redirect
( "%s#headerFeatures"%url
)
2467 class RHConfAddContribType(RHConferenceModifBase
):
2468 _uh
= urlHandlers
.UHConfAddContribType
2470 def _checkParams(self
, params
):
2471 RHConferenceModifBase
._checkParams
(self
, params
)
2472 self
._typeName
= params
.get("ctName", "")
2473 self
._typeDescription
= params
.get("ctDescription", "")
2474 self
._typeId
= params
.get("typeId", "")
2475 self
._cancel
= params
.get("cancel", "")
2476 self
._save
= params
.get("save", "")
2478 def _process( self
):
2480 self
._redirect
(urlHandlers
.UHConferenceModification
.getURL(self
._conf
))
2482 ct
= self
._conf
.newContribType(self
._typeName
, self
._typeDescription
)
2484 # Filtering criteria: by default make new contribution type checked
2485 filters
= session
.setdefault('ContributionFilterConf%s' % self
._conf
.getId(), {})
2486 if 'types' in filters
:
2487 #Append the new type to the existing list
2488 newDict
= filters
['types'][:]
2489 newDict
.append(ct
.getId())
2490 filters
['types'] = newDict
[:]
2492 #Create a new entry for the dictionary containing the new type
2493 filters
['types'] = [ct
.getId()]
2494 session
.modified
= True
2496 self
._redirect
(urlHandlers
.UHConferenceModification
.getURL(self
._conf
))
2498 p
= conferences
.WPConfAddContribType(self
, self
._target
)
2502 class RHConfRemoveContribType(RHConferenceModifBase
):
2503 _uh
= urlHandlers
.UHConfRemoveContribType
2505 def _checkParams(self
, params
):
2506 RHConferenceModifBase
._checkParams
(self
, params
)
2507 selTypeId
= self
._normaliseListParam
( params
.get( "types", [] ) )
2508 self
._contribTypes
= []
2509 for id in selTypeId
:
2510 self
._contribTypes
.append(self
._conf
.getContribTypeById(id))
2514 for ct
in self
._contribTypes
:
2515 self
._conf
.removeContribType(ct
)
2516 self
._redirect
(urlHandlers
.UHConferenceModification
.getURL(self
._conf
))
2519 class RHConfContribTypeBase(RHConferenceModifBase
):
2521 def _checkParams(self
, params
):
2522 RHConferenceModifBase
._checkParams
(self
, params
)
2523 l
= locators
.WebLocator()
2524 l
.setContribType( params
)
2525 self
._contribType
= self
._target
= l
.getObject()
2528 class RHConfEditContribType(RHConfContribTypeBase
):
2530 def _checkParams(self
, params
):
2531 RHConfContribTypeBase
._checkParams
(self
, params
)
2532 self
._save
= params
.get("save", "")
2533 self
._name
= params
.get("ctName", "")
2534 self
._cancel
= params
.get("cancel", "")
2535 self
._description
= params
.get("ctDescription", "")
2539 self
._redirect
(urlHandlers
.UHConferenceModification
.getURL(self
._conf
))
2541 self
._target
.setName(self
._name
)
2542 self
._target
.setDescription(self
._description
)
2543 self
._redirect
(urlHandlers
.UHConferenceModification
.getURL(self
._conf
))
2545 p
= conferences
.WPConfEditContribType(self
, self
._target
)
2549 class ContribFilterCrit(filters
.FilterCriteria
):
2550 _availableFields
= { \
2551 contribFilters
.TypeFilterField
.getId():contribFilters
.TypeFilterField
, \
2552 contribFilters
.StatusFilterField
.getId():contribFilters
.StatusFilterField
, \
2553 contribFilters
.TrackFilterField
.getId():contribFilters
.TrackFilterField
, \
2554 contribFilters
.SessionFilterField
.getId():contribFilters
.SessionFilterField
}
2557 class ContribSortingCrit(filters
.SortingCriteria
):
2558 _availableFields
= {
2559 contribFilters
.NumberSF
.getId():contribFilters
.NumberSF
,
2560 contribFilters
.DateSF
.getId():contribFilters
.DateSF
,
2561 contribFilters
.ContribTypeSF
.getId():contribFilters
.ContribTypeSF
,
2562 contribFilters
.TrackSF
.getId():contribFilters
.TrackSF
,
2563 contribFilters
.SpeakerSF
.getId():contribFilters
.SpeakerSF
,
2564 contribFilters
.BoardNumberSF
.getId():contribFilters
.BoardNumberSF
,
2565 contribFilters
.SessionSF
.getId():contribFilters
.SessionSF
,
2566 contribFilters
.TitleSF
.getId():contribFilters
.TitleSF
2570 class RHContributionListBase(RHConferenceModifBase
):
2572 def _checkProtection(self
):
2573 from MaKaC
.webinterface
.rh
.reviewingModif
import RCPaperReviewManager
2574 if not RCPaperReviewManager
.hasRights(self
):
2575 RHConferenceModifBase
._checkProtection
(self
)
2578 class RHContributionList(RHContributionListBase
):
2579 _uh
= urlHandlers
.UHConfModifContribList
2581 def _checkProtection(self
):
2582 from MaKaC
.webinterface
.rh
.reviewingModif
import RCPaperReviewManager
2583 if not RCPaperReviewManager
.hasRights(self
):
2584 RHContributionListBase
._checkProtection
(self
)
2586 def _resetFilters( self
, sessionData
):
2588 Brings the filter data to a consistent state (websession),
2589 marking everything as "checked"
2593 sessionData
["type"] = map(lambda ctype
: ctype
.getId(), self
._conf
.getContribTypeList())
2594 sessionData
["track"] = map(lambda track
: track
.getId(), self
._conf
.getTrackList())
2595 sessionData
["session"] = map(lambda ses
: ses
.getId(), self
._conf
.getSessionList())
2596 sessionData
["status"] = map(lambda status
: ContribStatusList
.getId(status
), ContribStatusList
.getList())
2598 paperId
= materialFactories
.PaperFactory().getId()
2599 slidesId
= materialFactories
.SlidesFactory().getId()
2600 for matId
in ["--other--","--none--",paperId
,slidesId
]: # wtf? doesn't that simply re-create the list?
2601 lmaterial
.append(matId
)
2602 sessionData
["material"] = lmaterial
2603 sessionData
["typeShowNoValue"] = True
2604 sessionData
["trackShowNoValue"] = True
2605 sessionData
["sessionShowNoValue"] = True
2609 def _updateFilters( self
, sessionData
, params
):
2611 Updates the filter parameters in the websession with those
2612 coming from the HTTP request
2615 sessionData
["status"] = []
2616 sessionData
["material"] = []
2617 sessionData
.update(params
)
2618 sessionData
["type"] = utils
.normalizeToList(params
.get('types', []))
2619 sessionData
["track"] = utils
.normalizeToList(params
.get('tracks', []))
2620 sessionData
['session'] = utils
.normalizeToList(params
.get('sessions', []))
2622 # update these elements in the session so that the parameters that are
2623 # passed are always taken into account (sessionData.update is not
2624 # enough, since the elements that are ommitted in params would just be
2627 sessionData
['typeShowNoValue'] = params
.has_key('typeShowNoValue')
2628 sessionData
['trackShowNoValue'] = params
.has_key('trackShowNoValue')
2629 sessionData
['sessionShowNoValue'] = params
.has_key('sessionShowNoValue')
2633 def _buildFilteringCriteria(self
, sessionData
):
2635 Creates the Filtering Criteria object, without changing the existing
2636 session data (sessionData is cloned, not directly changed)
2638 sessionCopy
= sessionData
.copy()
2640 # Build the filtering criteria
2641 filterCrit
= ContribFilterCrit(self
._conf
, sessionCopy
)
2643 filterCrit
.getField("type").setShowNoValue(sessionCopy
.get('typeShowNoValue'))
2644 filterCrit
.getField("track").setShowNoValue(sessionCopy
.get('trackShowNoValue'))
2645 filterCrit
.getField("session").setShowNoValue(sessionCopy
.get('sessionShowNoValue'))
2649 def _checkAction(self
, params
, filtersActive
, sessionData
, operation
, isBookmark
):
2651 Decides what to do with the request parameters, depending
2652 on the type of operation that is requested
2655 # user chose to reset the filters
2656 if operation
== 'resetFilters':
2657 self
._filterUsed
= False
2658 sessionData
= self
._resetFilters
(sessionData
)
2660 # user set the filters
2661 elif operation
== 'setFilters':
2662 self
._filterUsed
= True
2663 sessionData
= self
._updateFilters
(sessionData
, params
)
2665 # user has changed the display options
2666 elif operation
== 'setDisplay':
2667 self
._filterUsed
= filtersActive
2669 # session is empty (first time)
2670 elif not filtersActive
:
2671 self
._filterUsed
= False
2672 sessionData
= self
._resetFilters
(sessionData
)
2674 self
._filterUsed
= True
2676 # if this is accessed through a direct link, the session is empty, so set default values
2678 sessionData
= self
._resetFilters
(sessionData
)
2679 if operation
!= 'resetFilters':
2680 sessionData
= self
._updateFilters
(sessionData
, params
)
2682 # preserve the order and sortBy parameters, whatever happens
2683 sessionData
['order'] = params
.get('order', 'down')
2684 sessionData
['sortBy'] = params
.get('sortBy', 'number')
2688 def _checkParams( self
, params
):
2689 RHContributionListBase
._checkParams
( self
, params
)
2690 operationType
= params
.get('operationType')
2691 sessionData
= session
.get('ContributionFilterConf%s' % self
._conf
.getId())
2693 # check if there is information already
2694 # set in the session variables
2697 sessionData
= sessionData
.copy()
2698 filtersActive
= sessionData
.get('filtersActive', False)
2700 # set a default, empty dict
2702 filtersActive
= False
2704 if params
.has_key("resetFilters"):
2705 operation
= 'resetFilters'
2706 elif operationType
== 'filter':
2707 operation
= 'setFilters'
2708 elif operationType
== 'display':
2709 operation
= 'setDisplay'
2713 isBookmark
= params
.has_key("isBookmark")
2714 sessionData
= self
._checkAction
(params
, filtersActive
, sessionData
, operation
, isBookmark
)
2715 # Maintain the state about filter usage
2716 sessionData
['filtersActive'] = self
._filterUsed
;
2717 # Save the web session
2718 session
['ContributionFilterConf%s' % self
._conf
.getId()] = sessionData
2719 self
._filterCrit
= self
._buildFilteringCriteria
(sessionData
)
2720 self
._sortingCrit
= ContribSortingCrit([sessionData
.get("sortBy", "number").strip()])
2721 self
._order
= sessionData
.get("order", "down")
2722 self
._authSearch
= sessionData
.get("authSearch", "")
2724 def _process( self
):
2725 p
= conferences
.WPModifContribList(self
, self
._target
, self
._filterUsed
)
2726 return p
.display(authSearch
=self
._authSearch
,\
2727 filterCrit
=self
._filterCrit
, sortingCrit
=self
._sortingCrit
, order
=self
._order
)
2730 class RHContribQuickAccess(RHConferenceModifBase
):
2732 def _checkParams(self
,params
):
2733 RHConferenceModifBase
._checkParams
(self
,params
)
2734 self
._contrib
=self
._target
.getContributionById(params
.get("selContrib",""))
2737 url
=urlHandlers
.UHConfModifContribList
.getURL(self
._target
)
2738 if self
._contrib
is not None:
2739 url
=urlHandlers
.UHContributionModification
.getURL(self
._contrib
)
2742 #-------------------------------------------------------------------------------------
2744 class RHAbstractsParticipantList(RHConfModifCFABase
):
2746 def _checkProtection( self
):
2747 if len( self
._conf
.getCoordinatedTracks( self
._getUser
() ) ) == 0:
2748 RHConferenceModifBase
._checkProtection
( self
)
2750 def _checkParams( self
, params
):
2751 RHConfModifCFABase
._checkParams
( self
, params
)
2752 self
._abstractIds
= normaliseListParam( params
.get("abstracts", []) )
2753 self
._displayedGroups
= params
.get("displayedGroups", [])
2754 if type(self
._displayedGroups
) != list:
2755 self
._displayedGroups
= [self
._displayedGroups
]
2756 self
._clickedGroup
= params
.get("clickedGroup","")
2758 def _setGroupsToDisplay(self
):
2759 if self
._clickedGroup
in self
._displayedGroups
:
2760 self
._displayedGroups
.remove(self
._clickedGroup
)
2762 self
._displayedGroups
.append(self
._clickedGroup
)
2764 def _process( self
):
2765 #This is a plain text exception but an exception should be raised here !
2766 if not self
._abstractIds
:
2767 return _("There is no abstract.")
2769 submitters
= OOBTree()
2770 primaryAuthors
= OOBTree()
2771 coAuthors
= OOBTree()
2772 submitterEmails
= set()
2773 primaryAuthorEmails
= set()
2774 coAuthorEmails
= set()
2776 self
._setGroupsToDisplay
()
2778 abMgr
= self
._conf
.getAbstractMgr()
2779 for abstId
in self
._abstractIds
:
2780 abst
= abMgr
.getAbstractById(abstId
)
2783 subm
= abst
.getSubmitter()
2784 if subm
.getSurName().lower().strip() != "" or subm
.getFirstName().lower().strip() != "" or subm
.getEmail().lower().strip() != "":
2785 keySB
= "%s-%s-%s"%(subm
.getSurName().lower(), subm
.getFirstName().lower(), subm
.getEmail().lower())
2786 submitters
[keySB
] = subm
2787 submitterEmails
.add(subm
.getEmail())
2789 for pAut
in abst
.getPrimaryAuthorList():
2790 if pAut
.getSurName().lower().strip() == "" and pAut
.getFirstName().lower().strip() == "" and pAut
.getEmail().lower().strip() == "":
2792 keyPA
= "%s-%s-%s"%(pAut
.getSurName().lower(), pAut
.getFirstName().lower(), pAut
.getEmail().lower())
2793 primaryAuthors
[keyPA
] = pAut
2794 primaryAuthorEmails
.add(pAut
.getEmail())
2796 for coAut
in abst
.getCoAuthorList():
2797 if coAut
.getSurName().lower().strip() == "" and coAut
.getFirstName().lower().strip() == "" and coAut
.getEmail().lower().strip() == "":
2799 keyCA
= "%s-%s-%s"%(coAut
.getSurName().lower(), coAut
.getFirstName().lower(), coAut
.getEmail().lower())
2800 coAuthors
[keyCA
] = coAut
2801 coAuthorEmails
.add(coAut
.getEmail())
2802 emailList
= {"submitters":{},"primaryAuthors":{},"coAuthors":{}}
2803 emailList
["submitters"]["tree"] = submitters
2804 emailList
["primaryAuthors"]["tree"] = primaryAuthors
2805 emailList
["coAuthors"]["tree"] = coAuthors
2806 emailList
["submitters"]["emails"] = submitterEmails
2807 emailList
["primaryAuthors"]["emails"] = primaryAuthorEmails
2808 emailList
["coAuthors"]["emails"] = coAuthorEmails
2809 p
= conferences
.WPConfParticipantList(self
, self
._target
, emailList
, self
._displayedGroups
, self
._abstractIds
)
2813 class RHNewAbstract(RHConfModifCFABase
, AbstractParam
):
2816 RHConfModifCFABase
.__init
__(self
)
2817 AbstractParam
.__init
__(self
)
2819 def _checkParams(self
, params
):
2820 RHConfModifCFABase
._checkParams
(self
, params
)
2821 #if the user is not logged in we return immediately as this form needs
2822 # the user to be logged in and therefore all the checking below is not
2824 if self
._getUser
() is None:
2826 AbstractParam
._checkParams
(self
, params
, self
._conf
, request
.content_length
)
2828 def _doValidate(self
):
2829 #First, one must validate that the information is fine
2830 errors
= self
._abstractData
.check()
2832 p
= conferences
.WPModNewAbstract(
2833 self
, self
._target
, self
._abstractData
)
2834 pars
= self
._abstractData
.toDict()
2835 pars
["action"] = self
._action
2836 return p
.display(**pars
)
2837 #Then, we create the abstract object and set its data to the one
2839 cfaMgr
= self
._target
.getAbstractMgr()
2840 abstract
= cfaMgr
.newAbstract(self
._getUser
())
2841 #self._setAbstractData(abstract)
2842 self
._abstractData
.setAbstractData(abstract
)
2843 #Finally, we display the abstract list page
2844 self
._redirect
(urlHandlers
.UHConfAbstractList
.getURL(self
._conf
))
2847 if self
._action
== "CANCEL":
2849 urlHandlers
.UHConfAbstractManagment
.getURL(self
._target
))
2850 elif self
._action
== "VALIDATE":
2851 return self
._doValidate
()
2853 p
= conferences
.WPModNewAbstract(
2854 self
, self
._target
, self
._abstractData
)
2855 pars
= self
._abstractData
.toDict()
2856 return p
.display(**pars
)
2860 class RHContribsActions
:
2862 class to select the action to do with the selected abstracts
2864 def process(self
, params
):
2865 if params
.has_key("PDF"):
2866 return RHContribsToPDF().process(params
)
2867 elif params
.has_key("excel.x"):
2868 return RHContribsToExcel().process(params
)
2869 elif params
.has_key("xml.x"):
2870 return RHContribsToXML().process(params
)
2871 elif params
.has_key("AUTH"):
2872 return RHContribsParticipantList().process(params
)
2873 elif params
.has_key("move"):
2874 return RHMoveContribsToSession().process(params
)
2875 elif params
.has_key("PKG"):
2876 return RHMaterialPackage().process(params
)
2877 elif params
.has_key("PROC"):
2878 return RHProceedings().process(params
)
2879 return "no action to do"
2882 class RHContribsToPDFMenu(RHConferenceModifBase
):
2884 def _checkParams( self
, params
):
2885 RHConferenceModifBase
._checkParams
( self
, params
)
2886 self
._contribIds
= self
._normaliseListParam
( params
.get("contributions", []) )
2888 for id in self
._contribIds
:
2889 self
._contribs
.append(self
._conf
.getContributionById(id))
2890 self
._displayType
= params
.get("displaytype", None)
2892 def _process( self
):
2893 from MaKaC
.PDFinterface
.conference
import ContributionBook
2894 if not self
._displayType
:
2895 wp
= conferences
.WPConfModifContribToPDFMenu(self
, self
._conf
, self
._contribIds
)
2898 elif self
._displayType
== "bookOfAbstract":
2899 tz
= self
._target
.getTimezone()
2900 filename
= "{0} - Book of abstracts.pdf".format(self
._target
.getTitle())
2902 pdf
= ContributionBook(self
._target
, self
.getAW(), self
._contribs
, tz
=tz
)
2903 return send_file(filename
, pdf
.generate(), 'PDF')
2905 elif self
._displayType
== "bookOfAbstractBoardNo":
2906 tz
= self
._target
.getTimezone()
2907 filename
= "{0} - Book of abstracts.pdf".format(self
._target
.getTitle())
2908 pdf
= ContributionBook(self
._target
, self
.getAW(), self
._contribs
, tz
=tz
, sort_by
="boardNo")
2909 return send_file(filename
, pdf
.generate(), 'PDF')
2911 elif self
._displayType
== "ContributionList":
2912 tz
= self
._conf
.getTimezone()
2913 filename
= "{0} - Contributions.pdf".format(self
._target
.getTitle())
2914 if not self
._contribs
:
2915 return "No contributions to print"
2917 contrib_pdf
= ContribsToPDF(self
._conf
, self
._contribs
)
2918 fpath
= contrib_pdf
.generate()
2920 return send_file(filename
, fpath
, 'PDF')
2923 class RHContribsToPDF(RHConferenceModifBase
):
2925 def _checkParams( self
, params
):
2926 RHConferenceModifBase
._checkParams
( self
, params
)
2927 self
._contribIds
= self
._normaliseListParam
( params
.get("contributions", []) )
2929 for id in self
._contribIds
:
2930 self
._contribs
.append(self
._conf
.getContributionById(id))
2932 def _process( self
):
2933 tz
= self
._conf
.getTimezone()
2934 filename
= "Contributions.pdf"
2935 if not self
._contribs
:
2936 return "No contributions to print"
2937 pdf
= ContribsToPDF(self
._conf
, self
._contribs
)
2938 return send_file(filename
, pdf
.generate(), 'PDF')
2941 class RHContribsToExcel(RHConferenceModifBase
):
2943 def _checkParams( self
, params
):
2944 RHConferenceModifBase
._checkParams
( self
, params
)
2945 self
._contribIds
= self
._normaliseListParam
( params
.get("contributions", []) )
2947 for id in self
._contribIds
:
2948 self
._contribs
.append(self
._conf
.getContributionById(id))
2950 def _process( self
):
2951 tz
= self
._conf
.getTimezone()
2952 filename
= "Contributions.csv"
2953 if not self
._contribs
:
2954 return "No contributions to print"
2955 excel
= ContributionsListToExcel(self
._conf
, self
._contribs
, tz
=tz
)
2956 return send_file(filename
, StringIO(excel
.getExcelFile()), 'CSV')
2959 class RHContribsToXML(RHConferenceModifBase
):
2961 def _checkParams( self
, params
):
2962 RHConferenceModifBase
._checkParams
( self
, params
)
2963 self
._contribIds
= self
._normaliseListParam
( params
.get("contributions", []) )
2965 for id in self
._contribIds
:
2966 self
._contribs
.append(self
._conf
.getContributionById(id))
2967 def _process( self
):
2968 filename
= "Contributions.xml"
2969 from MaKaC
.common
.fossilize
import fossilize
2970 resultFossil
= fossilize(self
._contribs
)
2971 serializer
= Serializer
.create('xml')
2972 return send_file(filename
, StringIO(serializer(resultFossil
)), 'XML')
2975 class RHContribsParticipantList(RHConferenceModifBase
):
2977 def _checkParams( self
, params
):
2978 RHConferenceModifBase
._checkParams
( self
, params
)
2979 self
._contribIds
= normaliseListParam( params
.get("contributions", []) )
2980 self
._displayedGroups
= self
._normaliseListParam
( params
.get("displayedGroups", []) )
2981 self
._clickedGroup
= params
.get("clickedGroup","")
2983 def _setGroupsToDisplay(self
):
2984 if self
._clickedGroup
in self
._displayedGroups
:
2985 self
._displayedGroups
.remove(self
._clickedGroup
)
2987 self
._displayedGroups
.append(self
._clickedGroup
)
2989 def _process( self
):
2990 if not self
._contribIds
:
2991 return i18nformat("""<table align=\"center\" width=\"100%%\"><tr><td> _("There are no contributions") </td></tr></table>""")
2993 speakers
= OOBTree()
2994 primaryAuthors
= OOBTree()
2995 coAuthors
= OOBTree()
2996 speakerEmails
= set()
2997 primaryAuthorEmails
= set()
2998 coAuthorEmails
= set()
3000 self
._setGroupsToDisplay
()
3002 for contribId
in self
._contribIds
:
3003 contrib
= self
._conf
.getContributionById(contribId
)
3005 for pAut
in contrib
.getPrimaryAuthorList():
3006 if pAut
.getFamilyName().lower().strip() == "" and pAut
.getFirstName().lower().strip() == "" and pAut
.getEmail().lower().strip() == "":
3008 keyPA
= "%s-%s-%s"%(pAut
.getFamilyName().lower(), pAut
.getFirstName().lower(), pAut
.getEmail().lower())
3009 primaryAuthors
[keyPA
] = pAut
3010 if pAut
.getEmail() != "":
3011 primaryAuthorEmails
.add(pAut
.getEmail())
3013 for coAut
in contrib
.getCoAuthorList():
3014 if coAut
.getFamilyName().lower().strip() == "" and coAut
.getFirstName().lower().strip() == "" and coAut
.getEmail().lower().strip() == "":
3016 keyCA
= "%s-%s-%s"%(coAut
.getFamilyName().lower(), coAut
.getFirstName().lower(), coAut
.getEmail().lower())
3017 coAuthors
[keyCA
] = coAut
3018 if coAut
.getEmail() != "":
3019 coAuthorEmails
.add(coAut
.getEmail())
3021 for pres
in contrib
.getSpeakerList():
3022 if pres
.getFamilyName().lower().strip() == "" and pres
.getFirstName().lower().strip() == "" and pres
.getEmail().lower().strip() == "":
3024 keyP
= "%s-%s-%s"%(pres
.getFamilyName().lower(), pres
.getFirstName().lower(), pres
.getEmail().lower())
3025 speakers
[keyP
] = pres
3026 if pres
.getEmail() != "":
3027 speakerEmails
.add(pres
.getEmail())
3028 emailList
= {"speakers":{},"primaryAuthors":{},"coAuthors":{}}
3029 emailList
["speakers"]["tree"] = speakers
3030 emailList
["primaryAuthors"]["tree"] = primaryAuthors
3031 emailList
["coAuthors"]["tree"] = coAuthors
3032 emailList
["speakers"]["emails"] = speakerEmails
3033 emailList
["primaryAuthors"]["emails"] = primaryAuthorEmails
3034 emailList
["coAuthors"]["emails"] = coAuthorEmails
3035 p
= conferences
.WPConfModifParticipantList(self
, self
._target
, emailList
, self
._displayedGroups
, self
._contribIds
)
3039 class RHMoveContribsToSession(RHConferenceModifBase
):
3041 def _checkParams(self
,params
):
3042 RHConferenceModifBase
._checkParams
(self
,params
)
3044 self
._session
=self
._target
.getSessionById(params
.get("targetSession",""))
3045 self
._contribIds
=self
._normaliseListParam
(params
.get("contributions",[]))
3046 if params
.has_key("OK"):
3047 if self
._session
is not None and self
._session
.isClosed():
3048 raise NoReportError(_("""The modification of the session "%s" is not allowed because it is closed""")%self
._session
.getTitle())
3049 self
._contribIds
=self
._normaliseListParam
(params
.get("contributions","").split(","))
3051 elif params
.has_key("CANCEL"):
3052 self
._action
="CANCEL"
3053 elif params
.has_key("CONFIRM"):
3054 self
._action
="MOVE_CONFIRMED"
3055 elif params
.has_key("CONFIRM_ALL"):
3056 self
._action
="MOVE_ALL_CONFIRMED"
3058 def _needsWarning(self
,contrib
):
3059 return (contrib
.getSession() is not None and \
3060 contrib
.getSession()!=self
._session
) or \
3061 (contrib
.getSession() is None and \
3062 self
._session
is not None and \
3063 contrib
.isScheduled())
3065 def _process( self
):
3066 url
=urlHandlers
.UHConfModifContribList
.getURL(self
._target
)
3067 if self
._action
=="CANCEL":
3070 elif self
._action
in ("MOVE","MOVE_CONFIRMED","MOVE_ALL_CONFIRMED"):
3072 for id in self
._contribIds
:
3073 contrib
=self
._target
.getContributionById(id)
3076 if self
._needsWarning
(contrib
):
3077 if self
._action
=="MOVE":
3078 p
=conferences
.WPModMoveContribsToSessionConfirmation(self
,self
._target
)
3079 return p
.display(contribIds
=self
._contribIds
,targetSession
=self
._session
)
3080 elif self
._action
=="MOVE_CONFIRMED":
3082 if contrib
.getSession() is not None and contrib
.getSession().isClosed():
3083 raise NoReportError(_("""The contribution "%s" cannot be moved because it is inside of the session "%s" that is closed""")%(contrib
.getId(), contrib
.getSession().getTitle()))
3084 contribList
.append(contrib
)
3085 for contrib
in contribList
:
3086 contrib
.setSession(self
._session
)
3089 p
=conferences
.WPModMoveContribsToSession(self
,self
._target
)
3090 return p
.display(contribIds
=self
._contribIds
)
3092 class RHMaterialPackageAbstract(RHConferenceModifBase
):
3095 def _checkParams( self
, params
):
3096 RHConferenceModifBase
._checkParams
( self
, params
)
3097 abstractIds
= self
._normaliseListParam
( params
.get("abstracts", []) )
3098 self
._abstracts
= []
3099 for aID
in abstractIds
:
3100 self
._abstracts
.append(self
._conf
.getAbstractMgr().getAbstractById(aID
))
3102 def _process( self
):
3103 if not self
._abstracts
:
3104 return FormValuesError(_("No abstract selected"))
3105 p
= AbstractPacker(self
._conf
)
3106 path
= p
.pack(self
._abstracts
, ZIPFileHandler())
3107 return send_file('abstractFiles.zip', path
, 'ZIP', inline
=False)
3110 class RHMaterialPackage(RHConferenceModifBase
):
3112 def _checkParams(self
, params
):
3113 RHConferenceModifBase
._checkParams
(self
, params
)
3114 self
._contribIds
= self
._normaliseListParam
(params
.get("contributions", []))
3116 for id in self
._contribIds
:
3117 self
._contribs
.append(self
._conf
.getContributionById(id))
3120 if not self
._contribs
:
3121 return "No contribution selected"
3122 p
=ContribPacker(self
._conf
)
3123 path
=p
.pack(self
._contribs
, ZIPFileHandler())
3124 if not p
.getItems():
3125 raise NoReportError(_("The selected package does not contain any items"))
3126 return send_file('material.zip', path
, 'ZIP', inline
=False)
3129 class RHProceedings(RHConferenceModifBase
):
3131 def _process( self
):
3132 set_best_lang() # prevents from having a _LazyString when generating a pdf without session.lang set
3133 p
=ProceedingsPacker(self
._conf
)
3134 path
=p
.pack(ZIPFileHandler())
3135 return send_file('proceedings.zip', path
, 'ZIP', inline
=False)
3138 class RHAbstractBook( RHConfModifCFABase
):
3139 _uh
= urlHandlers
.UHConfModAbstractBook
3141 def _checkParams( self
, params
):
3142 RHConfModifCFABase
._checkParams
( self
, params
)
3144 def _process( self
):
3145 p
= conferences
.WPModAbstractBook(self
,self
._target
)
3149 class RHAbstractBookToogleShowIds( RHConfModifCFABase
):
3150 _uh
= urlHandlers
.UHConfModAbstractBookToogleShowIds
3152 def _process( self
):
3153 self
._conf
.getBOAConfig().setShowIds(not self
._conf
.getBOAConfig().getShowIds())
3154 self
._redirect
( urlHandlers
.UHConfModAbstractBook
.getURL( self
._conf
) )
3157 class RHModifSessionCoordRights( RHConferenceModifBase
):
3158 _uh
= urlHandlers
.UHConfPerformDataModif
3160 def _checkParams( self
, params
):
3161 RHConferenceModifBase
._checkParams
( self
, params
)
3162 self
._rightId
= params
.get("rightId", "")
3164 def _process( self
):
3165 if self
._rightId
!= "":
3166 if self
._conf
.hasSessionCoordinatorRight(self
._rightId
):
3167 self
._conf
.removeSessionCoordinatorRight(self
._rightId
)
3169 self
._conf
.addSessionCoordinatorRight(self
._rightId
)
3170 self
._redirect
( "%s#sessionCoordinatorRights"%urlHandlers
.UHConfModifAC
.getURL( self
._conf
) )
3173 class RHConfModifPendingQueues( RHConferenceModifBase
):
3174 _uh
= urlHandlers
.UHConfModifPendingQueues
3176 def _process( self
):
3177 p
= conferences
.WPConfModifPendingQueues( self
, self
._target
, self
._getRequestParams
().get("tab","conf_submitters") )
3180 class RHConfModifPendingQueuesActionConfMgr
:
3182 class to select the action to do with the selected pending conference submitters
3185 _uh
= urlHandlers
.UHConfModifPendingQueuesActionConfMgr
3187 def process(self
, params
):
3188 if 'remove' in params
:
3189 return RHConfModifPendingQueuesRemoveConfMgr().process(params
)
3190 elif 'reminder' in params
:
3191 return RHConfModifPendingQueuesReminderConfMgr().process(params
)
3192 return "no action to do"
3194 class RHConfModifPendingQueuesRemoveConfMgr( RHConferenceModifBase
):
3196 def _checkParams( self
, params
):
3197 RHConferenceModifBase
._checkParams
( self
, params
)
3198 self
._pendingConfMgrIds
= self
._normaliseListParam
( params
.get("pendingUsers", []) )
3199 self
._pendingConfMgrs
= []
3200 for id in self
._pendingConfMgrIds
:
3201 self
._pendingConfMgrs
.extend(self
._conf
.getPendingQueuesMgr().getPendingConfManagersByEmail(id))
3202 self
._remove
=params
.has_key("confirm")
3203 self
._confirmed
=params
.has_key("confirm") or params
.has_key("cancel")
3205 def _process( self
):
3206 url
=urlHandlers
.UHConfModifPendingQueues
.getURL(self
._conf
)
3207 url
.addParam("tab","conf_managers")
3208 if self
._pendingConfMgrs
== []:
3212 for ps
in self
._pendingConfMgrs
:
3213 self
._conf
.getPendingQueuesMgr().removePendingConfManager(ps
)
3216 wp
= conferences
.WPConfModifPendingQueuesRemoveConfMgrConfirm(self
, self
._conf
, self
._pendingConfMgrIds
)
3219 class RHConfModifPendingQueuesReminderConfMgr( RHConferenceModifBase
):
3221 def _checkParams( self
, params
):
3222 RHConferenceModifBase
._checkParams
( self
, params
)
3223 self
._pendingConfMgrIds
= self
._normaliseListParam
( params
.get("pendingUsers", []) )
3224 self
._pendingConfMgrs
= []
3225 for email
in self
._pendingConfMgrIds
:
3226 self
._pendingConfMgrs
.append(self
._conf
.getPendingQueuesMgr().getPendingConfManagersByEmail(email
))
3227 self
._send
=params
.has_key("confirm")
3228 self
._confirmed
=params
.has_key("confirm") or params
.has_key("cancel")
3231 def _process( self
):
3232 url
=urlHandlers
.UHConfModifPendingQueues
.getURL(self
._conf
)
3233 url
.addParam("tab","conf_managers")
3234 if self
._pendingConfMgrs
== []:
3238 pendings
=pendingQueues
.PendingConfManagersHolder()
3239 for pss
in self
._pendingConfMgrs
:
3240 pendings
._sendReminderEmail
(pss
)
3243 wp
= conferences
.WPConfModifPendingQueuesReminderConfMgrConfirm(self
, self
._conf
, self
._pendingConfMgrIds
)
3246 class RHConfModifPendingQueuesActionConfSubm
:
3248 class to select the action to do with the selected pending conference submitters
3251 _uh
= urlHandlers
.UHConfModifPendingQueuesActionConfSubm
3253 def process(self
, params
):
3254 if 'remove' in params
:
3255 return RHConfModifPendingQueuesRemoveConfSubm().process(params
)
3256 elif 'reminder' in params
:
3257 return RHConfModifPendingQueuesReminderConfSubm().process(params
)
3258 return "no action to do"
3260 class RHConfModifPendingQueuesRemoveConfSubm( RHConferenceModifBase
):
3262 def _checkParams( self
, params
):
3263 RHConferenceModifBase
._checkParams
( self
, params
)
3264 self
._pendingConfSubmIds
= self
._normaliseListParam
( params
.get("pendingUsers", []) )
3265 self
._pendingConfSubms
= []
3266 for id in self
._pendingConfSubmIds
:
3267 self
._pendingConfSubms
.extend(self
._conf
.getPendingQueuesMgr().getPendingConfSubmittersByEmail(id))
3268 self
._remove
=params
.has_key("confirm")
3269 self
._confirmed
=params
.has_key("confirm") or params
.has_key("cancel")
3271 def _process( self
):
3272 url
=urlHandlers
.UHConfModifPendingQueues
.getURL(self
._conf
)
3273 url
.addParam("tab","conf_submitters")
3274 if self
._pendingConfSubms
== []:
3278 for ps
in self
._pendingConfSubms
:
3279 self
._conf
.getPendingQueuesMgr().removePendingConfSubmitter(ps
)
3282 wp
= conferences
.WPConfModifPendingQueuesRemoveConfSubmConfirm(self
, self
._conf
, self
._pendingConfSubmIds
)
3285 class RHConfModifPendingQueuesReminderConfSubm( RHConferenceModifBase
):
3287 def _checkParams( self
, params
):
3288 RHConferenceModifBase
._checkParams
( self
, params
)
3289 self
._pendingConfSubmIds
= self
._normaliseListParam
( params
.get("pendingUsers", []) )
3290 self
._pendingConfSubms
= []
3291 for email
in self
._pendingConfSubmIds
:
3292 self
._pendingConfSubms
.append(self
._conf
.getPendingQueuesMgr().getPendingConfSubmittersByEmail(email
))
3293 self
._send
=params
.has_key("confirm")
3294 self
._confirmed
=params
.has_key("confirm") or params
.has_key("cancel")
3297 def _process( self
):
3298 url
=urlHandlers
.UHConfModifPendingQueues
.getURL(self
._conf
)
3299 url
.addParam("tab","conf_submitters")
3300 if self
._pendingConfSubms
== []:
3304 pendings
=pendingQueues
.PendingConfSubmittersHolder()
3305 for pss
in self
._pendingConfSubms
:
3306 pendings
._sendReminderEmail
(pss
)
3309 wp
= conferences
.WPConfModifPendingQueuesReminderConfSubmConfirm(self
, self
._conf
, self
._pendingConfSubmIds
)
3312 class RHConfModifPendingQueuesActionSubm
:
3314 class to select the action to do with the selected pending contribution submitters
3317 _uh
= urlHandlers
.UHConfModifPendingQueuesActionSubm
3319 def process(self
, params
):
3320 if 'remove' in params
:
3321 return RHConfModifPendingQueuesRemoveSubm().process(params
)
3322 elif 'reminder' in params
:
3323 return RHConfModifPendingQueuesReminderSubm().process(params
)
3324 return "no action to do"
3326 class RHConfModifPendingQueuesRemoveSubm( RHConferenceModifBase
):
3328 def _checkParams( self
, params
):
3329 RHConferenceModifBase
._checkParams
( self
, params
)
3330 self
._pendingSubmIds
= self
._normaliseListParam
( params
.get("pendingUsers", []) )
3331 self
._pendingSubms
= []
3332 for id in self
._pendingSubmIds
:
3333 self
._pendingSubms
.extend(self
._conf
.getPendingQueuesMgr().getPendingSubmittersByEmail(id))
3334 self
._remove
=params
.has_key("confirm")
3335 self
._confirmed
=params
.has_key("confirm") or params
.has_key("cancel")
3337 def _process( self
):
3338 url
=urlHandlers
.UHConfModifPendingQueues
.getURL(self
._conf
)
3339 url
.addParam("tab","submitters")
3340 if self
._pendingSubms
== []:
3344 for ps
in self
._pendingSubms
:
3345 self
._conf
.getPendingQueuesMgr().removePendingSubmitter(ps
)
3348 wp
= conferences
.WPConfModifPendingQueuesRemoveSubmConfirm(self
, self
._conf
, self
._pendingSubmIds
)
3351 class RHConfModifPendingQueuesReminderSubm( RHConferenceModifBase
):
3353 def _checkParams( self
, params
):
3354 RHConferenceModifBase
._checkParams
( self
, params
)
3355 self
._pendingSubmIds
= self
._normaliseListParam
( params
.get("pendingUsers", []) )
3356 self
._pendingSubms
= []
3357 for email
in self
._pendingSubmIds
:
3358 self
._pendingSubms
.append(self
._conf
.getPendingQueuesMgr().getPendingSubmittersByEmail(email
))
3359 self
._send
=params
.has_key("confirm")
3360 self
._confirmed
=params
.has_key("confirm") or params
.has_key("cancel")
3363 def _process( self
):
3364 url
=urlHandlers
.UHConfModifPendingQueues
.getURL(self
._conf
)
3365 url
.addParam("tab","submitters")
3366 if self
._pendingSubms
== []:
3370 pendings
=pendingQueues
.PendingSubmittersHolder()
3371 for pss
in self
._pendingSubms
:
3372 pendings
._sendReminderEmail
(pss
)
3375 wp
= conferences
.WPConfModifPendingQueuesReminderSubmConfirm(self
, self
._conf
, self
._pendingSubmIds
)
3378 class RHConfModifPendingQueuesActionMgr
:
3380 class to select the action to do with the selected pending submitters
3383 _uh
= urlHandlers
.UHConfModifPendingQueuesActionMgr
3385 def process(self
, params
):
3386 if 'remove' in params
:
3387 return RHConfModifPendingQueuesRemoveMgr().process(params
)
3388 elif 'reminder' in params
:
3389 return RHConfModifPendingQueuesReminderMgr().process(params
)
3390 return "no action to do"
3392 class RHConfModifPendingQueuesRemoveMgr( RHConferenceModifBase
):
3394 def _checkParams( self
, params
):
3395 RHConferenceModifBase
._checkParams
( self
, params
)
3396 self
._pendingMgrIds
= self
._normaliseListParam
( params
.get("pendingUsers", []) )
3397 self
._pendingMgrs
= []
3398 for id in self
._pendingMgrIds
:
3399 self
._pendingMgrs
.extend(self
._conf
.getPendingQueuesMgr().getPendingManagersByEmail(id))
3400 self
._remove
=params
.has_key("confirm")
3401 self
._confirmed
=params
.has_key("confirm") or params
.has_key("cancel")
3404 def _process( self
):
3405 url
=urlHandlers
.UHConfModifPendingQueues
.getURL(self
._conf
)
3406 url
.addParam("tab","managers")
3407 if self
._pendingMgrs
== []:
3411 for ps
in self
._pendingMgrs
:
3412 self
._conf
.getPendingQueuesMgr().removePendingManager(ps
)
3415 wp
= conferences
.WPConfModifPendingQueuesRemoveMgrConfirm(self
, self
._conf
, self
._pendingMgrIds
)
3418 class RHConfModifPendingQueuesReminderMgr( RHConferenceModifBase
):
3420 def _checkParams( self
, params
):
3421 RHConferenceModifBase
._checkParams
( self
, params
)
3422 self
._pendingMgrIds
= self
._normaliseListParam
( params
.get("pendingUsers", []) )
3423 self
._pendingMgrs
= []
3424 for email
in self
._pendingMgrIds
:
3425 self
._pendingMgrs
.append(self
._conf
.getPendingQueuesMgr().getPendingManagersByEmail(email
))
3426 self
._send
=params
.has_key("confirm")
3427 self
._confirmed
=params
.has_key("confirm") or params
.has_key("cancel")
3430 def _process( self
):
3431 url
=urlHandlers
.UHConfModifPendingQueues
.getURL(self
._conf
)
3432 url
.addParam("tab","managers")
3433 if self
._pendingMgrs
== []:
3437 pendings
=pendingQueues
.PendingManagersHolder()
3438 for pss
in self
._pendingMgrs
:
3439 pendings
._sendReminderEmail
(pss
)
3442 wp
= conferences
.WPConfModifPendingQueuesReminderMgrConfirm(self
, self
._conf
, self
._pendingMgrIds
)
3445 class RHConfModifPendingQueuesActionCoord
:
3447 class to select the action to do with the selected pending submitters
3450 _uh
= urlHandlers
.UHConfModifPendingQueuesActionCoord
3452 def process(self
, params
):
3453 if 'remove' in params
:
3454 return RHConfModifPendingQueuesRemoveCoord().process(params
)
3455 elif 'reminder' in params
:
3456 return RHConfModifPendingQueuesReminderCoord().process(params
)
3457 return "no action to do"
3459 class RHConfModifPendingQueuesRemoveCoord( RHConferenceModifBase
):
3461 def _checkParams( self
, params
):
3462 RHConferenceModifBase
._checkParams
( self
, params
)
3463 self
._pendingCoordIds
= self
._normaliseListParam
( params
.get("pendingUsers", []) )
3464 self
._pendingCoords
= []
3465 for id in self
._pendingCoordIds
:
3466 self
._pendingCoords
.extend(self
._conf
.getPendingQueuesMgr().getPendingCoordinatorsByEmail(id))
3467 self
._remove
=params
.has_key("confirm")
3468 self
._confirmed
=params
.has_key("confirm") or params
.has_key("cancel")
3471 def _process( self
):
3472 url
=urlHandlers
.UHConfModifPendingQueues
.getURL(self
._conf
)
3473 url
.addParam("tab", "coordinators")
3474 if self
._pendingCoords
== []:
3478 for ps
in self
._pendingCoords
:
3479 self
._conf
.getPendingQueuesMgr().removePendingCoordinator(ps
)
3482 wp
= conferences
.WPConfModifPendingQueuesRemoveCoordConfirm(self
, self
._conf
, self
._pendingCoordIds
)
3485 class RHConfModifPendingQueuesReminderCoord( RHConferenceModifBase
):
3487 def _checkParams( self
, params
):
3488 RHConferenceModifBase
._checkParams
( self
, params
)
3489 self
._pendingCoordIds
= self
._normaliseListParam
( params
.get("pendingUsers", []) )
3490 self
._pendingCoords
= []
3491 for email
in self
._pendingCoordIds
:
3492 self
._pendingCoords
.append(self
._conf
.getPendingQueuesMgr().getPendingCoordinatorsByEmail(email
))
3493 self
._send
=params
.has_key("confirm")
3494 self
._confirmed
=params
.has_key("confirm") or params
.has_key("cancel")
3497 def _process( self
):
3498 url
=urlHandlers
.UHConfModifPendingQueues
.getURL(self
._conf
)
3499 url
.addParam("tab", "coordinators")
3500 if self
._pendingCoords
== []:
3504 pendings
=pendingQueues
.PendingCoordinatorsHolder()
3505 for pss
in self
._pendingCoords
:
3506 pendings
._sendReminderEmail
(pss
)
3509 wp
= conferences
.WPConfModifPendingQueuesReminderCoordConfirm(self
, self
._conf
, self
._pendingCoordIds
)
3512 class RHConfAbstractFields( RHConfModifCFABase
):
3513 _uh
= urlHandlers
.UHConfModifCFAOptFld
3515 def _checkParams( self
, params
):
3516 RHConfModifCFABase
._checkParams
( self
, params
)
3517 self
._fieldId
= params
.get("fieldId", "")
3518 if self
._fieldId
.strip()!="":
3519 if not self
._conf
.getAbstractMgr().getAbstractFieldsMgr().hasField(self
._fieldId
):
3520 raise MaKaCError( _("The field that you are trying to enable/disable does not exist"))
3522 def _process( self
):
3523 if self
._fieldId
.strip() != "":
3524 if self
._conf
.getAbstractMgr().hasEnabledAbstractField(self
._fieldId
):
3525 self
._conf
.getAbstractMgr().disableAbstractField(self
._fieldId
)
3527 self
._conf
.getAbstractMgr().enableAbstractField(self
._fieldId
)
3528 self
._redirect
(urlHandlers
.UHConfModifCFA
.getURL(self
._conf
))
3531 class RHConfRemoveAbstractField( RHConfModifCFABase
):
3532 _uh
= urlHandlers
.UHConfModifCFARemoveOptFld
3534 def _checkParams( self
, params
):
3535 RHConfModifCFABase
._checkParams
( self
, params
)
3537 if params
.get("fieldId","") != "":
3538 self
._fieldIds
= self
._normaliseListParam
( params
["fieldId"] )
3540 def _process( self
):
3541 for id in self
._fieldIds
:
3542 self
._conf
.getAbstractMgr().removeAbstractField(id)
3543 self
._redirect
(urlHandlers
.UHConfModifCFA
.getURL(self
._conf
))
3545 class RHConfMoveAbsFieldUp( RHConfModifCFABase
):
3546 _uh
= urlHandlers
.UHConfModifCFAAbsFieldUp
3548 def _checkParams( self
, params
):
3549 RHConfModifCFABase
._checkParams
( self
, params
)
3550 self
._fieldId
= params
.get("fieldId", "")
3552 def _process( self
):
3553 if self
._fieldId
!= "":
3554 self
._conf
.getAbstractMgr().moveAbsFieldUp(self
._fieldId
)
3555 self
._redirect
(urlHandlers
.UHConfModifCFA
.getURL(self
._conf
))
3557 class RHConfMoveAbsFieldDown( RHConfModifCFABase
):
3558 _uh
= urlHandlers
.UHConfModifCFAAbsFieldDown
3560 def _checkParams( self
, params
):
3561 RHConfModifCFABase
._checkParams
( self
, params
)
3562 self
._fieldId
= params
.get("fieldId", "")
3564 def _process( self
):
3565 if self
._fieldId
!= "":
3566 self
._conf
.getAbstractMgr().moveAbsFieldDown(self
._fieldId
)
3567 self
._redirect
(urlHandlers
.UHConfModifCFA
.getURL(self
._conf
))
3570 class RHScheduleMoveEntryUp(RHConferenceModifBase
):
3572 def _checkParams(self
, params
):
3573 RHConferenceModifBase
._checkParams
(self
, params
)
3574 self
._entry
=self
._conf
.getSchedule().getEntryById(params
.get("schEntryId",""))
3578 if self
._entry
is not None:
3579 self
._conf
.getSchedule().moveUpEntry(self
._entry
)
3580 date
=self
._entry
.getStartDate()
3582 self
._redirect
(urlHandlers
.UHConfModifSchedule
.getURL(self
._conf
))
3584 self
._redirect
("%s#%s"%(urlHandlers
.UHConfModifSchedule
.getURL(self
._conf
),date
.strftime("%Y-%m-%d")))
3587 class RHScheduleMoveEntryDown(RHConferenceModifBase
):
3589 def _checkParams(self
, params
):
3590 RHConferenceModifBase
._checkParams
(self
, params
)
3591 self
._entry
=self
._conf
.getSchedule().getEntryById(params
.get("schEntryId",""))
3595 if self
._entry
is not None:
3596 self
._conf
.getSchedule().moveDownEntry(self
._entry
)
3597 date
=self
._entry
.getStartDate()
3599 self
._redirect
(urlHandlers
.UHConfModifSchedule
.getURL(self
._conf
))
3601 self
._redirect
("%s#%s"%(urlHandlers
.UHConfModifSchedule
.getURL(self
._conf
),date
.strftime("%Y-%m-%d")))
3604 class RHReschedule(RHConferenceModifBase
):
3606 def _checkParams(self
, params
):
3607 RHConferenceModifBase
._checkParams
(self
, params
)
3608 self
._cancel
=params
.has_key("CANCEL")
3609 self
._ok
=params
.has_key("OK")
3610 self
._hour
=params
.get("hour","")
3611 self
._minute
=params
.get("minute","")
3612 self
._action
=params
.get("action","duration")
3613 self
._fit
= params
.get("fit","noFit") == "doFit"
3614 self
._targetDay
=params
.get("targetDay",None) #comes in format YYYYMMDD, ex: 20100317
3615 self
._sessionId
= params
.get("sessionId", "")
3616 if self
._targetDay
is None:
3617 raise MaKaCError( _("Error while rescheduling timetable: not target day"))
3619 self
._day
=timezone(self
._conf
.getTimezone()).localize(datetime(int(params
["targetDay"][0:4]),
3620 int(params
["targetDay"][4:6]),
3621 int(params
["targetDay"][6:8])))
3623 if self
._hour
.strip() == "" or self
._minute
.strip() == "":
3624 raise FormValuesError( _("Please write the time with the format HH:MM. For instance, 00:05 to indicate 'O hours' and '5 minutes'"))
3626 if int(self
._hour
) or int(self
._hour
):
3628 except ValueError, e
:
3629 raise FormValuesError( _("Please write a number to specify the time HH:MM. For instance, 00:05 to indicate 'O hours' and '5 minutes'"))
3632 if not self
._cancel
:
3634 p
= conferences
.WPConfModifReschedule(self
, self
._conf
, self
._targetDay
)
3637 t
= timedelta(hours
=int(self
._hour
), minutes
=int(self
._minute
))
3639 self
._conf
.getSessionById(self
._sessionId
).getSchedule().rescheduleTimes(self
._action
, t
, self
._day
, self
._fit
)
3640 self
._redirect
("%s#%s" % (urlHandlers
.UHSessionModifSchedule
.getURL(self
._conf
.getSessionById(self
._sessionId
)), self
._targetDay
))
3642 self
._conf
.getSchedule().rescheduleTimes(self
._action
, t
, self
._day
, self
._fit
)
3643 self
._redirect
("%s#%s" % (urlHandlers
.UHConfModifSchedule
.getURL(self
._conf
), self
._targetDay
))
3646 class RHRelocate(RHConferenceModifBase
):
3648 def _checkParams(self
, params
):
3649 RHConferenceModifBase
._checkParams
(self
, params
)
3651 if params
.has_key("contribId"):
3652 self
._entry
= self
._conf
.getContributionById(params
.get("contribId",""))
3653 self
._schEntry
= self
._entry
.getSchEntry()
3654 elif params
.has_key("schEntryId"):
3655 if params
.has_key("sessionId") and params
.has_key("slotId"):
3656 self
._oldSch
= self
._conf
.getSessionById(params
.get("sessionId","")).getSlotById(params
.get("slotId","")).getSchedule()
3658 self
._oldSch
= self
._conf
.getSchedule()
3660 self
._schEntry
= self
._entry
= self
._oldSch
.getEntryById(params
.get("schEntryId",""))
3662 raise MaKaCError( _("Cannot find target item"))
3664 raise MaKaCError( _("No contribution to relocate"))
3665 self
._contribPlace
=params
.get("targetId","")
3666 self
._cancel
=params
.has_key("CANCEL")
3667 self
._ok
=params
.has_key("OK")
3668 self
._targetDay
=params
.get("targetDay","")
3669 self
._check
=int(params
.get("check","1"))
3672 if not self
._cancel
:
3674 p
=conferences
.WPConfModifRelocate(self
,self
._conf
, self
._entry
, self
._targetDay
)
3677 if self
._contribPlace
.strip() != "":
3678 if self
._contribPlace
!="conf":
3679 s
,ss
=self
._contribPlace
.split(":")
3680 session
=self
._conf
.getSessionById(s
)
3681 if session
is not None:
3682 slot
=session
.getSlotById(ss
)
3683 if slot
is not None:
3684 self
._schEntry
.getSchedule().removeEntry(self
._schEntry
)
3685 if isinstance(self
._entry
, conference
.Contribution
):
3686 self
._entry
.setSession(session
)
3687 slot
.getSchedule().addEntry(self
._schEntry
, check
=self
._check
)
3689 self
._schEntry
.getSchedule().removeEntry(self
._schEntry
)
3690 self
._conf
.getSchedule().addEntry(self
._schEntry
, check
=self
._check
)
3691 self
._redirect
("%s#%s"%(urlHandlers
.UHConfModifSchedule
.getURL(self
._conf
), self
._targetDay
))
3694 # ============================================================================
3695 # === Badges related =========================================================
3696 # ============================================================================
3698 ##------------------------------------------------------------------------------------------------------------
3699 class RHConfBadgeBase(RHConferenceModifBase
):
3701 def _checkProtection( self
):
3702 if not self
._target
.canManageRegistration(self
.getAW().getUser()):
3703 RHConferenceModifBase
._checkProtection
(self
)
3706 Badge Design and Printing classes
3708 class RHConfBadgePrinting(RHConfBadgeBase
):
3709 """ This class corresponds to the screen where templates are
3710 listed and can be created, edited, deleted and tried.
3711 It always displays the list of templates; but we can
3712 arrive to this page in different scenarios:
3713 -A template has just been created (templateId = new template id, new = True). The template
3714 will be stored and the temporary backgrounds stored in the session object archived.
3715 -A template has been edited (templateId = existing template id, new = False or not set).
3716 The template will be updated and the temporary backgrounds stored in it, archived.
3717 -A template had been deleted (deleteTemplateId = id of the template to delete)
3718 -We were creating / editing a template but we pressed the "Cancel" button
3719 (templateId = id of the template that was being created / edited, Cancel = True).
3720 Temporary backgrounds (in the session object or in the template object) will be deleted.
3723 def _checkParams(self
, params
):
3724 RHConfBadgeBase
._checkParams
(self
, params
)
3725 self
.__templateId
= params
.get("templateId",None)
3726 self
.__templateData
= params
.get("templateData",None)
3727 self
.__deleteTemplateId
= params
.get("deleteTemplateId",None)
3728 self
.__copyTemplateId
= params
.get("copyTemplateId",None)
3729 self
.__new
= params
.get("new","False") == "True"
3730 self
.__cancel
= params
.get("cancel","False") == "True"
3733 if self
._target
.isClosed():
3734 return conferences
.WPConferenceModificationClosed(self
, self
._target
).display()
3736 if self
.__templateId
and self
.__templateData
and not self
.__deleteTemplateId
:
3739 self
._target
.getBadgeTemplateManager().storeTemplate(self
.__templateId
, self
.__templateData
)
3740 key
= "tempBackground-%s-%s" % (self
._conf
.id, self
.__templateId
)
3741 filePaths
= session
.get(key
)
3743 cfg
= Config
.getInstance()
3744 tempPath
= cfg
.getUploadedFilesSharedTempDir()
3745 for filePath
in filePaths
:
3746 self
._target
.getBadgeTemplateManager().getTemplateById(self
.__templateId
).addTempBackgroundFilePath(filePath
)
3747 self
._tempFilesToDelete
.append(os
.path
.join(tempPath
, filePath
))
3748 self
._target
.getBadgeTemplateManager().getTemplateById(self
.__templateId
).archiveTempBackgrounds(self
._conf
)
3750 self
._target
.getBadgeTemplateManager().storeTemplate(self
.__templateId
, self
.__templateData
)
3752 elif self
.__deleteTemplateId
:
3753 self
._target
.getBadgeTemplateManager().deleteTemplate(self
.__deleteTemplateId
)
3755 elif self
.__copyTemplateId
:
3756 self
._target
.getBadgeTemplateManager().copyTemplate(self
.__copyTemplateId
)
3758 if self
._target
.getBadgeTemplateManager().hasTemplate(self
.__templateId
):
3759 self
._target
.getBadgeTemplateManager().getTemplateById(self
.__templateId
).deleteTempBackgrounds()
3761 key
= "tempBackground-%s-%s" % (self
._conf
.id, self
.__templateId
)
3762 session
.pop(key
, None)
3764 if self
._target
.getId() == "default":
3765 p
= admins
.WPBadgeTemplates(self
)
3766 url
= urlHandlers
.UHBadgeTemplates
.getURL()
3768 p
= conferences
.WPConfModifBadgePrinting(self
, self
._target
)
3769 url
= urlHandlers
.UHConfModifBadgePrinting
.getURL(self
._target
)
3770 if request
.method
== 'POST':
3776 class RHConfBadgeDesign(RHConfBadgeBase
):
3777 """ This class corresponds to the screen where templates are
3778 designed. We can arrive to this screen from different scenarios:
3779 -We are creating a new template (templateId = new template id, new = True)
3780 -We are editing an existing template (templateId = existing template id, new = False or not set)
3783 def _checkParams(self
, params
):
3784 RHConfBadgeBase
._checkParams
(self
, params
)
3785 self
.__templateId
= params
.get("templateId",None)
3786 new
= params
.get("new",'False')
3791 self
.__baseTemplate
= params
.get("baseTemplate",'blank')
3795 if self
._target
.isClosed():
3796 p
= conferences
.WPConferenceModificationClosed( self
, self
._target
)
3798 p
= conferences
.WPConfModifBadgeDesign(self
, self
._target
, self
.__templateId
, self
.__new
, self
.__baseTemplate
)
3801 class RHConfBadgePrintingPDF(RHConfBadgeBase
):
3802 """ This class is used to print the PDF from a badge template.
3803 There are 2 scenarios:
3804 -We are printing badges for all registrants (registrantList = 'all' or not set).
3805 -We are printing badges just for some registrants (registrantList = list of id's of registrants)
3808 def _checkParams(self
, params
):
3809 """ Default values (1.5, etc...) are CERN's defaults in cm.
3810 These default values also appear in ConfModifBadgePDFOptions.tpl
3811 marginTop: top margin
3812 marginBottom: bottom margin
3813 marginLeft: left margin
3814 marginRight: right margin
3815 marginColumns: margin between columns
3816 marginRows: margin between rows
3817 keepPDFOptions: tells if we should keep the other params for the next time
3818 by storing them in the database (in the conference object)
3820 RHConfBadgeBase
._checkParams
(self
, params
)
3822 self
.__templateId
= params
.get("templateId",None)
3824 #we retrieve the present PDF options of the conference in order to use
3825 #its values in case of input error
3826 self
.__PDFOptions
= self
._target
.getBadgeTemplateManager().getPDFOptions()
3828 self
.__keepPDFOptions
= params
.get("keepPDFOptions", False)
3829 #in case of input error, this will be set to False
3832 self
.__marginTop
= float(params
.get("marginTop",''))
3834 self
.__marginTop
= self
.__PDFOptions
.getTopMargin()
3835 self
.__keepPDFOptions
= False
3838 self
.__marginBottom
= float(params
.get("marginBottom",''))
3840 self
.__marginBottom
= self
.__PDFOptions
.getBottomMargin()
3841 self
.__keepPDFOptions
= False
3844 self
.__marginLeft
= float(params
.get("marginLeft",''))
3846 self
.__marginLeft
= self
.__PDFOptions
.getLeftMargin()
3847 self
.__keepPDFOptions
= False
3850 self
.__marginRight
= float(params
.get("marginRight",''))
3852 self
.__marginRight
= self
.__PDFOptions
.getRightMargin()
3853 self
.__keepPDFOptions
= False
3856 self
.__marginColumns
= float(params
.get("marginColumns",''))
3858 self
.__marginColumns
= self
.__PDFOptions
.getMarginColumns()
3859 self
.__keepPDFOptions
= False
3862 self
.__marginRows
= float(params
.get("marginRows",''))
3864 self
.__marginRows
= self
.__PDFOptions
.getMarginRows()
3865 self
.__keepPDFOptions
= False
3867 self
.__pagesize
= params
.get("pagesize",'A4')
3869 self
.__drawDashedRectangles
= params
.get("drawDashedRectangles", False) is not False
3870 self
.__landscape
= params
.get('landscape') == '1'
3872 self
.__registrantList
= params
.get("registrantList","all")
3873 if self
.__registrantList
!= "all":
3874 self
.__registrantList
= self
.__registrantList
.split(',')
3878 if self
._target
.isClosed():
3879 p
= conferences
.WPConferenceModificationClosed( self
, self
._target
)
3882 if self
._conf
.getRegistrantsList() == []:
3883 return _("There are no registrants, so no badges to print.")
3884 elif self
.__templateId
== None:
3885 return _("There is no badge template selected for this conference.")
3887 if self
.__keepPDFOptions
:
3888 #we store the pdf options into the conference
3889 self
.__PDFOptions
.setTopMargin(self
.__marginTop
)
3890 self
.__PDFOptions
.setBottomMargin(self
.__marginBottom
)
3891 self
.__PDFOptions
.setLeftMargin(self
.__marginLeft
)
3892 self
.__PDFOptions
.setRightMargin(self
.__marginRight
)
3893 self
.__PDFOptions
.setMarginColumns(self
.__marginColumns
)
3894 self
.__PDFOptions
.setMarginRows(self
.__marginRows
)
3895 self
.__PDFOptions
.setPagesize(self
.__pagesize
)
3896 self
.__PDFOptions
.setDrawDashedRectangles(self
.__drawDashedRectangles
)
3897 self
.__PDFOptions
.setLandscape(self
.__landscape
)
3900 pdf
= RegistrantsListToBadgesPDF(self
._conf
,
3901 self
._conf
.getBadgeTemplateManager().getTemplateById(self
.__templateId
),
3903 self
.__marginBottom
,
3906 self
.__marginColumns
,
3909 self
.__drawDashedRectangles
,
3910 self
.__registrantList
,
3912 return send_file('Badges.pdf', StringIO(pdf
.getPDFBin()), 'PDF')
3915 class RHConfBadgeSaveTempBackground(RHConfBadgeBase
):
3916 """ This class is used to save a background as a temporary file,
3917 before it is archived. Temporary backgrounds are archived
3918 after pressing the "save" button.
3919 The temporary background filepath can be stored in the session
3920 object (if we are creating a new template and it has not been stored yet)
3921 or in the corresponding template if we are editing a template.
3924 def _getNewTempFile( self
):
3925 cfg
= Config
.getInstance()
3926 tempPath
= cfg
.getUploadedFilesSharedTempDir()
3927 tempFileName
= tempfile
.mkstemp( suffix
="IndicoBadgeBG.tmp", dir = tempPath
)[1]
3930 def _saveFileToTemp(self
, fs
):
3931 fileName
= self
._getNewTempFile
()
3933 return os
.path
.split(fileName
)[-1]
3935 def _checkParams(self
, params
):
3936 RHConfBadgeBase
._checkParams
(self
, params
)
3937 self
.__templateId
= params
.get("templateId",None)
3939 self
._tempFilePath
= self
._saveFileToTemp
(params
["file"])
3940 except AttributeError:
3941 self
._tempFilePath
= None
3944 if self
._target
.isClosed():
3945 return json
.dumps({'status': 'error'}, textarea
=True)
3947 if self
._tempFilePath
is not None:
3948 if self
._conf
.getBadgeTemplateManager().hasTemplate(self
.__templateId
):
3949 backgroundId
= self
._conf
.getBadgeTemplateManager().getTemplateById(self
.__templateId
).addTempBackgroundFilePath(self
._tempFilePath
)
3951 key
= "tempBackground-%s-%s" % (self
._conf
.id, self
.__templateId
)
3952 value
= session
.get(key
)
3954 tempFilePathList
= PersistentList()
3955 tempFilePathList
.append(self
._tempFilePath
)
3956 session
[key
] = tempFilePathList
3959 value
.append(self
._tempFilePath
)
3960 backgroundId
= len(value
) - 1
3961 session
.modified
= True
3966 'url': str(urlHandlers
.UHConfModifBadgeGetBackground
.getURL(self
._conf
, self
.__templateId
, backgroundId
))
3969 class RHConfBadgeGetBackground(RHConfBadgeBase
):
3970 """ Class used to obtain a background in order to display it
3971 on the Badge Design screen.
3972 The background can be obtained from the archived files
3973 or from the temporary files.
3976 def _checkParams(self
, params
):
3977 RHConfBadgeBase
._checkParams
(self
, params
)
3978 self
.__templateId
= params
.get("templateId",None)
3979 self
.__backgroundId
= int(params
.get("backgroundId",None))
3980 self
.__width
= int(params
.get("width","-1"))
3981 self
.__height
= int(params
.get("height","-1"))
3983 def __imageBin(self
, image
):
3984 mimetype
= image
.getFileType() or 'application/octet-stream'
3985 return send_file(image
.getFileName(), image
.getFilePath(), mimetype
)
3987 def __fileBin(self
, filePath
):
3988 return send_file('tempBackground', filePath
, 'application/octet-stream')
3991 if self
._target
.isClosed():
3992 p
= conferences
.WPConferenceModificationClosed( self
, self
._target
)
3995 cfg
= Config
.getInstance()
3996 tempPath
= cfg
.getUploadedFilesSharedTempDir()
3997 if self
._conf
.getBadgeTemplateManager().hasTemplate(self
.__templateId
):
3998 isArchived
, image
= self
._conf
.getBadgeTemplateManager().getTemplateById(self
.__templateId
).getBackground(self
.__backgroundId
)
3999 if image
is not None:
4001 return self
.__imageBin
(image
)
4003 image
= os
.path
.join(tempPath
,image
)
4004 return self
.__fileBin
(image
)
4007 key
= "tempBackground-%s-%s" % (self
._conf
.id, self
.__templateId
)
4008 filePath
= os
.path
.join(tempPath
, session
[key
][int(self
.__backgroundId
)])
4009 return self
.__fileBin
(filePath
)
4012 # ============================================================================
4013 # === Posters related ========================================================
4014 # ============================================================================
4016 ##------------------------------------------------------------------------------------------------------------
4018 Poster Design and Printing classes
4020 class RHConfPosterPrinting(RHConferenceModifBase
):
4021 """ This class corresponds to the screen where templates are
4022 listed and can be created, edited, deleted and tried.
4023 It always displays the list of templates; but we can
4024 arrive to this page in different scenarios:
4025 -A template has just been created (templateId = new template id, new = True). The template
4026 will be stored and the temporary backgrounds stored in the session object archived.
4027 -A template has been edited (templateId = existing template id, new = False or not set).
4028 The template will be updated and the temporary backgrounds stored in it, archived.
4029 -A template had been deleted (deleteTemplateId = id of the template to delete)
4030 -We were creating / editing a template but we pressed the "Cancel" button
4031 (templateId = id of the template that was being created / edited, Cancel = True).
4032 Temporary backgrounds (in the session object or in the template object) will be deleted.
4035 def _checkParams(self
, params
):
4036 RHConferenceModifBase
._checkParams
(self
, params
)
4037 self
.__templateId
= params
.get("templateId",None)
4038 self
.__templateData
= params
.get("templateData",None)
4039 self
.__deleteTemplateId
= params
.get("deleteTemplateId",None)
4040 self
.__copyTemplateId
= params
.get("copyTemplateId",None)
4041 self
.__bgPosition
= params
.get("bgPosition",None)
4042 self
.__new
= params
.get("new","False") == "True"
4043 self
.__cancel
= params
.get("cancel","False") == "True"
4047 if self
._target
.isClosed():
4048 return conferences
.WPConferenceModificationClosed(self
, self
._target
).display()
4050 if self
.__templateId
and self
.__templateData
and not self
.__deleteTemplateId
:
4053 self
._target
.getPosterTemplateManager().storeTemplate(self
.__templateId
, self
.__templateData
)
4054 key
= "tempBackground-%s-%s" % (self
._conf
.id, self
.__templateId
)
4055 filePaths
= session
.get(key
)
4057 for filePath
in filePaths
:
4058 self
._target
.getPosterTemplateManager().getTemplateById(self
.__templateId
).addTempBackgroundFilePath(filePath
[0],filePath
[1])
4059 self
._target
.getPosterTemplateManager().getTemplateById(self
.__templateId
).archiveTempBackgrounds(self
._conf
)
4061 # template already exists
4062 self
._target
.getPosterTemplateManager().storeTemplate(self
.__templateId
, self
.__templateData
)
4063 elif self
.__deleteTemplateId
:
4064 self
._target
.getPosterTemplateManager().deleteTemplate(self
.__deleteTemplateId
)
4065 elif self
.__copyTemplateId
:
4066 self
._target
.getPosterTemplateManager().copyTemplate(self
.__copyTemplateId
)
4068 if self
._target
.getPosterTemplateManager().hasTemplate(self
.__templateId
):
4069 self
._target
.getPosterTemplateManager().getTemplateById(self
.__templateId
).deleteTempBackgrounds()
4071 fkey
= "tempBackground-%s-%s" % (self
._conf
.id, self
.__templateId
)
4072 session
.pop(fkey
, None)
4074 if self
._target
.getId() == "default":
4075 p
= admins
.WPPosterTemplates(self
)
4076 url
= urlHandlers
.UHPosterTemplates
.getURL()
4078 p
= conferences
.WPConfModifPosterPrinting(self
, self
._target
)
4079 url
= urlHandlers
.UHConfModifPosterPrinting
.getURL(self
._target
)
4080 if request
.method
== 'POST':
4086 class RHConfPosterDesign(RHConferenceModifBase
):
4087 """ This class corresponds to the screen where templates are
4088 designed. We can arrive to this screen from different scenarios:
4089 -We are creating a new template (templateId = new template id, new = True)
4090 -We are editing an existing template (templateId = existing template id, new = False or not set)
4093 def _checkParams(self
, params
):
4094 RHConferenceModifBase
._checkParams
(self
, params
)
4095 self
.__templateId
= params
.get("templateId",None)
4096 new
= params
.get("new",'False')
4101 self
.__baseTemplate
= params
.get("baseTemplate",'blank')
4104 if self
._target
.isClosed():
4105 p
= conferences
.WPConferenceModificationClosed( self
, self
._target
)
4107 if (self
._target
.getId() == "default"):
4108 p
= admins
.WPPosterTemplateDesign(self
, self
._target
, self
.__templateId
, self
.__new
)
4110 if self
.__new
== True and self
.__baseTemplate
!= 'blank':
4111 dconf
= conference
.CategoryManager().getDefaultConference()
4112 templMan
= self
._target
.getPosterTemplateManager()
4113 newId
= self
.__templateId
4114 dconf
.getPosterTemplateManager().getTemplateById(self
.__baseTemplate
).clone(templMan
, newId
)
4115 url
= urlHandlers
.UHConfModifPosterPrinting().getURL(self
._target
)
4119 p
= conferences
.WPConfModifPosterDesign(self
, self
._target
, self
.__templateId
, self
.__new
, self
.__baseTemplate
)
4122 class RHConfPosterPrintingPDF(RHConferenceModifBase
):
4124 This class is used to print the PDF from a poster template.
4126 def _checkParams(self
, params
):
4127 RHConferenceModifBase
._checkParams
(self
, params
)
4128 self
.__templateId
= params
.get("templateId",None)
4129 if self
.__templateId
== None:
4130 raise FormValuesError(_("Poster not selected"))
4131 if self
.__templateId
.find('global') != -1:
4132 self
.__templateId
= self
.__templateId
.replace('global','')
4133 self
.__template
= conference
.CategoryManager().getDefaultConference().getPosterTemplateManager().getTemplateById(self
.__templateId
)
4135 self
.__template
= self
._conf
.getPosterTemplateManager().getTemplateById(self
.__templateId
)
4137 self
.__marginH
= int(params
.get("marginH",'2'))
4141 self
.__marginV
= int(params
.get("marginV",'2'))
4144 self
.__pagesize
= params
.get("pagesize",'A4')
4148 if self
._target
.isClosed():
4149 p
= conferences
.WPConferenceModificationClosed( self
, self
._target
)
4152 pdf
= LectureToPosterPDF(self
._conf
,
4158 return send_file('Poster.pdf', StringIO(pdf
.getPDFBin()), 'PDF')
4161 class RHConfPosterSaveTempBackground(RHConferenceModifBase
):
4162 """ This class is used to save a background as a temporary file,
4163 before it is archived. Temporary backgrounds are archived
4164 after pressing the "save" button.
4165 The temporary background filepath can be stored in the session
4166 object (if we are creating a new template and it has not been stored yet)
4167 or in the corresponding template if we are editing a template.
4170 def _getNewTempFile( self
):
4171 cfg
= Config
.getInstance()
4172 tempPath
= cfg
.getUploadedFilesSharedTempDir()
4173 tempFileName
= tempfile
.mkstemp( suffix
="IndicoPosterBG.tmp", dir = tempPath
)[1]
4176 def _saveFileToTemp(self
, fs
):
4177 fileName
= self
._getNewTempFile
()
4179 return os
.path
.split(fileName
)[-1]
4181 def _checkParams(self
, params
):
4182 RHConferenceModifBase
._checkParams
(self
, params
)
4183 self
.__templateId
= params
.get("templateId",None)
4185 self
._bgPosition
= params
.get("bgPosition",None)
4188 self
._tempFilePath
= self
._saveFileToTemp
(params
["file"])
4189 except AttributeError:
4190 self
._tempFilePath
= None
4193 if self
._target
.isClosed():
4194 return json
.dumps({'status': 'error'}, textarea
=True)
4196 if self
._tempFilePath
is not None:
4197 if self
._conf
.getPosterTemplateManager().hasTemplate(self
.__templateId
):
4199 backgroundId
= self
._conf
.getPosterTemplateManager().getTemplateById(self
.__templateId
).addTempBackgroundFilePath(self
._tempFilePath
,self
._bgPosition
)
4202 key
= "tempBackground-%s-%s" % (self
._conf
.id, self
.__templateId
)
4203 value
= session
.get(key
)
4206 tempFilePathList
= PersistentList()
4207 tempFilePathList
.append((self
._tempFilePath
,self
._bgPosition
))
4208 session
[key
] = tempFilePathList
4212 value
.append((self
._tempFilePath
, self
._bgPosition
))
4213 backgroundId
= len(value
) - 1
4214 session
.modified
= True
4219 'url': str(urlHandlers
.UHConfModifPosterGetBackground
.getURL(self
._conf
, self
.__templateId
, backgroundId
)),
4220 'pos': self
._bgPosition
4224 class RHConfPosterGetBackground(RHConferenceModifBase
):
4225 """ Class used to obtain a background in order to display it
4226 on the Poster Design screen.
4227 The background can be obtained from the archived files
4228 or from the temporary files.
4231 def _checkParams(self
, params
):
4232 RHConferenceModifBase
._checkParams
(self
, params
)
4233 self
.__templateId
= params
.get("templateId",None)
4234 self
.__backgroundId
= int(params
.get("backgroundId",None))
4235 self
.__width
= int(params
.get("width","-1"))
4236 self
.__height
= int(params
.get("height","-1"))
4238 def __imageBin(self
, image
):
4239 mimetype
= image
.getFileType() or 'application/octet-stream'
4240 return send_file(image
.getFileName(), image
.getFilePath(), mimetype
)
4242 def __fileBin(self
, filePath
):
4243 return send_file('tempBackground', filePath
, mimetype
='application/octet-stream')
4247 if self
._target
.isClosed():
4248 p
= conferences
.WPConferenceModificationClosed( self
, self
._target
)
4251 cfg
= Config
.getInstance()
4252 tempPath
= cfg
.getUploadedFilesSharedTempDir()
4254 if self
._conf
.getPosterTemplateManager().hasTemplate(self
.__templateId
):
4256 isArchived
, image
= self
._conf
.getPosterTemplateManager().getTemplateById(self
.__templateId
).getBackground(self
.__backgroundId
)
4258 if image
is not None:
4260 return self
.__imageBin
(image
)
4262 image
= os
.path
.join(tempPath
,image
)
4263 return self
.__fileBin
(image
)
4266 key
= "tempBackground-%s-%s" % (self
._conf
.id, self
.__templateId
)
4267 filePath
= os
.path
.join(tempPath
, session
[key
][int(self
.__backgroundId
)][0])
4268 return self
.__fileBin
(filePath
)