Simplify the mails-rappel view

This commit is contained in:
Martin Pépin 2017-06-18 17:03:50 +01:00
parent 69aee6b8ac
commit 80f6a808dc
2 changed files with 6 additions and 13 deletions

View file

@ -28,7 +28,7 @@
<p>
<em>Note :</em> le template de ce mail peut être modifié à
<a href="{% url 'admin:custommail_custommail_change' custommail_id %}">cette adresse</a>
<a href="{% url 'admin:custommail_custommail_change' custommail.pk %}">cette adresse</a>
</p>
<hr \>

View file

@ -6,9 +6,7 @@ import hashlib
import time
import json
from datetime import timedelta
from custommail.shortcuts import (
send_mass_custom_mail, send_custom_mail, render_custom_mail
)
from custommail.shortcuts import send_mass_custom_mail, send_custom_mail
from custommail.models import CustomMail
from django.shortcuts import render, get_object_or_404
from django.contrib.auth.decorators import login_required
@ -652,28 +650,23 @@ def unpaid(request, tirage_id):
def send_rappel(request, spectacle_id):
show = get_object_or_404(Spectacle, id=spectacle_id)
# Mails d'exemples
exemple_mail_1place = render_custom_mail('bda-rappel', {
custommail = CustomMail.objects.get(shortname="bda-rappel")
exemple_mail_1place = custommail.render({
'member': request.user,
'show': show,
'nb_attr': 1
})
exemple_mail_2places = render_custom_mail('bda-rappel', {
exemple_mail_2places = custommail.render({
'member': request.user,
'show': show,
'nb_attr': 2
})
# Contexte
custommail_id = (
CustomMail.objects
.filter(shortname="bda-rappel")
.values_list("id", flat=True)
[0]
)
ctxt = {
'show': show,
'exemple_mail_1place': exemple_mail_1place,
'exemple_mail_2places': exemple_mail_2places,
'custommail_id': custommail_id,
'custommail': custommail,
}
# Envoi confirmé
if request.method == 'POST':