check lors de l'inscription pour des places en revente
This commit is contained in:
parent
b6655047ed
commit
f0553d709e
2 changed files with 17 additions and 1 deletions
|
@ -3,6 +3,9 @@
|
|||
|
||||
{% block realcontent %}
|
||||
<h2>Inscriptions pour BDA-Revente</h2>
|
||||
{% if deja_revente %}
|
||||
<p class="success">Des reventes existent déjà pour certains de ces spectacles ; vérifie les places disponibles sans tirage !</p>
|
||||
{% endif %}
|
||||
<form action="" class="form-horizontal" method="post">
|
||||
{% csrf_token %}
|
||||
{{form | bootstrap}}
|
||||
|
|
15
bda/views.py
15
bda/views.py
|
@ -381,6 +381,7 @@ def list_revente(request, tirage_id):
|
|||
spectacles = tirage.spectacle_set.filter(
|
||||
date__gte=timezone.now())
|
||||
shotgun = []
|
||||
deja_revente = False
|
||||
for spectacle in spectacles:
|
||||
revente_objects = SpectacleRevente.objects.filter(
|
||||
attribution__spectacle=spectacle,
|
||||
|
@ -399,13 +400,25 @@ def list_revente(request, tirage_id):
|
|||
choices = form.cleaned_data['spectacles']
|
||||
participant.choicesrevente = choices
|
||||
participant.save()
|
||||
for spectacle in choices:
|
||||
qset = SpectacleRevente.objects.filter(
|
||||
attribution__spectacle=spectacle)
|
||||
if qset.exists():
|
||||
# On l'inscrit à l'un des tirages au sort
|
||||
for revente in qset.all():
|
||||
if not revente.shotgun:
|
||||
revente.interested.add(participant)
|
||||
break
|
||||
deja_revente = True
|
||||
|
||||
else:
|
||||
form = InscriptionReventeForm(
|
||||
tirage,
|
||||
initial={'spectacles': participant.choicesrevente.all()})
|
||||
|
||||
return render(request, "liste-reventes.html",
|
||||
{"form": form, 'shotgun': shotgun})
|
||||
{"form": form, 'shotgun': shotgun,
|
||||
"deja_revente": deja_revente})
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
Loading…
Reference in a new issue