From 59b8f406b652ffb1ddd9a20a726d3e5461264cf7 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Mon, 26 Sep 2016 15:53:58 +0200 Subject: [PATCH] fix bug shotgun --- bda/views.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bda/views.py b/bda/views.py index bac7415d..12c57d49 100644 --- a/bda/views.py +++ b/bda/views.py @@ -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 !