diff --git a/bda/management/commands/manage_reventes.py b/bda/management/commands/manage_reventes.py index f45357b1..45b9c91a 100644 --- a/bda/management/commands/manage_reventes.py +++ b/bda/management/commands/manage_reventes.py @@ -14,7 +14,6 @@ class Command(BaseCommand): def handle(self, *args, **options): now = timezone.now() - self.stdout.write(now) reventes = SpectacleRevente.objects.all() for revente in reventes: # Check si < 24h @@ -22,15 +21,18 @@ class Command(BaseCommand): revente.date + timedelta(days=1)) and \ now >= revente.date + timedelta(minutes=15) and \ not revente.notif_sent: + self.stdout.write(str(now)) revente.mail_shotgun() self.stdout.write("Mail de disponibilité immédiate envoyé") # Check si délai de retrait dépassé elif (now >= revente.date + timedelta(hours=1) and not revente.notif_sent): + self.stdout.write(str(now)) revente.send_notif() self.stdout.write("Mail d'inscription à une revente envoyé") # Check si tirage à faire elif (now >= revente.expiration_time and not revente.tirage_done): + self.stdout.write(str(now)) revente.tirage() self.stdout.write("Tirage effectué, mails envoyés") diff --git a/bda/models.py b/bda/models.py index cc96e525..0debec36 100644 --- a/bda/models.py +++ b/bda/models.py @@ -8,6 +8,7 @@ import calendar import random from datetime import timedelta +from django.contrib.sites.models import Site from django.db import models from django.contrib.auth.models import User from django.template import loader, Context @@ -105,21 +106,24 @@ class Spectacle(models.Model): for attr in Attribution.objects.filter(spectacle=self).all(): member = attr.participant.user if member.id in members: - members[member.id].nb_attr = 2 + members[member.id][1] = 2 else: - member.nb_attr = 1 - members[member.id] = member + members[member.id] = [member.first_name, 1, member.email] + # Pour le BdA + members[0] = ['BdA', 1, 'bda@ens.fr'] + members[-1] = ['BdA', 2, 'bda@ens.fr'] # On écrit un mail personnalisé à chaque participant mails_to_send = [] mail_object = "%s - %s - %s" % (self.title, self.date_no_seconds(), self.location) for member in members.values(): mail_body = render_template('mail-rappel.txt', { - 'member': member, + 'name': member[0], + 'nb_attr': member[1], 'show': self}) mail_tot = mail.EmailMessage( mail_object, mail_body, - settings.MAIL_DATA['rappels']['FROM'], [member.email], + settings.MAIL_DATA['rappels']['FROM'], [member[2]], [], headers={ 'Reply-To': settings.MAIL_DATA['rappels']['REPLYTO']}) mails_to_send.append(mail_tot) @@ -245,6 +249,11 @@ class SpectacleRevente(models.Model): # On a aussi 1h pour changer d'avis return self.date + delay + timedelta(hours=1) + def expiration_time_str(self): + return self.expiration_time \ + .astimezone(timezone.get_current_timezone()) \ + .strftime('%D à %H:%M') + @property def shotgun(self): # Soit on a dépassé le délai du tirage, soit il reste peu de @@ -270,8 +279,9 @@ class SpectacleRevente(models.Model): for participant in inscrits: mail_body = render_template('mail-revente.txt', { 'user': participant.user, - 'spectacle': self.spectacle, - 'revente': self}) + 'spectacle': self.attribution.spectacle, + 'revente': self, + 'domain': Site.objects.get_current().domain}) mail_tot = mail.EmailMessage( mail_object, mail_body, settings.MAIL_DATA['revente']['FROM'], @@ -293,7 +303,8 @@ class SpectacleRevente(models.Model): for participant in inscrits: mail_body = render_template('mail-shotgun.txt', { 'user': participant.user, - 'spectacle': self.spectacle, + 'spectacle': self.attribution.spectacle, + 'domain': Site.objects.get_current(), 'mail': self.attribution.participant.user.email}) mail_tot = mail.EmailMessage( mail_object, mail_body, @@ -318,7 +329,7 @@ class SpectacleRevente(models.Model): mail_buyer = """Bonjour, Tu as été tiré-e au sort pour racheter une place pour %s le %s (%s) à %0.02f€. -Tu peux contacter le vendeur à l'adresse %s. +Tu peux contacter le/la vendeur-se à l'adresse %s. Chaleureusement, Le BdA""" % (spectacle.title, spectacle.date_no_seconds(), diff --git a/bda/templates/mail-rappel.txt b/bda/templates/mail-rappel.txt index 5152b1db..4759a849 100644 --- a/bda/templates/mail-rappel.txt +++ b/bda/templates/mail-rappel.txt @@ -1,14 +1,14 @@ -Bonjour {{ member.get_full_name }}, +Bonjour {{ name }}, -Nous te rappellons que tu as eu la chance d'obtenir {{ member.nb_attr|pluralize:"une place,deux places" }} +Nous te rappellons que tu as eu la chance d'obtenir {{ nb_attr|pluralize:"une place,deux places" }} pour {{ show.title }}, le {{ show.date_no_seconds }} au {{ show.location }}. N'oublie pas de t'y rendre ! -{% if member.nb_attr == 2 %} +{% if nb_attr == 2 %} Tu as obtenu deux places pour ce spectacle. Nous te rappelons que ces places sont strictement réservées aux personnes de moins de 28 ans. {% endif %} {% if show.listing %}Pour ce spectacle, tu as reçu des places sur listing. Il te faudra donc te rendre 15 minutes en avance sur les lieux de la représentation -pour retirer {{ member.nb_attr|pluralize:"ta place,tes places" }}. +pour retirer {{ nb_attr|pluralize:"ta place,tes places" }}. {% else %}Pour assister à ce spectacle, tu dois présenter les billets qui ont été distribués au burô. {% endif %} diff --git a/bda/templates/mail-revente.txt b/bda/templates/mail-revente.txt index adc61eb9..899afe3b 100644 --- a/bda/templates/mail-revente.txt +++ b/bda/templates/mail-revente.txt @@ -1,8 +1,12 @@ -Bonjour {{ user.get_full_name }} +Bonjour {{ user.first_name }} -Une place pour le spectacle {{ spectacle.title }} ({{spectacle.date_no_seconds}}) a été postée sur BdA-Revente. +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-interested-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}} +Si ce spectacle t'intéresse toujours, merci de nous le signaler en cliquant +sur ce lien : http://{{ domain }}{% url "bda-revente-interested" revente.id %}. +Dans le cas où plusieurs personnes seraient intéressées, nous procèderons à +un tirage au sort le {{ revente.expiration_time_str }}. Chaleureusement, Le BdA diff --git a/bda/templates/mail-shotgun.txt b/bda/templates/mail-shotgun.txt index 8c4e7bd9..899d5c85 100644 --- a/bda/templates/mail-shotgun.txt +++ b/bda/templates/mail-shotgun.txt @@ -1,8 +1,11 @@ -Bonjour {{ user.get_full_name }} +Bonjour {{ user.first_name }} -Une place pour le spectacle {{ spectacle.title }} ({{spectacle.date_no_seconds}}) a été postée sur BdA-Revente. +Une place pour le spectacle {{ spectacle.title }} ({{ spectacle.date_no_seconds }}) +a été postée sur BdA-Revente. -Puisque ce spectacle a lieu dans moins de 24h, il n'y a pas de tirage au sort pour cette place : elle est disponible immédiatement à l'addresse {{url "bda-buy-revente" spectacle.id}}, à la disposition de tous. +Puisque ce spectacle a lieu dans moins de 24h, il n'y a pas de tirage au sort pour +cette place : elle est disponible immédiatement à l'addresse +http://{{ domain }}{% url "bda-buy-revente" spectacle.id %}, à la disposition de tous. Chaleureusement, Le BdA