1 # -*- coding: utf-8 -*-
4 ## This file is par{t of Indico.
5 ## Copyright (C) 2002 - 2012 European Organization for Nuclear Research (CERN).
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.
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
):
44 Booking / request details:<br />
45 <table style="border-spacing: 10px 10px;">
47 <td style="vertical-align: top; white-space : nowrap;">
48 <strong>Type:</strong>
50 <td style="vertical-align: top;">
55 <td style="vertical-align: top; white-space : nowrap;">
58 <td style="vertical-align: top;">
63 <td style="vertical-align: top; white-space : nowrap;">
64 <strong>Modification link:</strong>
66 <td style="vertical-align: top;">
67 <a href="%(modifURL)s">link</a>
71 <td style="vertical-align: top; white-space : nowrap;">
72 <strong>Creation date:</strong>
74 <td style="vertical-align: top;">
80 <td style="vertical-align: top; white-space : nowrap;">
81 <strong>Booking parameters:</strong>
83 <td style="vertical-align: top;">
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
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())))
109 A new booking / request was created in <a href="%s">%s</a>
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())))
137 A booking / request was modified in <a href="%s">%s</a>
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())))
165 A booking / request was deleted in <a href="%s">%s</a>
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
)