From 0e03fc85ee2528d67957c6fa298f232ee2391410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 2 Jun 2017 17:25:04 +0100 Subject: [PATCH 01/10] The BdA receives the reminder emails --- bda/__init__.py | 10 ++++++++++ bda/models.py | 10 +++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/bda/__init__.py b/bda/__init__.py index e69de29b..a5eecc65 100644 --- a/bda/__init__.py +++ b/bda/__init__.py @@ -0,0 +1,10 @@ +from django.contrib.auth.models import User + + +def get_generic_user(): + generic, created = User.objects.get_or_create(username="bda_generic") + if created: + generic.email = "bda@ens.fr" + generic.first_name = "Bureau des Arts" + generic.save() + return generic diff --git a/bda/models.py b/bda/models.py index 0228b4c0..42090374 100644 --- a/bda/models.py +++ b/bda/models.py @@ -11,6 +11,8 @@ from django.contrib.auth.models import User from django.conf import settings from django.utils import timezone, formats +from . import get_generic_user + class Tirage(models.Model): title = models.CharField("Titre", max_length=300) @@ -104,11 +106,9 @@ class Spectacle(models.Model): members[member.id][1] = 2 else: members[member.id] = [member, 1] - # FIXME : faire quelque chose de ça, un utilisateur bda_generic ? - # # Pour le BdA - # members[0] = ['BdA', 1, 'bda@ens.fr'] - # members[-1] = ['BdA', 2, 'bda@ens.fr'] # On écrit un mail personnalisé à chaque participant + bda_generic = get_generic_user() + members[-1] = [bda_generic, 1] datatuple = [( 'bda-rappel', {'member': member[0], 'nb_attr': member[1], 'show': self}, @@ -121,7 +121,7 @@ class Spectacle(models.Model): self.rappel_sent = timezone.now() self.save() # On renvoie la liste des destinataires - return members.values() + return map(lambda t: t[0], members.values()) @property def is_past(self): From 2a3614540fc143e7e62f091991c4bd9106692724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 2 Jun 2017 17:32:23 +0100 Subject: [PATCH 02/10] minor PEP8 changes --- bda/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bda/views.py b/bda/views.py index 00a1b300..406ca81c 100644 --- a/bda/views.py +++ b/bda/views.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from collections import defaultdict -from functools import partial import random import hashlib import time @@ -27,7 +26,7 @@ from django.views.generic.list import ListView from gestioncof.decorators import cof_required, buro_required from bda.models import ( Spectacle, Participant, ChoixSpectacle, Attribution, Tirage, - SpectacleRevente, Salle, Quote, CategorieSpectacle + SpectacleRevente, Salle, CategorieSpectacle ) from bda.algorithm import Algorithm from bda.forms import ( @@ -305,7 +304,8 @@ def do_tirage(tirage_elt, token): # On inscrit à BdA-Revente ceux qui n'ont pas eu les places voulues ChoixRevente = Participant.choicesrevente.through - # Suppression des reventes demandées/enregistrées (si le tirage est relancé) + # Suppression des reventes demandées/enregistrées + # (si le tirage est relancé) ( ChoixRevente.objects .filter(spectacle__tirage=tirage_elt) From 31c034a96ae2cf4072d6607df45038ce98657d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 2 Jun 2017 18:01:27 +0100 Subject: [PATCH 03/10] send_rappel: use django messages + css tweaks --- bda/templates/bda/mails-rappel.html | 47 +++++++++++++---------------- bda/views.py | 8 +++++ gestioncof/static/css/cof.css | 7 +++-- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/bda/templates/bda/mails-rappel.html b/bda/templates/bda/mails-rappel.html index 73625d1c..21fcc407 100644 --- a/bda/templates/bda/mails-rappel.html +++ b/bda/templates/bda/mails-rappel.html @@ -3,41 +3,36 @@ {% block realcontent %}

Mails de rappels

{% if sent %} -

Les mails de rappel pour le spectacle {{ show.title }} ont bien été envoyés aux personnes suivantes

-
    - {% for member in members %} -
  • {{ member.get_full_name }} ({{ member.email }})
  • - {% endfor %} -
+

Les mails de rappel pour le spectacle {{ show.title }} ont bien été envoyés aux personnes suivantes

+
    + {% for member in members %} +
  • {{ member.get_full_name }} ({{ member.email }})
  • + {% endfor %} +
{% else %} -

Voulez vous envoyer les mails de rappel pour le spectacle - {{ show.title }} ?

- {% if show.rappel_sent %} -

Attention, les mails ont déjà été envoyés le - {{ show.rappel_sent }}

- {% endif %} +

Voulez vous envoyer les mails de rappel pour le spectacle {{ show.title }} ?

{% endif %} - {% if not sent %} -
- {% csrf_token %} -
- -
-
- {% endif %} +
+ {% if not sent %} +
+ {% csrf_token %} +
+ +
+
+ {% endif %} +
-
-

Forme des mails

Une seule place

- {% for part in exemple_mail_1place %} -
{{ part }}
- {% endfor %} + {% for part in exemple_mail_1place %} +
{{ part }}
+ {% endfor %}

Deux places

{% for part in exemple_mail_2places %} -
{{ part }}
+
{{ part }}
{% endfor %} {% endblock %} diff --git a/bda/views.py b/bda/views.py index 406ca81c..602e5025 100644 --- a/bda/views.py +++ b/bda/views.py @@ -673,6 +673,14 @@ def send_rappel(request, spectacle_id): # Demande de confirmation else: ctxt['sent'] = False + if show.rappel_sent: + messages.warning( + request, + "Attention, un mail de rappel pour ce spectale a déjà été " + "envoyé le {}".format(formats.localize( + timezone.template_localtime(show.rappel_sent) + )) + ) return render(request, "bda/mails-rappel.html", ctxt) diff --git a/gestioncof/static/css/cof.css b/gestioncof/static/css/cof.css index e1cdd763..91cf726a 100644 --- a/gestioncof/static/css/cof.css +++ b/gestioncof/static/css/cof.css @@ -40,8 +40,9 @@ a { background: transparent; } - - +div.empty-form { + padding-bottom: 2em; +} a:hover { color: #444; @@ -341,10 +342,12 @@ fieldset legend { font-weight: 700; font-size: large; color:#DE826B; + padding-bottom: .5em; } #main-content h4 { color:#DE826B; + padding-bottom: .5em; } #main-content h2, From fbdfdeef46f725e49ee73f88643ad5fe70a57c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 2 Jun 2017 18:30:02 +0100 Subject: [PATCH 04/10] Add a link to the reminder emails sending page --- bda/templates/bda-participants.html | 27 ++++++++++++++++++--------- bda/urls.py | 5 ++++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/bda/templates/bda-participants.html b/bda/templates/bda-participants.html index 289d1761..85af4a2e 100644 --- a/bda/templates/bda-participants.html +++ b/bda/templates/bda-participants.html @@ -36,17 +36,26 @@

Ajouter une attribution

-
- - -
- - + + +
+ Page d'envoi manuel des mails de rappel +
+