VC: Fix error on clone page for legacy-ID events
[cds-indico.git] / indico / MaKaC / participant.py
blobef547caf23004431f9e2ccc88101aa593dfe18a0
1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
17 from persistent import Persistent
19 from MaKaC.common import log
20 from MaKaC.common.timezoneUtils import nowutc
21 import MaKaC.webinterface.urlHandlers as urlHandlers
22 from MaKaC.webinterface.mail import GenericMailer
23 from MaKaC.webinterface.mail import GenericNotification
24 from MaKaC.common import utils
25 from MaKaC.i18n import _
26 from indico.core import signals
27 from indico.core.config import Config
28 from MaKaC.common.fossilize import fossilizes, Fossilizable
29 from MaKaC.fossils.participant import IParticipantMinimalFossil
31 from indico.modules.users.legacy import AvatarUserWrapper
32 from indico.util.contextManager import ContextManager
35 class Participation(Persistent):
37 def __init__(self, conference):
38 self._conference = conference
39 self._obligatory = False
40 self._addedInfo = False
41 self._allowedForApplying = False
42 self._autoAccept = False
43 self._participantList = {}
44 self._pendingParticipantList = {}
45 self._declinedParticipantList = {}
46 self._participantIdGenerator = 0
47 self._pendingIdGenerator = 0
48 self._declinedIdGenerator = 0
49 self._displayParticipantList = True
50 self._numMaxParticipants = 0
51 self._notifyMgrNewParticipant = False
53 def clone(self, conference, options, eventManager=None):
54 newParticipation = conference.getParticipation()
55 newParticipation._obligatory = self._obligatory
56 newParticipation._allowedForApplying = self._allowedForApplying
57 newParticipation._autoAccept = self.isAutoAccept()
58 newParticipation._notifyMgrNewParticipant = self.isNotifyMgrNewParticipant()
59 newParticipation._displayParticipantList = self._displayParticipantList
60 if options.get("addedInfo", False) :
61 newParticipation._addedInfo = True
62 clonedStatuses = ["added", "excused", "refused"]
63 for p in self._participantList.values():
64 if p.getStatus() in clonedStatuses :
65 newParticipation.addParticipant(p.clone(conference), eventManager)
66 return newParticipation
68 def getConference(self):
69 return self._conference
71 def isObligatory(self):
72 return self._obligatory
74 def setObligatory(self, responsibleUser = None):
75 self._obligatory = True
76 logData = {}
77 logData["subject"] = "Event set to MANDATORY"
78 self._conference.getLogHandler().logAction(logData,
79 log.ModuleNames.PARTICIPANTS)
81 def setInobligatory(self, responsibleUser = None):
82 self._obligatory = False
83 logData = {}
84 logData["subject"] = "Event set to NON MANDATORY"
85 self._conference.getLogHandler().logAction(logData,
86 log.ModuleNames.PARTICIPANTS)
88 def isAddedInfo(self):
89 return self._addedInfo
91 def setAddedInfo(self, responsibleUser = None):
92 self._addedInfo = True
93 logData = {}
94 logData["subject"] = "Info about adding WILL be sent to participants"
95 self._conference.getLogHandler().logAction(logData,
96 log.ModuleNames.PARTICIPANTS)
98 def setNoAddedInfo(self, responsibleUser = None):
99 self._addedInfo = False
100 logData = {}
101 logData["subject"] = "Info about adding WON'T be sent to participants"
102 self._conference.getLogHandler().logAction(logData,
103 log.ModuleNames.PARTICIPANTS)
105 def isAllowedForApplying(self):
106 try :
107 if self._allowedForApplying :
108 pass
109 except AttributeError :
110 self._allowedForApplying = False
111 return self._allowedForApplying
113 def setAllowedForApplying(self, responsibleUser=None):
114 self._allowedForApplying = True
115 logData = {}
116 logData["subject"] = "Applying for participation is ALLOWED"
117 self._conference.getLogHandler().logAction(logData,
118 log.ModuleNames.PARTICIPANTS)
119 self.notifyModification()
121 def setNotAllowedForApplying(self, responsibleUser=None):
122 self._allowedForApplying = False
123 logData = {}
124 logData["subject"] = "Applying for participation is NOT ALLOWED"
125 self._conference.getLogHandler().logAction(logData,
126 log.ModuleNames.PARTICIPANTS)
127 self.notifyModification()
129 def isAutoAccept(self):
130 try:
131 return self._autoAccept
132 except AttributeError :
133 self._autoAccept = False
134 return False
136 def setAutoAccept(self, value, responsibleUser = None):
137 self._autoAccept = value
138 logData = {
139 "subject": "Auto accept of participation.",
140 "value": str(value)
142 self._conference.getLogHandler().logAction(logData,
143 log.ModuleNames.PARTICIPANTS)
144 self.notifyModification()
146 def getNumMaxParticipants(self):
147 try:
148 return self._numMaxParticipants
149 except AttributeError :
150 self._numMaxParticipants = 0
151 return False
153 def setNumMaxParticipants(self, value, responsibleUser = None):
154 self._numMaxParticipants = value
155 logData = {
156 "subject": "Num max of participants.",
157 "value": str(value)
159 self._conference.getLogHandler().logAction(logData,
160 log.ModuleNames.PARTICIPANTS)
161 self.notifyModification()
163 def isNotifyMgrNewParticipant(self):
164 try:
165 return self._notifyMgrNewParticipant
166 except AttributeError:
167 self._notifyMgrNewParticipant = False
168 return False
170 def setNotifyMgrNewParticipant(self, value):
171 currentUser = ContextManager.get('currentUser')
172 self._notifyMgrNewParticipant = value
173 logData = {}
175 if value:
176 logData["subject"] = _("Manager notification of participant application has been enabled")
177 else:
178 logData["subject"] = _("Manager notification of participant application has been disabled")
180 self._conference.getLogHandler().logAction(logData,
181 log.ModuleNames.PARTICIPANTS)
182 self.notifyModification()
184 def isFull(self):
185 if self.getNumMaxParticipants() != 0:
186 return len(self.getParticipantList()) >= self.getNumMaxParticipants()
187 return False
189 def alreadyParticipating(self, participant):
190 if participant is None :
191 return -1
192 if participant.getConference().getId() != self.getConference().getId() :
193 return -1
194 if participant.getId() in self._participantList.keys() :
195 return 1
196 if participant.getEmail().strip() == "":
197 return 0
198 for p in self._participantList.values() :
199 pString = p.getEmail()
200 newString = participant.getEmail()
201 if pString == newString :
202 return 1
203 return 0
205 def alreadyPending(self, pending):
206 if pending is None :
207 return -1
208 if pending.getConference().getId() != self.getConference().getId() :
209 return -1
210 if pending.getId() in self._pendingParticipantList.keys() :
211 return 1
212 if pending.getEmail().strip() == "":
213 return -1
214 for p in self._pendingParticipantList.values() :
215 if p.getEmail() == pending.getEmail() :
216 return 1
217 return 0
219 def getParticipantList(self):
220 participants = self._participantList.values()
221 participants.sort(utils.sortUsersByName)
222 return participants
224 def getPresentParticipantListText(self):
225 text = []
226 for p in self.getParticipantList():
227 if p.isPresent() and p.isConfirmed():
228 part = p.getName()
229 text.append(part)
230 return "; ".join(text)
232 def getParticipantById(self, participantId):
233 if participantId is not None:
234 return self._participantList.get(participantId, None)
235 else:
236 return None
238 def getPendingParticipantList(self):
239 return self._pendingParticipantList
241 def getPendingParticipantByKey(self, key):
242 if key is not None :
243 return self._pendingParticipantList.get(key, None)
244 else :
245 return None
247 def prepareAddedInfo(self, participant, eventManager):
248 if participant is None :
249 return None
250 if eventManager is None :
251 return None
253 data = {}
254 title = ""
255 familyName = ""
256 firstName = ""
257 refuse = ""
259 refuseURL = urlHandlers.UHConfParticipantsRefusal.getURL( self._conference )
260 refuseURL.addParam("participantId","%d"%self._lastParticipantId())
261 eventURL = urlHandlers.UHConferenceDisplay.getURL( self._conference )
263 toList = []
264 if participant.getAvatar() is not None :
265 toList.append(participant.getAvatar().getEmail())
266 data["toList"] = toList
267 title = participant.getAvatar().getTitle()
268 familyName = participant.getAvatar().getFamilyName()
269 firstName = participant.getAvatar().getFirstName()
270 else :
271 toList.append(participant.getEmail())
272 data["toList"] = toList
273 title = participant.getTitle()
274 familyName = participant.getFamilyName()
275 firstName = participant.getFamilyName()
276 if data["toList"] is None or len(data["toList"]) == 0 :
277 return None
279 if title is None or title == "" :
280 title = firstName
281 if not self._obligatory :
282 refuse = _("""
283 If you are not interested in taking part in this event
284 or cannot participate due to any reason, please indicate your decline
285 to the event organisers at %s
286 """)%refuseURL
287 else :
288 refuse = _("""
289 Due to decision of the organisers, presence in the event
290 is obligatory for all participants.
291 """)
293 data["fromAddr"] = eventManager.getEmail()
294 data["subject"] = "Invitation to '%s'" % self._conference.getTitle()
295 data["body"] = """
296 Dear %s %s,
298 you have been added to the list of '%s' participants.
299 Further information on this event are avaliable at %s.
301 Looking forward to meeting you at %s
302 Your Indico
303 on behalf of %s %s
304 """ % (title, familyName,
305 self._conference.getTitle(),
306 eventURL, refuse,
307 self._conference.getTitle(),
308 eventManager.getFirstName(), eventManager.getFamilyName())
310 return data
312 def getDeclinedParticipantList(self):
313 try:
314 return self._declinedParticipantList
315 except AttributeError :
316 self._declinedParticipantList = {}
317 return self._declinedParticipantList
319 def declineParticipant(self, participant, responsibleUser = None):
320 if participant.getConference().getId() != self._conference.getId() :
321 return False
322 self.removePendingParticipant(participant)
323 self.getDeclinedParticipantList()["%d"%self._newDeclinedId()] = participant
324 logData = participant.getParticipantData()
325 logData["subject"] = _("Participant declined : %s")%participant.getWholeName()
326 self._conference.getLogHandler().logAction(logData,
327 log.ModuleNames.PARTICIPANTS)
328 self.notifyModification()
331 def getDeclinedParticipantByKey(self, key):
332 if key is not None :
333 return self.getDeclinedParticipantList().get(key, None)
334 else :
335 return None
337 def addParticipant(self, participant, eventManager = None):
338 # check if it's worth to add the participant
339 if participant.getConference().getId() != self._conference.getId() :
340 return False
341 self.removePendingParticipant(participant)
342 if not participant.setId(self._newParticipantId()):
343 return False
344 if self.alreadyParticipating(participant) != 0 :
345 return False
346 self._participantList["%d"%self._lastParticipantId()] = participant
348 # remove him from the "pending" list
349 if participant in self._pendingParticipantList.values() :
350 for k in self._pendingParticipantList.keys() :
351 if self._pendingParticipantList[k] == participant :
352 del self._pendingParticipantList[k]
353 break
355 logData = participant.getParticipantData()
356 logData["subject"] = _("New participant added : %s")%participant.getWholeName()
357 self._conference.getLogHandler().logAction(logData,
358 log.ModuleNames.PARTICIPANTS)
360 participant.setStatusAdded()
362 # check if an e-mail should be sent...
363 if self._addedInfo :
364 # to notify the user of his/her addition
365 if eventManager is None :
366 return False
367 data = self.prepareAddedInfo(participant, eventManager)
368 GenericMailer.sendAndLog(GenericNotification(data),
369 self._conference,
370 log.ModuleNames.PARTICIPANTS)
372 avatar = participant.getAvatar()
374 if avatar is None :
375 # or to encourage him/her to register at Indico
376 #self.sendEncouragementToCreateAccount(participant)
377 pass
378 else:
379 # OK, if we have an avatar, let's keep things consistent
380 avatar.linkTo(self._conference,"participant")
382 self.notifyModification()
383 return True
385 def inviteParticipant(self, participant, eventManager):
386 if participant.getConference().getId() != self._conference.getId() :
387 return False
388 if not participant.setId(self._newParticipantId()):
389 return False
390 if eventManager is None :
391 return False
392 if self.alreadyParticipating(participant) != 0 :
393 return False
394 self._participantList["%d"%self._lastParticipantId()] = participant
395 logData = participant.getParticipantData()
396 logData["subject"] = _("New participant invited : %s")%participant.getWholeName()
397 self._conference.getLogHandler().logAction(logData,
398 log.ModuleNames.PARTICIPANTS)
399 participant.setStatusInvited()
400 if participant.getAvatar() is not None:
401 if not participant.getAvatar().getEmail():
402 return False
403 else :
404 if not participant.getEmail() or participant.getEmail() == "":
405 return False
406 self.notifyModification()
407 return True
409 def removeParticipant(self, participant, responsibleUser=None):
410 if participant is None:
411 return False
412 # If 'participant' is an object from Participant
413 if isinstance(participant, Participant):
414 # remove all entries with participant
415 for key, value in self._participantList.items():
416 if value == participant:
417 del self._participantList[key]
418 # If 'participant' is a key
419 else:
420 key = participant
421 if key not in self._participantList:
422 return False
423 participant = self._participantList[key]
424 del self._participantList[key]
426 logData = participant.getParticipantData()
427 logData["subject"] = _("Removed participant %s %s (%s)")%(participant.getFirstName(),participant.getFamilyName(),participant.getEmail())
428 self._conference.getLogHandler().logAction(logData,
429 log.ModuleNames.PARTICIPANTS)
431 avatar = participant.getAvatar()
432 if avatar:
433 avatar.unlinkTo(self._conference,"participant")
434 if participant._status in {'added', 'accepted'}:
435 signals.event.participant_changed.send(self._conference, user=avatar, participant=participant,
436 old_status=participant._status, action='removed')
437 self.notifyModification()
438 return True
440 def setParticipantAccepted(self, participantId):
441 participant = self.getParticipantById(participantId)
442 if participant:
443 status = participant.setStatusAccepted()
444 self.notifyModification()
445 return status
446 return None
448 def setParticipantRejected(self, participantId):
449 participant = self.getParticipantById(participantId)
450 if participant:
451 status = participant.setStatusRejected()
452 self.notifyModification()
453 return status
454 return None
456 def addPendingParticipant(self, participant):
457 if participant.getConference().getId() != self._conference.getId() :
458 return False
459 if participant.getId() is not None :
460 return False
461 if self.alreadyParticipating(participant) != 0 :
462 return False
463 if self.isAutoAccept():
464 self.addParticipant(participant)
465 else:
466 self._pendingParticipantList["%d"%self._newPendingId()] = participant
468 logData = participant.getParticipantData()
469 logData["subject"] = _("New pending participant : %s")%participant.getWholeName()
470 self._conference.getLogHandler().logAction(logData,
471 log.ModuleNames.PARTICIPANTS)
473 participant.setStatusPending()
475 profileURL = urlHandlers.UHConfModifParticipantsPending.getURL(self._conference)
477 toList = []
478 creator=self._conference.getCreator()
479 if isinstance(creator, AvatarUserWrapper):
480 toList.append(creator.getEmail())
481 for manager in self._conference.getAccessController().getModifierList() :
482 if isinstance(manager, AvatarUserWrapper):
483 toList.append(manager.getEmail())
485 data = {}
486 data["toList"] = toList
487 data["fromAddr"] = Config.getInstance().getSupportEmail()
488 data["subject"] = _("New pending participant for %s")%self._conference.getTitle()
489 data["body"] = """
490 Dear Event Manager,
492 a new person is asking for participation in %s.
493 Personal profile of this pending participant is available at %s
494 Please take this candidature into consideration and accept or reject it
496 Your Indico
497 """%(self._conference.getTitle(), profileURL)
499 GenericMailer.send(GenericNotification(data))
500 self.notifyModification()
501 return True
503 def removePendingParticipant(self, participant, responsibleUser=None):
504 if participant is None:
505 return False
506 if isinstance(participant, Participant):
507 # remove all entries with participant
508 for key, value in self._pendingParticipantList.items():
509 if value == participant:
510 del self._pendingParticipantList[key]
511 else:
512 key = participant
513 if key == "":
514 return False
515 participant = self._pendingParticipantList[key]
516 del self._pendingParticipantList[key]
518 logData = participant.getParticipantData()
519 logData["subject"] = _("Pending participant removed : %s")%participant.getWholeName()
520 self._conference.getLogHandler().logAction(logData,
521 log.ModuleNames.PARTICIPANTS)
523 self.notifyModification()
524 return True
526 def setPendingDeclined(self, pendingId):
527 return self._pendingParticipantList[pendingId].setStatusDeclined()
528 self.notifyModification()
530 def setPendingAdded(self, pendingId):
531 return self.addParticipant(self._pendingParticipantList[pendingId])
532 self.notifyModification()
534 def prepareAskForExcuse(self, eventManager, toIdList):
535 if eventManager is None :
536 return None
537 if toIdList is None :
538 return None
539 if not self._obligatory :
540 return None
542 if nowutc() < self._conference.getEndDate() :
543 return None
545 toList = []
546 for id in toIdList :
547 p = self._participantList[id]
548 if not p.isPresent() :
549 toList.append(p)
550 if len(toList) == 0 :
551 return None
553 data = {}
554 data["toList"] = toList
555 data["fromAddr"] = eventManager.getEmail()
556 data["subject"] = _("Please excuse your absence to %s")%self._conference.getTitle()
557 data["body"] = """
558 Dear Participant,
560 you were absent to %s, which was mandatory for you to attend.
561 Therefore %s %s, the organiser of this event is kindly asking you to provide reasons
562 for your absence, so that it could be excused - simply by replying to
563 this email.
565 Your Indico
566 on behalf of %s %s
567 """%(self._conference.getTitle(), \
568 eventManager.getFirstName(), eventManager.getFamilyName(), \
569 eventManager.getFirstName(), eventManager.getFamilyName())
571 return data
573 def askForExcuse(self, eventManager, toIdList):
574 data = self.prepareAskForExcuse(eventManager, toIdList)
575 if data is None :
576 return False
578 GenericMailer.sendAndLog(GenericNotification(data), self._conference,
579 log.ModuleNames.PARTICIPANTS)
580 return True
582 def sendSpecialEmail(self, participantsIdList, eventManager, data):
583 if participantsIdList is None :
584 return False
585 if eventManager is None :
586 return False
587 if len(participantsIdList) == 0:
588 return True
589 if data.get("subject", None) is None :
590 return False
591 if data.get("body", None) is None :
592 return False
593 data["fromAddr"] = eventManager.getEmail()
595 toList = []
596 for userId in participantsIdList :
597 participant = self._participantList.get(userId, None)
598 if participant is not None :
599 toList.append(participant.getEmail())
600 data["toList"] = toList
601 GenericMailer.sendAndLog(GenericNotification(data), self._conference,
602 log.ModuleNames.PARTICIPANTS)
603 return True
605 def getPresentNumber(self):
606 counter = 0
607 for p in self._participantList.values() :
608 if p.isPresent() and p.isConfirmed():
609 counter += 1
610 return counter
612 def getAbsentNumber(self):
613 counter = 0
614 for p in self._participantList.values() :
615 if not p.isPresent() and p.isConfirmed():
616 counter += 1
617 return counter
619 def getExcusedNumber(self):
620 counter = 0
621 for p in self._participantList.values() :
622 if "excused" == p.getStatus() :
623 counter += 1
624 return counter
626 def getInvitedNumber(self):
627 counter = 0
628 for p in self._participantList.values() :
629 if "invited" == p.getStatus() :
630 counter += 1
631 return counter
633 def getRejectedNumber(self):
634 counter = 0
635 for p in self._participantList.values() :
636 if "rejected" == p.getStatus() :
637 counter += 1
638 return counter
640 def getAddedNumber(self):
641 counter = 0
642 for p in self._participantList.values() :
643 if "added" == p.getStatus() :
644 counter += 1
645 return counter
647 def getRefusedNumber(self):
648 counter = 0
649 for p in self._participantList.values() :
650 if "excused" == p.getStatus() :
651 counter += 1
652 return counter
654 def getPendingNumber(self):
655 counter = 0
656 for part in self._pendingParticipantList.values():
657 if not part.getStatus() == "declined":
658 counter += 1
659 return counter
661 def getDeclinedNumber(self):
662 return len(self.getDeclinedParticipantList())
664 def _newParticipantId(self):
665 self._participantIdGenerator += 1
666 return self._participantIdGenerator
668 def _lastParticipantId(self):
669 return self._participantIdGenerator
671 def _newPendingId(self):
672 self._pendingIdGenerator += 1
673 return self._pendingIdGenerator
675 def _lastPendingId(self):
676 return self._pendingIdGenerator
678 def _newDeclinedId(self):
679 try:
680 self._declinedIdGenerator += 1
681 except AttributeError:
682 self._declinedIdGenerator = 1
683 return self._declinedIdGenerator
685 def _lastDeclinedId(self):
686 try:
687 return self._declinedIdGenerator
688 except AttributeError:
689 self._declinedIdGenerator = 0
690 return self._declinedIdGenerator
692 def displayParticipantList(self):
693 try :
694 if self._displayParticipantList :
695 pass
696 except AttributeError :
697 self._displayParticipantList = True
698 return self._displayParticipantList
700 def participantListDisplay(self):
701 self.displayParticipantList()
702 self._displayParticipantList = True
703 self.notifyModification()
705 def participantListHide(self):
706 self.displayParticipantList()
707 self._displayParticipantList = False
708 self.notifyModification()
710 def notifyModification(self):
711 if self._conference != None:
712 self._conference.notifyModification()
713 self._p_changed=1
715 #---------------------------------------------------------------------------------
718 class Participant(Persistent, Fossilizable):
720 Class collecting data about person taking part in meeting / lecture
722 fossilizes(IParticipantMinimalFossil)
724 def __init__(self, conference, avatar=None):
725 if avatar is not None:
726 self._id = None
727 self._avatar = avatar
728 self._firstName = avatar.getFirstName()
729 self._familyName = avatar.getFamilyName()
730 if self._firstName.strip() == "" and self._familyName.strip() == "":
731 self._firstName = "Undefined name"
732 self._title = avatar.getTitle()
733 self._address = avatar.getAddress()
734 self._affiliation = avatar.getAffiliation()
735 self._telephone = avatar.getTelephone()
736 self._fax = avatar.getFax()
737 self._email = avatar.getEmail()
739 self._status = None
740 self._present = True
741 self._participation = None
742 if conference is not None :
743 self._participation = conference.getParticipation()
744 else:
745 self._id = None
746 self._avatar = None
747 self._firstName = ""
748 self._familyName = ""
749 self._title = ""
750 self._address = ""
751 self._affiliation = ""
752 self._telephone = ""
753 self._fax = ""
754 self._email = ""
756 self._status = None
757 self._present = True
758 self._participation = None
759 if conference is not None:
760 self._participation = conference.getParticipation()
762 def clone(self, conference):
763 newPart = Participant(conference)
764 newPart._avatar = self._avatar
765 newPart._firstName = self._firstName
766 newPart._familyName = self._familyName
767 newPart._title = self._title
768 newPart._address = self._address
769 newPart._affiliation = self._affiliation
770 newPart._telephone = self._telephone
771 newPart._fax = self._fax
772 newPart._email = self._email
773 newPart._status = None
774 newPart._present = True
776 return newPart
779 def getId(self):
780 return self._id
782 def setId(self, id):
783 if self._id is not None :
784 return False
785 self._id = id
786 return True
788 def getAvatar(self):
789 return self._avatar
791 def getTitle(self):
792 return self._title
794 def setTitle(self, title):
795 self._title = title
797 def getFirstName(self):
798 return self._firstName
800 def setFirstName(self, firstName):
801 self._firstName = firstName
803 def getFamilyName(self):
804 return self._familyName
806 def setFamilyName(self, familyName):
807 self._familyName = familyName
809 def getWholeName(self):
810 return "%s %s %s"%(self._title,self._firstName,self._familyName)
812 def getFullName(self):
813 return self.getWholeName()
815 def getName(self):
816 return "%s %s"%(self.getFirstName(),self.getFamilyName())
818 def getAddress(self):
819 return self._address
821 def setAddress(self, address):
822 self._address = address
824 def getAffiliation(self):
825 return self._affiliation
827 def setAffiliation(self, affiliation):
828 self._affiliation = affiliation
830 def getTelephone(self):
831 return self._telephone
833 def setTelephone(self, telephone):
834 self._telephone = telephone
836 def getFax(self):
837 return self._fax
839 def setFax(self, fax):
840 self._fax = fax
842 def getEmail(self):
843 return self._email
845 def setEmail(self, email):
846 self._email = email
848 def getParticipantData(self):
849 data = {}
850 data["Title"] = self.getTitle()
851 data["Family name"] = self.getFamilyName()
852 data["First name"] = self.getFirstName()
853 data["Affiliation"] = self.getAffiliation()
854 data["Address"] = self.getAddress()
855 data["Email"] = self.getEmail()
856 data["Phone"] = self.getTelephone()
857 data["Fax"] = self.getFax()
858 data["Participant status"] = self.getStatus()
860 return data
862 def isPresent(self):
863 return self._present
865 def setPresent(self):
866 self._present = True
868 def setAbsent(self):
869 self._present = False
871 def getParticipation(self):
872 return self._participation
874 def getConference(self):
875 return self._participation.getConference()
877 def getStatus(self):
878 return self._status
880 def isConfirmed(self):
881 return self._status in ["accepted", "added"]
883 def setStatusAdded(self, responsibleUser=None):
884 old_status = self._status
885 self._status = "added"
886 #if self._status is None or self._status == "pending" :
887 # self._status = "added"
889 # logData = self.getParticipantData()
890 # logData["subject"] = _("%s : status set to ADDED")%self.getWholeName()
891 # self.getConference().getLogHandler().logAction(logData,"participants",responsibleUser)
893 signals.event.participant_changed.send(self.getConference(), user=self._avatar, participant=self,
894 old_status=old_status, action='added')
895 logData = self.getParticipantData()
896 logData["subject"] = "%s : status set to ADDED"%self.getWholeName()
897 self.getConference().getLogHandler().logAction(logData,
898 log.ModuleNames.PARTICIPANTS)
900 return True
902 def setStatusRefused(self, responsibleUser=None):
903 if self._status != "added":
904 return False
905 old_status = self._status
906 self._status = "refused"
908 signals.event.participant_changed.send(self.getConference(), user=self._avatar, participant=self,
909 old_status=old_status, action='removed')
910 logData = self.getParticipantData()
911 logData["subject"] = _("%s : status set to REFUSED")%self.getWholeName()
912 self.getConference().getLogHandler().logAction(logData,
913 log.ModuleNames.PARTICIPANTS)
915 return True
917 def setStatusExcused(self, responsibleUser=None):
918 if not self.isConfirmed() or self._present:
919 return False
920 self._status = "excused"
922 logData = self.getParticipantData()
923 logData["subject"] = _("%s : status set to EXCUSED")%self.getWholeName()
924 self.getConference().getLogHandler().logAction(logData,
925 log.ModuleNames.PARTICIPANTS)
927 return True
929 def setStatusInvited(self, responsibleUser=None):
930 if self._status is not None :
931 return False
932 self._status = "invited"
934 logData = self.getParticipantData()
935 logData["subject"] = _("%s : status set to INVITED")%self.getWholeName()
936 self.getConference().getLogHandler().logAction(logData,
937 log.ModuleNames.PARTICIPANTS)
939 return True
941 def setStatusAccepted(self, responsibleUser=None):
942 if self._status not in ('invited', 'added'):
943 return False
944 old_status = self._status
945 self._status = "accepted"
947 if old_status != 'added':
948 signals.event.participant_changed.send(self.getConference(), user=self._avatar, participant=self,
949 old_status=old_status, action='added')
950 logData = self.getParticipantData()
951 logData["subject"] = _("%s : status set to ACCEPTED")%self.getWholeName()
952 self.getConference().getLogHandler().logAction(logData,
953 log.ModuleNames.PARTICIPANTS)
955 return True
957 def setStatusRejected(self, responsibleUser=None):
958 if self._status not in ('invited', 'added'):
959 return False
960 old_status = self._status
961 self._status = "rejected"
963 if old_status == 'added':
964 signals.event.participant_changed.send(self.getConference(), user=self._avatar, participant=self,
965 old_status=old_status, action='removed')
966 logData = self.getParticipantData()
967 logData["subject"] = _("%s : status set to REJECTED")%self.getWholeName()
968 self.getConference().getLogHandler().logAction(logData,
969 log.ModuleNames.PARTICIPANTS)
971 return True
973 def setStatusPending(self, responsibleUser=None):
974 if self._status is not None :
975 return False
976 self._status = "pending"
978 logData = self.getParticipantData()
979 logData["subject"] = _("%s : status set to PENDING")%self.getWholeName()
980 self.getConference().getLogHandler().logAction(logData,
981 log.ModuleNames.PARTICIPANTS)
983 return True
985 def setStatusDeclined(self, responsibleUser=None):
986 if self._status != "pending" :
987 return False
988 self._status = "declined"
990 logData = self.getParticipantData()
991 logData["subject"] = _("%s : status set to DECLINED")%self.getWholeName()
992 self.getConference().getLogHandler().logAction(logData,
993 log.ModuleNames.PARTICIPANTS)
995 return True
998 #---------------------------------------------------------------------------------