[FIX] Method naming
[cds-indico.git] / indico / MaKaC / plugins / Collaboration / RecordingRequest / collaboration.py
blobf47b60e2c0d38b4f51373bb55e45fde5b6a85f60
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.
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.
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.
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 RequestRescheduledNotification, RequestRelocatedNotification
26 from MaKaC.plugins.Collaboration.collaborationTools import CollaborationTools
27 from MaKaC.common.mail import GenericMailer
28 from MaKaC.plugins.Collaboration.RecordingRequest.common import RecordingRequestException,\
29 RecordingRequestError
30 from MaKaC.common.logger import Logger
31 from MaKaC.plugins.Collaboration.collaborationTools import MailTools
32 from MaKaC.i18n import _
33 from indico.core.index import Catalog
36 class CSBooking(CSBookingBase):
38 _hasStart = False
39 _hasStop = False
40 _hasCheckStatus = True
41 _hasAcceptReject = True
43 _needsBookingParamsCheck = True
45 _allowMultiple = False
47 _hasStartDate = False
49 _commonIndexes = ["All Requests"]
51 _simpleParameters = {
52 "talks" : (str, ''),
53 "talkSelection": (list, []),
54 "lectureStyle": (str, ''),
55 "postingUrgency": (str, ''),
56 "numRemoteViewers": (str, ''),
57 "numAttendees": (str, ''),
58 "otherComments": (str, '')}
60 def __init__(self, type, conf):
61 CSBookingBase.__init__(self, type, conf)
63 def getStatusMessage(self):
64 return self._statusMessage
66 def hasHappened(self):
67 return False
69 def isHappeningNow(self):
70 return False
72 def _checkBookingParams(self):
74 if self._bookingParams["lectureStyle"] == 'chooseOne': #change when list of community names is ok
75 raise RecordingRequestException("lectureStyle parameter cannot be 'chooseOne'")
77 return False
79 def _create(self):
80 self._statusMessage = "Request successfully sent"
81 self._statusClass = "statusMessageOther"
83 if MailTools.needToSendEmails('RecordingRequest'):
84 try:
85 notification = NewRequestNotification(self)
86 GenericMailer.sendAndLog(notification, self.getConference(),
87 "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py",
88 self.getConference().getCreator())
89 except Exception,e:
90 Logger.get('RecReq').exception(
91 """Could not send NewRequestNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
92 return RecordingRequestError('create', e)
96 def _modify(self, oldBookingParams):
97 self._statusMessage = "Request successfully sent"
98 self._statusClass = "statusMessageOther"
100 if MailTools.needToSendEmails('RecordingRequest'):
101 try:
102 notification = RequestModifiedNotification(self)
103 GenericMailer.sendAndLog(notification, self.getConference(),
104 "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py",
105 self.getConference().getCreator())
106 except Exception,e:
107 Logger.get('RecReq').exception(
108 """Could not send RequestModifiedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
109 return RecordingRequestError('edit', e)
112 def _checkStatus(self):
113 pass
115 def _accept(self, user = None):
116 self._statusMessage = "Request accepted"
117 self._statusClass = "statusMessageOK"
119 try:
120 notification = RequestAcceptedNotification(self)
121 GenericMailer.sendAndLog(notification, self.getConference(),
122 "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py",
123 None)
124 except Exception,e:
125 Logger.get('RecReq').exception(
126 """Could not send RequestAcceptedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
127 return RecordingRequestError('accept', e)
129 if MailTools.needToSendEmails('RecordingRequest'):
130 try:
131 notificationAdmin = RequestAcceptedNotificationAdmin(self, user)
132 GenericMailer.sendAndLog(notificationAdmin, self.getConference(),
133 "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py",
134 None)
135 except Exception,e:
136 Logger.get('RecReq').exception(
137 """Could not send RequestAcceptedNotificationAdmin for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
138 return RecordingRequestError('accept', e)
140 manager = self._conf.getCSBookingManager()
141 manager.notifyInfoChange()
143 def _reject(self):
144 self._statusMessage = "Request rejected by responsible"
145 self._statusClass = "statusMessageError"
147 try:
148 notification = RequestRejectedNotification(self)
149 GenericMailer.sendAndLog(notification, self.getConference(),
150 "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py",
151 None)
152 except Exception,e:
153 Logger.get('RecReq').exception(
154 """Could not send RequestRejectedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
155 return RecordingRequestError('reject', e)
157 if MailTools.needToSendEmails('RecordingRequest'):
158 try:
159 notificationAdmin = RequestRejectedNotificationAdmin(self)
160 GenericMailer.sendAndLog(notificationAdmin, self.getConference(),
161 "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py",
162 None)
163 except Exception,e:
164 Logger.get('RecReq').exception(
165 """Could not send RequestRejectedNotificationAdmin for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
166 return RecordingRequestError('reject', e)
168 def _delete(self):
169 if MailTools.needToSendEmails('RecordingRequest'):
170 try:
171 notification = RequestDeletedNotification(self)
172 GenericMailer.sendAndLog(notification, self.getConference(),
173 "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py",
174 self.getConference().getCreator())
175 except Exception,e:
176 Logger.get('RecReq').exception(
177 """Could not send RequestDeletedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
178 return RecordingRequestError('remove', e)
180 def notifyEventDateChanges(self, oldStartDate, newStartDate, oldEndDate, newEndDate):
181 manager = self._conf.getCSBookingManager()
182 manager._changeConfStartDateInIndex(self, oldStartDate, newStartDate)
183 if MailTools.needToSendEmails('RecordingRequest'):
184 try:
185 notification = RequestRescheduledNotification(self)
186 GenericMailer.sendAndLog(notification, self.getConference(),
187 "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py",
188 self.getConference().getCreator())
189 except Exception,e:
190 Logger.get('RecReq').exception(
191 """Could not send RequestRescheduledNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
192 return RecordingRequestError('edit', e)
194 def notifyLocationChange(self):
195 self.unindex_instances()
196 self.index_instances()
197 if MailTools.needToSendEmails('RecordingRequest'):
198 try:
199 notification = RequestRelocatedNotification(self)
200 GenericMailer.sendAndLog(notification, self.getConference(),
201 "MaKaC/plugins/Collaboration/RecordingRequest/collaboration.py",
202 self.getConference().getCreator())
203 except Exception,e:
204 Logger.get('RecReq').exception(
205 """Could not send RequestRelocatedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
206 return RecordingRequestError('edit', e)
208 def index_instances(self):
209 idx = Catalog.getIdx('cs_booking_instance')
210 idx['RecordingRequest'].index_booking(self)
211 idx['All Requests'].index_booking(self)
213 def unindex_instances(self):
214 idx = Catalog.getIdx('cs_booking_instance')
215 idx['RecordingRequest'].unindex_booking(self)
216 idx['All Requests'].unindex_booking(self)
218 def index_talk(self, talk):
219 if CollaborationTools.isAbleToBeWebcastOrRecorded(talk, "RecordingRequest") and self.isChooseTalkSelected() \
220 and talk.getId() in self.getTalkSelectionList():
221 idx = Catalog.getIdx('cs_booking_instance')
222 idx['RecordingRequest'].index_talk(self, talk)
223 idx['All Requests'].index_talk(self, talk)
225 def unindex_talk(self, talk):
226 idx = Catalog.getIdx('cs_booking_instance')
227 idx['RecordingRequest'].unindex_talk(self, talk)
228 idx['All Requests'].unindex_talk(self, talk)