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():
# On l'inscrit à l'un des tirages au sort
for revente in qset.all():
if revente.shotgun:
if revente.shotgun and not revente.soldTo:
deja_revente = True
else:
revente.interested.add(participant)
@ -435,12 +435,16 @@ def buy_revente(request, spectacle_id):
revente.delete()
return HttpResponseRedirect(reverse("bda-liste-revente",
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", {})
if request.POST:
revente = random.choice(reventes.all())
revente = random.choice(reventes_shotgun)
revente.soldTo = participant
revente.save()
mail = """Bonjour !