fix bug shotgun

This commit is contained in:
Ludovic Stephan 2016-09-26 15:53:58 +02:00
parent 15e755334d
commit 59b8f406b6

View file

@ -406,7 +406,7 @@ def list_revente(request, tirage_id):
if qset.exists(): if qset.exists():
# On l'inscrit à l'un des tirages au sort # On l'inscrit à l'un des tirages au sort
for revente in qset.all(): for revente in qset.all():
if revente.shotgun: if revente.shotgun and not revente.soldTo:
deja_revente = True deja_revente = True
else: else:
revente.interested.add(participant) revente.interested.add(participant)
@ -435,12 +435,16 @@ def buy_revente(request, spectacle_id):
revente.delete() revente.delete()
return HttpResponseRedirect(reverse("bda-liste-revente", return HttpResponseRedirect(reverse("bda-liste-revente",
args=[tirage.id])) args=[tirage.id]))
reventes_shotgun = []
for revente in reventes.all():
if revente.shotgun:
reventes_shotgun.append(revente)
if not reventes.exists(): if reventes_shotgun.empty():
return render(request, "bda-no-revente.html", {}) return render(request, "bda-no-revente.html", {})
if request.POST: if request.POST:
revente = random.choice(reventes.all()) revente = random.choice(reventes_shotgun)
revente.soldTo = participant revente.soldTo = participant
revente.save() revente.save()
mail = """Bonjour ! mail = """Bonjour !