source: indico/indico/MaKaC/plugins/Collaboration/WebcastRequest/collaboration.py @ d3cb3f

burotelhello-world-walkthroughipv6new-webexv0.97-seriesv0.98-seriesv0.98.2v0.98.3v0.98b1v0.98b2v0.99v1.0v1.1
Last change on this file since d3cb3f was d3cb3f, checked in by Jose Benito <jose.benito.gonzalez@…>, 3 years ago

[FIX] Status message was stored transalted

  • Property mode set to 100644
File size: 8.2 KB
Line 
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
21from MaKaC.plugins.Collaboration.base import CSBookingBase
22from MaKaC.plugins.Collaboration.WebcastRequest.mail import NewRequestNotification, RequestModifiedNotification, RequestDeletedNotification,\
23    RequestRejectedNotification, RequestAcceptedNotification,\
24    RequestAcceptedNotificationAdmin, RequestRejectedNotificationAdmin
25from MaKaC.common.mail import GenericMailer
26from MaKaC.plugins.Collaboration.WebcastRequest.common import WebcastRequestException,\
27    WebcastRequestError
28from MaKaC.common.logger import Logger
29from MaKaC.plugins.Collaboration.collaborationTools import MailTools
30from MaKaC.i18n import _
31
32class 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        "numWebcastViewers": (str, ''),
54        "numRecordingViewers": (str, ''),
55        "numAttendees": (str, ''),
56        "webcastPurpose": (list, []),
57        "intendedAudience" : (list, []),
58        "subjectMatter": (list, []),
59        "otherComments": (str, '')}
60
61    def __init__(self, type, conf):
62        CSBookingBase.__init__(self, type, conf)
63
64    def _checkBookingParams(self):
65        if not self._bookingParams["permission"]:
66            raise WebcastRequestException("permission parameter cannot be left empty")
67        if self._bookingParams["lectureOptions"] == 'chooseOne': #change when list of community names is ok
68            raise WebcastRequestException("lectureOptions parameter cannot be 'chooseOne'")
69        if self._bookingParams["lectureStyle"] == 'chooseOne': #change when list of community names is ok
70            raise WebcastRequestException("lectureStyle parameter cannot be 'chooseOne'")
71    #    if self._bookingParams["talks"] == 'choose':
72    #       raise WebcastRequestException("You cannot choose choose")
73        return False
74
75    def _create(self):
76        self._statusMessage = "Request successfully sent"
77        self._statusClass = "statusMessageOther"
78
79        if MailTools.needToSendEmails('WebcastRequest'):
80            try:
81                notification = NewRequestNotification(self)
82                GenericMailer.sendAndLog(notification, self.getConference(),
83                                     "MaKaC/plugins/Collaboration/WebcastRequest/collaboration.py",
84                                     self.getConference().getCreator())
85            except Exception,e:
86                Logger.get('RecReq').exception(
87                    """Could not send NewRequestNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
88                return WebcastRequestError('create', e)
89
90
91    def _modify(self, oldBookingParams):
92        self._statusMessage = "Request successfully sent"
93        self._statusClass = "statusMessageOther"
94
95        if MailTools.needToSendEmails('WebcastRequest'):
96            try:
97                notification = RequestModifiedNotification(self)
98                GenericMailer.sendAndLog(notification, self.getConference(),
99                                     "MaKaC/plugins/Collaboration/WebcastRequest/collaboration.py",
100                                     self.getConference().getCreator())
101            except Exception,e:
102                Logger.get('RecReq').exception(
103                    """Could not send RequestModifiedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
104                return WebcastRequestError('edit', e)
105
106
107    def _checkStatus(self):
108        pass
109
110    def _accept(self):
111        self._statusMessage = "Request accepted"
112        self._statusClass = "statusMessageOK"
113        import MaKaC.webcast as webcast
114        webcast.HelperWebcastManager.getWebcastManagerInstance().addForthcomingWebcast(self._conf)
115
116        try:
117            notification = RequestAcceptedNotification(self)
118            GenericMailer.sendAndLog(notification, self.getConference(),
119                                 "MaKaC/plugins/Collaboration/WebcastRequest/collaboration.py",
120                                 None)
121        except Exception,e:
122            Logger.get('RecReq').exception(
123                """Could not send RequestAcceptedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
124            return WebcastRequestError('accept', e)
125
126        if MailTools.needToSendEmails('WebcastRequest'):
127            try:
128                notification = RequestAcceptedNotificationAdmin(self)
129                GenericMailer.sendAndLog(notification, self.getConference(),
130                                     "MaKaC/plugins/Collaboration/WebcastRequest/collaboration.py",
131                                     None)
132            except Exception,e:
133                Logger.get('RecReq').exception(
134                    """Could not send RequestAcceptedNotificationAdmin for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
135                return WebcastRequestError('accept', e)
136
137    def _reject(self):
138        self._statusMessage = "Request rejected by responsible"
139        self._statusClass = "statusMessageError"
140
141        try:
142            notification = RequestRejectedNotification(self)
143            GenericMailer.sendAndLog(notification, self.getConference(),
144                                 "MaKaC/plugins/Collaboration/WebcastRequest/collaboration.py",
145                                 None)
146        except Exception,e:
147            Logger.get('RecReq').exception(
148                """Could not send RequestRejectedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
149            return WebcastRequestError('reject', e)
150
151        if MailTools.needToSendEmails('WebcastRequest'):
152            try:
153                notification = RequestRejectedNotificationAdmin(self)
154                GenericMailer.sendAndLog(notification, self.getConference(),
155                                     "MaKaC/plugins/Collaboration/WebcastRequest/collaboration.py",
156                                     None)
157            except Exception,e:
158                Logger.get('RecReq').exception(
159                    """Could not send RequestRejectedNotificationAdmin for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
160                return WebcastRequestError('reject', e)
161
162    def _delete(self):
163        if MailTools.needToSendEmails('WebcastRequest'):
164            try:
165                notification = RequestDeletedNotification(self)
166                GenericMailer.sendAndLog(notification, self.getConference(),
167                                     "MaKaC/plugins/Collaboration/WebcastRequest/collaboration.py",
168                                     self.getConference().getCreator())
169            except Exception,e:
170                Logger.get('RecReq').exception(
171                    """Could not send RequestDeletedNotification for request with id %s of event %s, exception: %s""" % (self._id, self.getConference().getId(), str(e)))
172                return WebcastRequestError('remove', e)
Note: See TracBrowser for help on using the repository browser.