diff --git a/bda/models.py b/bda/models.py index 91af3e99..d1d3ba7e 100644 --- a/bda/models.py +++ b/bda/models.py @@ -207,10 +207,26 @@ class SpectacleRevente(models.Model): return timezone.now() > self.expiration_time shotgun = property(get_shotgun) - def get_cancellable(self): - return timezone.now() < self.date + datetime.timedelta(hours=1) - cancellable = property(get_cancellable) - def __str__(self): return "%s -- %s" % (self.attribution.participant.user, 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) diff --git a/bda/templates/mail-revente.txt b/bda/templates/mail-revente.txt new file mode 100644 index 00000000..16655696 --- /dev/null +++ b/bda/templates/mail-revente.txt @@ -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 diff --git a/cof/settings_dev.py b/cof/settings_dev.py index 502cb0ee..0666ee9f 100644 --- a/cof/settings_dev.py +++ b/cof/settings_dev.py @@ -142,6 +142,9 @@ PETITS_COURS_REPLYTO = "cof@ens.fr" RAPPEL_FROM = 'Le BdA ' RAPPEL_REPLY_TO = RAPPEL_FROM +REVENTE_FROM = 'BDA-Revente ' +REVENTE_REPLY_TO = REVENTE_FROM + LOGIN_URL = "/login" LOGIN_REDIRECT_URL = "/"