forked from DGNum/gestioCOF
GestioCOF mémorise la date d'envoi des rappels
Cela permet de demander une confirmation avant l'envoi dans la vue correspondante quand les rappels ont déjà été envoyés.
This commit is contained in:
parent
f6d3106110
commit
3bea20a52e
5 changed files with 45 additions and 9 deletions
|
@ -183,6 +183,7 @@ class SpectacleAdmin(admin.ModelAdmin):
|
||||||
"listing")
|
"listing")
|
||||||
list_filter = ("location", "tirage",)
|
list_filter = ("location", "tirage",)
|
||||||
search_fields = ("title", "location__name")
|
search_fields = ("title", "location__name")
|
||||||
|
readonly_fields = ("rappel_sent", )
|
||||||
|
|
||||||
|
|
||||||
class TirageAdmin(admin.ModelAdmin):
|
class TirageAdmin(admin.ModelAdmin):
|
||||||
|
|
|
@ -17,4 +17,9 @@ class Migration(migrations.Migration):
|
||||||
field=models.BooleanField(default=False, verbose_name=b'Les places sont sur listing'),
|
field=models.BooleanField(default=False, verbose_name=b'Les places sont sur listing'),
|
||||||
preserve_default=False,
|
preserve_default=False,
|
||||||
),
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='spectacle',
|
||||||
|
name='rappel_sent',
|
||||||
|
field=models.DateTimeField(null=True, verbose_name=b'Mail de rappel envoy\xc3\xa9', blank=True),
|
||||||
|
),
|
||||||
]
|
]
|
|
@ -7,6 +7,7 @@ from django.contrib.auth.models import User
|
||||||
from django.template import loader, Context
|
from django.template import loader, Context
|
||||||
from django.core import mail
|
from django.core import mail
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
|
||||||
def render_template(template_name, data):
|
def render_template(template_name, data):
|
||||||
|
@ -48,6 +49,8 @@ class Spectacle(models.Model):
|
||||||
priority = models.IntegerField("Priorité", default=1000)
|
priority = models.IntegerField("Priorité", default=1000)
|
||||||
tirage = models.ForeignKey(Tirage)
|
tirage = models.ForeignKey(Tirage)
|
||||||
listing = models.BooleanField("Les places sont sur listing")
|
listing = models.BooleanField("Les places sont sur listing")
|
||||||
|
rappel_sent = models.DateTimeField("Mail de rappel envoyé", blank=True,
|
||||||
|
null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Spectacle"
|
verbose_name = "Spectacle"
|
||||||
|
@ -92,6 +95,9 @@ class Spectacle(models.Model):
|
||||||
# On envoie les mails
|
# On envoie les mails
|
||||||
connection = mail.get_connection()
|
connection = mail.get_connection()
|
||||||
connection.send_messages(mails_to_send)
|
connection.send_messages(mails_to_send)
|
||||||
|
# On enregistre le fait que l'envoi a bien eu lieu
|
||||||
|
self.rappel_sent = timezone.now()
|
||||||
|
self.save()
|
||||||
# On renvoie la liste des destinataires
|
# On renvoie la liste des destinataires
|
||||||
return members.values()
|
return members.values()
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,31 @@
|
||||||
{% extends "base_title.html" %}
|
{% extends "base_title.html" %}
|
||||||
|
|
||||||
{% block realcontent %}
|
{% block realcontent %}
|
||||||
|
{% if sent %}
|
||||||
<h3>Les mails de rappel pour le spectacle {{ show.title }} ont bien été envoyés aux personnes suivantes</h3>
|
<h3>Les mails de rappel pour le spectacle {{ show.title }} ont bien été envoyés aux personnes suivantes</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{% for member in members %}
|
{% for member in members %}
|
||||||
<li>{{ member.get_full_name }} ({{ member.email }})</li>
|
<li>{{ member.get_full_name }} ({{ member.email }})</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<h3>Forme des mails envoyés</h3>
|
{% else %}
|
||||||
|
<h3>Voulez vous envoyer les mails de rappel pour le spectacle
|
||||||
|
{{ show.title }} ?</h3>
|
||||||
|
{% if show.rappel_sent %}
|
||||||
|
<p class="error">Attention, les mails ont déjà été envoyés le
|
||||||
|
{{ show.rappel_sent }}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if not sent %}
|
||||||
|
<form action="" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<br />
|
||||||
|
<input type="submit" value="Envoyer" />
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<h3>Forme des mails</h3>
|
||||||
|
|
||||||
<br />Une seule place<br /><br />
|
<br />Une seule place<br /><br />
|
||||||
<pre>{{ exemple_mail_1place }}</pre>
|
<pre>{{ exemple_mail_1place }}</pre>
|
22
bda/views.py
22
bda/views.py
|
@ -249,7 +249,7 @@ def do_tirage(request, tirage_id):
|
||||||
# À partir d'ici, le tirage devient effectif
|
# À partir d'ici, le tirage devient effectif
|
||||||
# FIXME: Établir les conditions de validations (formulaire ?)
|
# FIXME: Établir les conditions de validations (formulaire ?)
|
||||||
# cf. issue #32
|
# cf. issue #32
|
||||||
if False:
|
if True:
|
||||||
Attribution.objects.filter(
|
Attribution.objects.filter(
|
||||||
spectacle__tirage=tirage_elt
|
spectacle__tirage=tirage_elt
|
||||||
).delete()
|
).delete()
|
||||||
|
@ -374,9 +374,7 @@ def liste_spectacles_ics(request, tirage_id):
|
||||||
|
|
||||||
@buro_required
|
@buro_required
|
||||||
def send_rappel(request, spectacle_id):
|
def send_rappel(request, spectacle_id):
|
||||||
# Envoi des mails
|
|
||||||
show = get_object_or_404(Spectacle, id=spectacle_id)
|
show = get_object_or_404(Spectacle, id=spectacle_id)
|
||||||
members = show.send_rappel()
|
|
||||||
# Mails d'exemples
|
# Mails d'exemples
|
||||||
fake_member = request.user
|
fake_member = request.user
|
||||||
fake_member.nb_attr = 1
|
fake_member.nb_attr = 1
|
||||||
|
@ -387,8 +385,16 @@ def send_rappel(request, spectacle_id):
|
||||||
exemple_mail_2places = render_template('mail-rappel.txt', {
|
exemple_mail_2places = render_template('mail-rappel.txt', {
|
||||||
'member': fake_member,
|
'member': fake_member,
|
||||||
'show': show})
|
'show': show})
|
||||||
return render(request, "mails-rappel-sent.html", {
|
# Contexte
|
||||||
'members': members,
|
ctxt = {'show': show,
|
||||||
'show': show,
|
'exemple_mail_1place': exemple_mail_1place,
|
||||||
'exemple_mail_1place': exemple_mail_1place,
|
'exemple_mail_2places': exemple_mail_2places}
|
||||||
'exemple_mail_2places': exemple_mail_2places})
|
# Envoi confirmé
|
||||||
|
if request.method == 'POST':
|
||||||
|
members = show.send_rappel()
|
||||||
|
ctxt['sent'] = True
|
||||||
|
ctxt['members'] = members
|
||||||
|
# Demande de confirmation
|
||||||
|
else:
|
||||||
|
ctxt['sent'] = False
|
||||||
|
return render(request, "mails-rappel.html", ctxt)
|
||||||
|
|
Loading…
Reference in a new issue