forked from DGNum/gestioCOF
send mail
This commit is contained in:
parent
af524a3081
commit
5b18eace20
3 changed files with 31 additions and 4 deletions
|
@ -207,10 +207,26 @@ class SpectacleRevente(models.Model):
|
||||||
return timezone.now() > self.expiration_time
|
return timezone.now() > self.expiration_time
|
||||||
shotgun = property(get_shotgun)
|
shotgun = property(get_shotgun)
|
||||||
|
|
||||||
def get_cancellable(self):
|
|
||||||
return timezone.now() < self.date + datetime.timedelta(hours=1)
|
|
||||||
cancellable = property(get_cancellable)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s -- %s" % (self.attribution.participant.user,
|
return "%s -- %s" % (self.attribution.participant.user,
|
||||||
self.attribution.spectacle.title)
|
self.attribution.spectacle.title)
|
||||||
|
|
||||||
|
def send_notif(self):
|
||||||
|
# On récupère la liste des inscrits
|
||||||
|
inscrits = self.attribution.spectacle.revente.select_related('user')
|
||||||
|
|
||||||
|
mails_to_send = []
|
||||||
|
mail_object = "%s" % (self.attribution.spectacle)
|
||||||
|
for participant in inscrits:
|
||||||
|
mail_body = render_template('mail-revente.txt', {
|
||||||
|
'user': participant.user,
|
||||||
|
'spectacle': self.spectacle,
|
||||||
|
'revente': self})
|
||||||
|
mail_tot = mail.EmailMessage(
|
||||||
|
mail_object, mail_body,
|
||||||
|
settings.REVENTE_FROM, [participant.email],
|
||||||
|
[], headers={'Reply-To': settings.REVENTE_REPLY_TO})
|
||||||
|
mails_to_send.append(mail_tot)
|
||||||
|
|
||||||
|
connection = mail.get_connection()
|
||||||
|
connection.send_messages(mails_to_send)
|
||||||
|
|
8
bda/templates/mail-revente.txt
Normal file
8
bda/templates/mail-revente.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Bonjour {{ user.get_full_name }}
|
||||||
|
|
||||||
|
Une place pour le spectacle {{ spectacle.title }} ({{spectacle.date_no_seconds}}) a été postée sur BDA-Revente.
|
||||||
|
|
||||||
|
Si ce spectacle t'intéresse toujours, merci de nous le signaler en cliquant sur ce lien : {% url "bda-inscr-revente" revente.id %}. Dans le cas où plusieurs personnes seraient intéressées, nous procèderons à un tirage au sort le {{revente.date_no_seconds}}
|
||||||
|
|
||||||
|
Chaleureusement,
|
||||||
|
Le BDA
|
|
@ -142,6 +142,9 @@ PETITS_COURS_REPLYTO = "cof@ens.fr"
|
||||||
RAPPEL_FROM = 'Le BdA <bda@ens.fr>'
|
RAPPEL_FROM = 'Le BdA <bda@ens.fr>'
|
||||||
RAPPEL_REPLY_TO = RAPPEL_FROM
|
RAPPEL_REPLY_TO = RAPPEL_FROM
|
||||||
|
|
||||||
|
REVENTE_FROM = 'BDA-Revente <bda-revente@ens.fr>'
|
||||||
|
REVENTE_REPLY_TO = REVENTE_FROM
|
||||||
|
|
||||||
LOGIN_URL = "/login"
|
LOGIN_URL = "/login"
|
||||||
LOGIN_REDIRECT_URL = "/"
|
LOGIN_REDIRECT_URL = "/"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue