forked from DGNum/gestioCOF
fix revente de reventes
This commit is contained in:
parent
13f282a289
commit
1ba2766231
1 changed files with 10 additions and 3 deletions
13
bda/views.py
13
bda/views.py
|
@ -285,6 +285,9 @@ def revente(request, tirage_id):
|
|||
if not created:
|
||||
revente.seller = participant
|
||||
revente.date = timezone.now()
|
||||
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('mail-revente-new.txt', {
|
||||
'vendeur': participant.user,
|
||||
|
@ -421,18 +424,22 @@ def buy_revente(request, spectacle_id):
|
|||
reventes = SpectacleRevente.objects.filter(
|
||||
attribution__spectacle=spectacle,
|
||||
soldTo__isnull=True)
|
||||
|
||||
# Si l'utilisateur veut racheter une place qu'il est en train de revendre,
|
||||
# on supprime la revente en question.
|
||||
if reventes.filter(seller=participant).exists():
|
||||
revente = reventes.filter(seller=participant)[0]
|
||||
revente.delete()
|
||||
return HttpResponseRedirect(reverse("bda-shotgun",
|
||||
args=[tirage.id]))
|
||||
reventes_shotgun = reventes.filter(shotgun=True)
|
||||
|
||||
if not reventes_shotgun.exists():
|
||||
reventes_shotgun = list(reventes.filter(shotgun=True).all())
|
||||
|
||||
if not reventes_shotgun:
|
||||
return render(request, "bda-no-revente.html", {})
|
||||
|
||||
if request.POST:
|
||||
revente = random.choice(reventes_shotgun.all())
|
||||
revente = random.choice(reventes_shotgun)
|
||||
revente.soldTo = participant
|
||||
revente.save()
|
||||
mail = """Bonjour !
|
||||
|
|
Loading…
Reference in a new issue