[IMP] Allow to send CC in Elec Agree Mail
[cds-indico.git] / indico / MaKaC / plugins / Collaboration / mail.py
blobd971c92c6b2c9ee19835a428cb493b4ea1d1a5b1
1 # -*- coding: utf-8 -*-
2 ##
3 ##
4 ## This file is par{t of Indico.
5 ## Copyright (C) 2002 - 2012 European Organization for Nuclear Research (CERN).
6 ##
7 ## 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 3 of the
10 ## License, or (at your option) any later version.
12 ## 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 Indico;if not, see <http://www.gnu.org/licenses/>.
20 from MaKaC.webinterface.mail import GenericNotification
21 from MaKaC.common.info import HelperMaKaCInfo
22 from MaKaC.plugins.Collaboration.collaborationTools import MailTools
23 from MaKaC.common.TemplateExec import beautify
24 from MaKaC.common.Configuration import Config
26 class CollaborationNotificationBase(GenericNotification):
27 """ Base class to build an email notification for the Recording request plugin.
28 """
29 def __init__(self, booking):
30 GenericNotification.__init__(self)
32 self._booking = booking
33 self._bp = booking._bookingParams
34 self._conference = booking.getConference()
36 self._modifLink = str(self._booking.getModificationURL())
38 self.setFromAddr("Indico Mailer <%s>"%Config.getInstance().getSupportEmail())
39 self.setToList(MailTools.getAdminEmailList())
40 self.setContentType("text/html")
42 def _getBookingDetails(self, typeOfMail):
43 return """
44 Booking / request details:<br />
45 <table style="border-spacing: 10px 10px;">
46 <tr>
47 <td style="vertical-align: top; white-space : nowrap;">
48 <strong>Type:</strong>
49 </td>
50 <td style="vertical-align: top;">
51 %(type)s
52 </td>
53 </tr>
54 <tr>
55 <td style="vertical-align: top; white-space : nowrap;">
56 <strong>id:</strong>
57 </td>
58 <td style="vertical-align: top;">
59 %(id)s
60 </td>
61 </tr>
62 <tr>
63 <td style="vertical-align: top; white-space : nowrap;">
64 <strong>Modification link:</strong>
65 </td>
66 <td style="vertical-align: top;">
67 <a href="%(modifURL)s">link</a>
68 </td>
69 </tr>
70 <tr>
71 <td style="vertical-align: top; white-space : nowrap;">
72 <strong>Creation date:</strong>
73 </td>
74 <td style="vertical-align: top;">
75 %(creationDate)s
76 </td>
77 </tr>
78 %(modificationDate)s
79 <tr>
80 <td style="vertical-align: top; white-space : nowrap;">
81 <strong>Booking parameters:</strong>
82 </td>
83 <td style="vertical-align: top;">
84 %(bookingParams)s
85 </td>
86 </tr>
87 </table>
88 """%{"type": self._booking.getType(),
89 "id" : self._booking.getId(),
90 "modifURL": self._modifLink,
91 "creationDate": MailTools.bookingCreationDate(self._booking),
92 "modificationDate": MailTools.bookingModificationDate(self._booking, typeOfMail),
93 "bookingParams": beautify(self._bp)
97 class NewBookingNotification(CollaborationNotificationBase):
98 """ Template to build an email notification to a Collaboration responsible
99 """
101 def __init__(self, booking):
102 CollaborationNotificationBase.__init__(self, booking)
104 self.setSubject("""[Video Services] New booking / request: %s (event id: %s)"""
105 % (self._conference.getTitle(), str(self._conference.getId())))
107 self.setBody(
109 A new booking / request was created in <a href="%s">%s</a>
110 <br /><br />
112 <br /><br />
114 <br /><br />
116 """ % ( MailTools.getServerName(),
117 MailTools.getServerName(),
118 self._getBookingDetails('new'),
119 MailTools.eventDetails(self._conference),
120 MailTools.organizerDetails(self._conference)
125 class BookingModifiedNotification(CollaborationNotificationBase):
126 """ Template to build an email notification to a Collaboration responsible
129 def __init__(self, booking):
130 CollaborationNotificationBase.__init__(self, booking)
132 self.setSubject("""[Video Services] Booking / request modified: %s (event id: %s)"""
133 % (self._conference.getTitle(), str(self._conference.getId())))
135 self.setBody(
137 A booking / request was modified in <a href="%s">%s</a>
138 <br /><br />
140 <br /><br />
142 <br /><br />
144 """ % ( MailTools.getServerName(),
145 MailTools.getServerName(),
146 self._getBookingDetails('modify'),
147 MailTools.eventDetails(self._conference),
148 MailTools.organizerDetails(self._conference)
153 class BookingDeletedNotification(CollaborationNotificationBase):
154 """ Template to build an email notification to a Collaboration responsible
157 def __init__(self, booking):
158 CollaborationNotificationBase.__init__(self, booking)
160 self.setSubject("""[Video Services] Booking / request deleted: %s (event id: %s)"""
161 % (self._conference.getTitle(), str(self._conference.getId())))
163 self.setBody(
165 A booking / request was deleted in <a href="%s">%s</a>
166 <br /><br />
168 <br /><br />
170 <br /><br />
172 """ % ( MailTools.getServerName(),
173 MailTools.getServerName(),
174 self._getBookingDetails('remove'),
175 MailTools.eventDetails(self._conference),
176 MailTools.organizerDetails(self._conference)
179 class SpeakersNotificationBase(GenericNotification):
180 """ Base class to build an email notification to Speakers
182 def __init__(self, sendToList, fromEmail, fromName ="Indico Mailer"):
183 GenericNotification.__init__(self)
185 self.setContentType("text/html")
186 self.setFromAddr("%s<%s>"%(fromName, fromEmail))
187 self.setToList(sendToList)
189 class ElectroniAgreementNotification(SpeakersNotificationBase):
190 """ Template to build an email notification to the speakers
191 to sign the electronic agreement.
194 def __init__(self, sendToList, sendToCCList, fromEmail, fromName, content, subject):
195 SpeakersNotificationBase.__init__(self, sendToList, fromEmail, fromName)
196 self.setCCList(sendToCCList)
197 self.setSubject(subject)
198 self.setBody(content)