forked from DGNum/gestioCOF
Style + commentaires
This commit is contained in:
parent
a9f25374ff
commit
330b45fb2c
1 changed files with 22 additions and 13 deletions
29
bda/views.py
29
bda/views.py
|
@ -271,6 +271,7 @@ def revente(request, tirage_id):
|
|||
if not participant.paid:
|
||||
return render(request, "bda-notpaid.html", {})
|
||||
if request.method == 'POST':
|
||||
# On met en vente une place
|
||||
if 'resell' in request.POST:
|
||||
resellform = ResellForm(participant, request.POST, prefix='resell')
|
||||
annulform = AnnulForm(participant, prefix='annul')
|
||||
|
@ -279,7 +280,8 @@ def revente(request, tirage_id):
|
|||
attributions = resellform.cleaned_data["attributions"]
|
||||
with transaction.atomic():
|
||||
for attribution in attributions:
|
||||
revente, created = SpectacleRevente.objects.get_or_create(
|
||||
revente, created = \
|
||||
SpectacleRevente.objects.get_or_create(
|
||||
attribution=attribution,
|
||||
defaults={'seller': participant})
|
||||
if not created:
|
||||
|
@ -288,21 +290,25 @@ def revente(request, tirage_id):
|
|||
revente.notif_sent = False
|
||||
revente.tirage_done = False
|
||||
revente.shotgun = False
|
||||
mail_subject = "BdA-Revente : {:s}".format(attribution.spectacle.title)
|
||||
mail_body = loader.render_to_string('bda/mails/revente-new.txt', {
|
||||
'vendeur': participant.user,
|
||||
mail_subject = "BdA-Revente : {:s}".format(
|
||||
attribution.spectacle.title)
|
||||
mail_body = loader.render_to_string(
|
||||
'bda/mails/revente-new.txt',
|
||||
{'vendeur': participant.user,
|
||||
'spectacle': attribution.spectacle,
|
||||
'revente': revente,
|
||||
})
|
||||
'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']],
|
||||
reply_to=[
|
||||
settings.MAIL_DATA['revente']['REPLYTO']
|
||||
],
|
||||
))
|
||||
revente.save()
|
||||
mail.get_connection().send_messages(mails)
|
||||
|
||||
# On annule une revente
|
||||
elif 'annul' in request.POST:
|
||||
annulform = AnnulForm(participant, request.POST, prefix='annul')
|
||||
resellform = ResellForm(participant, prefix='resell')
|
||||
|
@ -310,7 +316,8 @@ def revente(request, tirage_id):
|
|||
attributions = annulform.cleaned_data["attributions"]
|
||||
for attribution in attributions:
|
||||
attribution.revente.delete()
|
||||
|
||||
# On confirme une vente en transférant la place à la personne qui a
|
||||
# gagné le tirage
|
||||
elif 'transfer' in request.POST:
|
||||
resellform = ResellForm(participant, prefix='resell')
|
||||
annulform = AnnulForm(participant, prefix='annul')
|
||||
|
@ -323,7 +330,9 @@ def revente(request, tirage_id):
|
|||
attrib = revente.attribution
|
||||
attrib.participant = revente.soldTo
|
||||
attrib.save()
|
||||
|
||||
# On annule la revente après le tirage au sort (par exemple si
|
||||
# la personne qui a gagné le tirage ne se manifeste pas). La place est
|
||||
# alors remise en vente
|
||||
elif 'reinit' in request.POST:
|
||||
resellform = ResellForm(participant, prefix='resell')
|
||||
annulform = AnnulForm(participant, prefix='annul')
|
||||
|
|
Loading…
Reference in a new issue