forked from DGNum/gestioCOF
Envoie un mail de confirmation lors d'une mise en vente
Ce mail contient la date du tirage.
This commit is contained in:
parent
f1c87ab8ad
commit
981ff48e3d
2 changed files with 40 additions and 10 deletions
13
bda/templates/mail-revente-new.txt
Normal file
13
bda/templates/mail-revente-new.txt
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
Bonjour {{ vendeur.first_name }},
|
||||||
|
|
||||||
|
Tu t’es bien inscrit-e pour la revente de {{ spectacle.title }}.
|
||||||
|
|
||||||
|
{% with revente.expiration_time as time %}
|
||||||
|
Le tirage au sort entre tout-e-s les racheteuse-eur-s potentiel-le-s aura lieu
|
||||||
|
le {{ time|date:"DATE_FORMAT" }} à {{ time|time:"TIME_FORMAT" }} (dans {{time|timeuntil }}).
|
||||||
|
Si personne ne s’est inscrit pour racheter la place, celle-ci apparaitra parmi
|
||||||
|
les « Places disponibles immédiatement à la revente » sur GestioCOF.
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
|
Bonne revente !
|
||||||
|
Le Bureau des Arts
|
37
bda/views.py
37
bda/views.py
|
@ -8,15 +8,17 @@ import random
|
||||||
|
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.db import models
|
from django.db import models, transaction
|
||||||
from django.db.models import Count, Q
|
from django.db.models import Count, Q
|
||||||
from django.core import serializers
|
from django.core import serializers, mail
|
||||||
from django.forms.models import inlineformset_factory
|
from django.forms.models import inlineformset_factory
|
||||||
from django.http import HttpResponseBadRequest, HttpResponseRedirect
|
from django.http import HttpResponseBadRequest, HttpResponseRedirect
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.conf import settings
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
|
from django.template import loader
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.views.generic.list import ListView
|
from django.views.generic.list import ListView
|
||||||
|
|
||||||
|
@ -292,15 +294,30 @@ def revente(request, tirage_id):
|
||||||
resellform = ResellForm(participant, request.POST, prefix='resell')
|
resellform = ResellForm(participant, request.POST, prefix='resell')
|
||||||
annulform = AnnulForm(participant, prefix='annul')
|
annulform = AnnulForm(participant, prefix='annul')
|
||||||
if resellform.is_valid():
|
if resellform.is_valid():
|
||||||
|
mails = []
|
||||||
attributions = resellform.cleaned_data["attributions"]
|
attributions = resellform.cleaned_data["attributions"]
|
||||||
for attribution in attributions:
|
with transaction.atomic():
|
||||||
revente, created = SpectacleRevente.objects.get_or_create(
|
for attribution in attributions:
|
||||||
attribution=attribution,
|
revente, created = SpectacleRevente.objects.get_or_create(
|
||||||
defaults={'seller': participant})
|
attribution=attribution,
|
||||||
if not created:
|
defaults={'seller': participant})
|
||||||
revente.seller = participant
|
if not created:
|
||||||
revente.date = timezone.now()
|
revente.seller = participant
|
||||||
revente.save()
|
revente.date = timezone.now()
|
||||||
|
mail_subject = "BdA-Revente : {:s}".format(attribution.spectacle.title)
|
||||||
|
mail_body = loader.render_to_string('mail-revente-new.txt', {
|
||||||
|
'vendeur': participant.user,
|
||||||
|
'spectacle': attribution.spectacle,
|
||||||
|
'revente': revente,
|
||||||
|
})
|
||||||
|
mails.append(mail.EmailMessage(
|
||||||
|
mail_subject, mail_body,
|
||||||
|
from_email=settings.MAIL_DATA['revente']['FROM'],
|
||||||
|
to=[participant.user.email],
|
||||||
|
reply_to=[settings.MAIL_DATA['revente']['REPLYTO']],
|
||||||
|
))
|
||||||
|
revente.save()
|
||||||
|
mail.get_connection().send_messages(mails)
|
||||||
|
|
||||||
elif 'annul' in request.POST:
|
elif 'annul' in request.POST:
|
||||||
annulform = AnnulForm(participant, request.POST, prefix='annul')
|
annulform = AnnulForm(participant, request.POST, prefix='annul')
|
||||||
|
|
Loading…
Reference in a new issue