[FIX] Method naming
[cds-indico.git] / indico / MaKaC / plugins / Collaboration / WebcastRequest / collaboration.py
blobf1830e70fd41e8f6ba55a13b76e8374458f41a47
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.WebcastRequest.mail import NewRequestNotification, RequestModifiedNotification, RequestDeletedNotification,\
23 RequestRejectedNotification, RequestAcceptedNotification,\
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.WebcastRequest.common import WebcastRequestException,\
29 WebcastRequestError
30 from MaKaC.common.logger import Logger
31 from MaKaC.plugins.Collaboration.collaborationTools import MailTools
32 from MaKaC.i18n import _
34 from indico.core.index import Catalog
37 class CSBooking(CSBookingBase):
39 _hasStart = False
40 _hasStop = False
41 _hasCheckStatus = True
42 _hasAcceptReject = True
44 _needsBookingParamsCheck = True
46 _allowMultiple = False
48 _hasStartDate = False
50 _commonIndexes = ["All Requests"]
52 _simpleParameters = {
53 "talks" : (str, ''),
54 "talkSelection": (list, []),
55 "otherComments": (str, ''),
56 "audience": (str, '')}
58 def __init__(self, type, conf):
59 CSBookingBase.__init__(self, type, conf)
61 def _checkBookingParams(self):
62 return False
64 def getStatusMessage(self):
65 return self._statusMessage
67 def hasHappened(self):
68 return False
70 def isHappeningNow(self):
71 return False
73 def _create(self):
74 self._statusMessage = "Request successfully sent"
75 self._statusClass = "statusMessageOther"
77 if MailTools.needToSendEmails('WebcastRequest'):
78 try:
79 notification = NewRequestNotification(self)
80 GenericMailer.sendAndLog(notification, self.getConference(),
81 "MaKaC/plugins/Collaboration/WebcastRequest/collaboration.py",
82 self.getConference().getCreator())
83 except Exception,e:
84 Logger.get('RecReq').exception(
85 """Could not send NewRequestNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
86 return WebcastRequestError('create', e)
89 def _modify(self, oldBookingParams):
90 self._statusMessage = "Request successfully sent"
91 self._statusClass = "statusMessageOther"
93 if MailTools.needToSendEmails('WebcastRequest'):
94 try:
95 notification = RequestModifiedNotification(self)
96 GenericMailer.sendAndLog(notification, self.getConference(),
97 "MaKaC/plugins/Collaboration/WebcastRequest/collaboration.py",
98 self.getConference().getCreator())
99 except Exception,e:
100 Logger.get('RecReq').exception(
101 """Could not send RequestModifiedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
102 return WebcastRequestError('edit', e)
105 def _checkStatus(self):
106 pass
108 def _accept(self, user = None):
109 self._statusMessage = "Request accepted"
110 self._statusClass = "statusMessageOK"
111 import MaKaC.webcast as webcast
112 webcast.HelperWebcastManager.getWebcastManagerInstance().addForthcomingWebcast(self._conf, self._bookingParams.get("audience", ""))
114 try:
115 notification = RequestAcceptedNotification(self)
116 GenericMailer.sendAndLog(notification, self.getConference(),
117 "MaKaC/plugins/Collaboration/WebcastRequest/collaboration.py",
118 None)
119 except Exception,e:
120 Logger.get('RecReq').exception(
121 """Could not send RequestAcceptedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
122 return WebcastRequestError('accept', e)
124 if MailTools.needToSendEmails('WebcastRequest'):
125 try:
126 notification = RequestAcceptedNotificationAdmin(self, user)
127 GenericMailer.sendAndLog(notification, self.getConference(),
128 "MaKaC/plugins/Collaboration/WebcastRequest/collaboration.py",
129 None)
130 except Exception,e:
131 Logger.get('RecReq').exception(
132 """Could not send RequestAcceptedNotificationAdmin for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
133 return WebcastRequestError('accept', e)
135 manager = self._conf.getCSBookingManager()
136 manager.notifyInfoChange()
138 def _reject(self):
139 self._statusMessage = "Request rejected by responsible"
140 self._statusClass = "statusMessageError"
141 import MaKaC.webcast as webcast
142 webcast.HelperWebcastManager.getWebcastManagerInstance().delForthcomingWebcast(self._conf)
144 try:
145 notification = RequestRejectedNotification(self)
146 GenericMailer.sendAndLog(notification, self.getConference(),
147 "MaKaC/plugins/Collaboration/WebcastRequest/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 WebcastRequestError('reject', e)
154 if MailTools.needToSendEmails('WebcastRequest'):
155 try:
156 notification = RequestRejectedNotificationAdmin(self)
157 GenericMailer.sendAndLog(notification, self.getConference(),
158 "MaKaC/plugins/Collaboration/WebcastRequest/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 WebcastRequestError('reject', e)
165 def _delete(self):
166 import MaKaC.webcast as webcast
167 webcast.HelperWebcastManager.getWebcastManagerInstance().delForthcomingWebcast(self._conf)
169 if MailTools.needToSendEmails('WebcastRequest'):
170 try:
171 notification = RequestDeletedNotification(self)
172 GenericMailer.sendAndLog(notification, self.getConference(),
173 "MaKaC/plugins/Collaboration/WebcastRequest/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 WebcastRequestError('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('WebcastRequest'):
184 try:
185 notification = RequestRescheduledNotification(self)
186 GenericMailer.sendAndLog(notification, self.getConference(),
187 "MaKaC/plugins/Collaboration/WebcastRequest/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 WebcastRequestError('edit', e)
194 def notifyLocationChange(self):
195 self.unindex_instances()
196 self.index_instances()
197 if MailTools.needToSendEmails('WebcastRequest'):
198 try:
199 notification = RequestRelocatedNotification(self)
200 GenericMailer.sendAndLog(notification, self.getConference(),
201 "MaKaC/plugins/Collaboration/WebcastRequest/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 WebcastRequestError('edit', e)
208 def index_instances(self):
209 idx = Catalog.getIdx('cs_booking_instance')
210 idx['WebcastRequest'].index_booking(self)
211 idx['All Requests'].index_booking(self)
213 def unindex_instances(self):
214 idx = Catalog.getIdx('cs_booking_instance')
215 idx['WebcastRequest'].unindex_booking(self)
216 idx['All Requests'].unindex_booking(self)
218 def index_talk(self, talk):
219 if CollaborationTools.isAbleToBeWebcastOrRecorded(talk, "WebcastRequest") and self.isChooseTalkSelected() \
220 and talk.getId() in self.getTalkSelectionList():
221 idx = Catalog.getIdx('cs_booking_instance')
222 idx['WebcastRequest'].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['WebcastRequest'].unindex_talk(self, talk)
228 idx['All Requests'].unindex_talk(self, talk)