| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | ## |
|---|
| 3 | ## |
|---|
| 4 | ## This file is part of CDS Indico. |
|---|
| 5 | ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN. |
|---|
| 6 | ## |
|---|
| 7 | ## CDS Indico is free software; you can redistribute it and/or |
|---|
| 8 | ## modify it under the terms of the GNU General Public License as |
|---|
| 9 | ## published by the Free Software Foundation; either version 2 of the |
|---|
| 10 | ## License, or (at your option) any later version. |
|---|
| 11 | ## |
|---|
| 12 | ## CDS Indico is distributed in the hope that it will be useful, but |
|---|
| 13 | ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 15 | ## General Public License for more details. |
|---|
| 16 | ## |
|---|
| 17 | ## You should have received a copy of the GNU General Public License |
|---|
| 18 | ## along with CDS Indico; if not, write to the Free Software Foundation, Inc., |
|---|
| 19 | ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 20 | |
|---|
| 21 | from MaKaC.plugins.Collaboration.base import CSBookingBase |
|---|
| 22 | from MaKaC.plugins.Collaboration.RecordingRequest.mail import NewRequestNotification, RequestModifiedNotification, RequestDeletedNotification,\ |
|---|
| 23 | RequestAcceptedNotification, RequestRejectedNotification,\ |
|---|
| 24 | RequestAcceptedNotificationAdmin, RequestRejectedNotificationAdmin |
|---|
| 25 | from MaKaC.common.mail import GenericMailer |
|---|
| 26 | from MaKaC.plugins.Collaboration.RecordingRequest.common import RecordingRequestException,\ |
|---|
| 27 | RecordingRequestError |
|---|
| 28 | from MaKaC.common.logger import Logger |
|---|
| 29 | from MaKaC.plugins.Collaboration.collaborationTools import MailTools |
|---|
| 30 | from MaKaC.i18n import _ |
|---|
| 31 | |
|---|
| 32 | class CSBooking(CSBookingBase): |
|---|
| 33 | |
|---|
| 34 | _hasStart = False |
|---|
| 35 | _hasStop = False |
|---|
| 36 | _hasCheckStatus = True |
|---|
| 37 | _hasAcceptReject = True |
|---|
| 38 | |
|---|
| 39 | _needsBookingParamsCheck = True |
|---|
| 40 | |
|---|
| 41 | _allowMultiple = False |
|---|
| 42 | |
|---|
| 43 | _hasStartDate = False |
|---|
| 44 | |
|---|
| 45 | _simpleParameters = { |
|---|
| 46 | "talks" : (str, ''), |
|---|
| 47 | "talkSelectionComments": (str, ''), |
|---|
| 48 | "talkSelection": (list, []), |
|---|
| 49 | "permission": (str, ''), |
|---|
| 50 | "lectureOptions": (str, ''), |
|---|
| 51 | "lectureStyle": (str, ''), |
|---|
| 52 | "postingUrgency": (str, ''), |
|---|
| 53 | "numRemoteViewers": (str, ''), |
|---|
| 54 | "numAttendees": (str, ''), |
|---|
| 55 | "recordingPurpose": (list, []), |
|---|
| 56 | "intendedAudience" : (list, []), |
|---|
| 57 | "subjectMatter": (list, []), |
|---|
| 58 | "otherComments": (str, '')} |
|---|
| 59 | |
|---|
| 60 | def __init__(self, type, conf): |
|---|
| 61 | CSBookingBase.__init__(self, type, conf) |
|---|
| 62 | |
|---|
| 63 | def _checkBookingParams(self): |
|---|
| 64 | if not self._bookingParams["permission"]: |
|---|
| 65 | raise RecordingRequestException("permission parameter cannot be left empty") |
|---|
| 66 | elif self._bookingParams["permission"] == 'No': |
|---|
| 67 | raise RecordingRequestException("""permission parameter cannot have the "no" value""") |
|---|
| 68 | |
|---|
| 69 | if self._bookingParams["lectureOptions"] == 'chooseOne': #change when list of community names is ok |
|---|
| 70 | raise RecordingRequestException("lectureOptions parameter cannot be 'chooseOne'") |
|---|
| 71 | |
|---|
| 72 | if self._bookingParams["lectureStyle"] == 'chooseOne': #change when list of community names is ok |
|---|
| 73 | raise RecordingRequestException("lectureStyle parameter cannot be 'chooseOne'") |
|---|
| 74 | |
|---|
| 75 | return False |
|---|
| 76 | |
|---|
| 77 | def _create(self): |
|---|
| 78 | self._statusMessage = "Request successfully sent" |
|---|
| 79 | self._statusClass = "statusMessageOther" |
|---|
| 80 | |
|---|
| 81 | if MailTools.needToSendEmails('RecordingRequest'): |
|---|
| 82 | try: |
|---|
| 83 | notification = NewRequestNotification(self) |
|---|
| 84 | GenericMailer.sendAndLog(notification, self.getConference(), |
|---|
| 85 | "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py", |
|---|
| 86 | self.getConference().getCreator()) |
|---|
| 87 | except Exception,e: |
|---|
| 88 | Logger.get('RecReq').exception( |
|---|
| 89 | """Could not send NewRequestNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e))) |
|---|
| 90 | return RecordingRequestError('create', e) |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | def _modify(self, oldBookingParams): |
|---|
| 95 | self._statusMessage = "Request successfully sent" |
|---|
| 96 | self._statusClass = "statusMessageOther" |
|---|
| 97 | |
|---|
| 98 | if MailTools.needToSendEmails('RecordingRequest'): |
|---|
| 99 | try: |
|---|
| 100 | notification = RequestModifiedNotification(self) |
|---|
| 101 | GenericMailer.sendAndLog(notification, self.getConference(), |
|---|
| 102 | "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py", |
|---|
| 103 | self.getConference().getCreator()) |
|---|
| 104 | except Exception,e: |
|---|
| 105 | Logger.get('RecReq').exception( |
|---|
| 106 | """Could not send RequestModifiedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e))) |
|---|
| 107 | return RecordingRequestError('edit', e) |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | def _checkStatus(self): |
|---|
| 111 | pass |
|---|
| 112 | |
|---|
| 113 | def _accept(self): |
|---|
| 114 | self._statusMessage = "Request accepted" |
|---|
| 115 | self._statusClass = "statusMessageOK" |
|---|
| 116 | |
|---|
| 117 | try: |
|---|
| 118 | notification = RequestAcceptedNotification(self) |
|---|
| 119 | GenericMailer.sendAndLog(notification, self.getConference(), |
|---|
| 120 | "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py", |
|---|
| 121 | None) |
|---|
| 122 | except Exception,e: |
|---|
| 123 | Logger.get('RecReq').exception( |
|---|
| 124 | """Could not send RequestAcceptedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e))) |
|---|
| 125 | return RecordingRequestError('accept', e) |
|---|
| 126 | |
|---|
| 127 | if MailTools.needToSendEmails('RecordingRequest'): |
|---|
| 128 | try: |
|---|
| 129 | notificationAdmin = RequestAcceptedNotificationAdmin(self) |
|---|
| 130 | GenericMailer.sendAndLog(notificationAdmin, self.getConference(), |
|---|
| 131 | "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py", |
|---|
| 132 | None) |
|---|
| 133 | except Exception,e: |
|---|
| 134 | Logger.get('RecReq').exception( |
|---|
| 135 | """Could not send RequestAcceptedNotificationAdmin for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e))) |
|---|
| 136 | return RecordingRequestError('accept', e) |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | def _reject(self): |
|---|
| 141 | self._statusMessage = "Request rejected by responsible" |
|---|
| 142 | self._statusClass = "statusMessageError" |
|---|
| 143 | |
|---|
| 144 | try: |
|---|
| 145 | notification = RequestRejectedNotification(self) |
|---|
| 146 | GenericMailer.sendAndLog(notification, self.getConference(), |
|---|
| 147 | "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py", |
|---|
| 148 | None) |
|---|
| 149 | except Exception,e: |
|---|
| 150 | Logger.get('RecReq').exception( |
|---|
| 151 | """Could not send RequestRejectedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e))) |
|---|
| 152 | return RecordingRequestError('reject', e) |
|---|
| 153 | |
|---|
| 154 | if MailTools.needToSendEmails('RecordingRequest'): |
|---|
| 155 | try: |
|---|
| 156 | notificationAdmin = RequestRejectedNotificationAdmin(self) |
|---|
| 157 | GenericMailer.sendAndLog(notificationAdmin, self.getConference(), |
|---|
| 158 | "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py", |
|---|
| 159 | None) |
|---|
| 160 | except Exception,e: |
|---|
| 161 | Logger.get('RecReq').exception( |
|---|
| 162 | """Could not send RequestRejectedNotificationAdmin for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e))) |
|---|
| 163 | return RecordingRequestError('reject', e) |
|---|
| 164 | |
|---|
| 165 | def _delete(self): |
|---|
| 166 | if MailTools.needToSendEmails('RecordingRequest'): |
|---|
| 167 | try: |
|---|
| 168 | notification = RequestDeletedNotification(self) |
|---|
| 169 | GenericMailer.sendAndLog(notification, self.getConference(), |
|---|
| 170 | "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py", |
|---|
| 171 | self.getConference().getCreator()) |
|---|
| 172 | except Exception,e: |
|---|
| 173 | Logger.get('RecReq').exception( |
|---|
| 174 | """Could not send RequestDeletedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e))) |
|---|
| 175 | return RecordingRequestError('remove', e) |
|---|