Correction de bugs et nettoyage

This commit is contained in:
Martin Pépin 2016-12-23 10:25:28 +01:00
parent b39806e171
commit 8bf2f715a4
5 changed files with 34 additions and 27 deletions

View file

@ -298,36 +298,35 @@ class SpectacleRevente(models.Model):
# Envoie un mail au gagnant et au vendeur # Envoie un mail au gagnant et au vendeur
winner = random.choice(inscrits) winner = random.choice(inscrits)
self.soldTo = winner self.soldTo = winner
datatuple = []
context = { context = {
'acheteur': winner.user, 'acheteur': winner.user,
'vendeur': seller.user, 'vendeur': seller.user,
'show': spectacle, 'show': spectacle,
} }
send_custom_mail( datatuple.append((
'bda-revente-winner', 'bda-revente-winner',
context,
settings.MAIL_DATA['revente']['FROM'],
[winner.user.email], [winner.user.email],
context=context, ))
from_email=settings.MAIL_DATA['revente']['FROM'] datatuple.append((
)
send_custom_mail(
'bda-revente-seller', 'bda-revente-seller',
[seller.user.email], context,
context=context, settings.MAIL_DATA['revente']['FROM'],
from_email=settings.MAIL_DATA['revente']['FROM'] [seller.user.email]
) ))
# Envoie un mail aux perdants # Envoie un mail aux perdants
datatuple = [( for inscrit in inscrits:
if inscrit != winner:
context['acheteur'] = inscrit.user
datatuple.append((
'bda-revente-loser', 'bda-revente-loser',
{ context,
'acheteur': inscrit.user,
'vendeur': seller.user,
'show': spectacle
},
settings.MAIL_DATA['revente']['FROM'], settings.MAIL_DATA['revente']['FROM'],
[inscrit.user.email]) [inscrit.user.email]
for inscrit in inscrits if inscrit != winner ))
]
send_mass_custom_mail(datatuple) send_mass_custom_mail(datatuple)
# Si personne ne veut de la place, elle part au shotgun # Si personne ne veut de la place, elle part au shotgun
else: else:

View file

@ -28,8 +28,12 @@
<h3>Forme des mails</h3> <h3>Forme des mails</h3>
<br />Une seule place<br /><br /> <br />Une seule place<br /><br />
<pre>{{ exemple_mail_1place }}</pre> {% for part in exemple_mail_1place %}
<pre>{{ part }}</pre>
{% endfor %}
<br />Deux places<br /><br /> <br />Deux places<br /><br />
<pre>{{ exemple_mail_2places }}</pre> {% for part in exemple_mail_2places %}
<pre>{{ part }}</pre>
{% endfor %}
{% endblock %} {% endblock %}

View file

@ -466,7 +466,7 @@ def buy_revente(request, spectacle_id):
} }
send_custom_mail( send_custom_mail(
'bda-buy-shotgun', 'bda-buy-shotgun',
[revente.seller.user.email], recipient_list=[revente.seller.user.email],
context=context, context=context,
from_email='bda@ens.fr' from_email='bda@ens.fr'
) )
@ -575,7 +575,7 @@ def send_rappel(request, spectacle_id):
# Demande de confirmation # Demande de confirmation
else: else:
ctxt['sent'] = False ctxt['sent'] = False
return render(request, "mails-rappel.html", ctxt) return render(request, "bda/mails-rappel.html", ctxt)
def descriptions_spectacles(request, tirage_id): def descriptions_spectacles(request, tirage_id):

View file

@ -155,7 +155,7 @@ def _generate_eleve_email(demande, proposed_for):
render_custom_mail('petit-cours-mail-eleve', { render_custom_mail('petit-cours-mail-eleve', {
"demande": demande, "demande": demande,
"matieres": matieres "matieres": matieres
})[1] })
) )
for user, matieres in proposed_for for user, matieres in proposed_for
] ]

View file

@ -30,10 +30,14 @@
<h4>Mails pour les membres proposés :</h4> <h4>Mails pour les membres proposés :</h4>
{% for proposeduser, mail in proposed_mails %} {% for proposeduser, mail in proposed_mails %}
<h5>Pour {{ proposeduser }}:</h5> <h5>Pour {{ proposeduser }}:</h5>
<pre>{{ mail }}</pre> {% for part in mail %}
<pre>{{ part }}</pre>
{% endfor %}
{% endfor %} {% endfor %}
<h4>Mail pour l'auteur de la demande :</h4> <h4>Mail pour l'auteur de la demande :</h4>
<pre style="margin-top: 15px;">{{ mainmail|safe }}</pre> {% for part in mainmail %}
<pre style="margin-top: 15px;">{{ part|safe }}</pre>
{% endfor %}
<input type="hidden" name="attribdata" value="{{ attribdata }}" /> <input type="hidden" name="attribdata" value="{{ attribdata }}" />
{% if redo %}<input type="hidden" name="redo" value="1" />{% endif %} {% if redo %}<input type="hidden" name="redo" value="1" />{% endif %}
<input class="btn btn-primary pull-right" type="submit" value="Valider le {% if redo %}re{% endif %}traitement de la demande" /> <input class="btn btn-primary pull-right" type="submit" value="Valider le {% if redo %}re{% endif %}traitement de la demande" />