forked from DGNum/gestioCOF
Proper use of messages in inscription-reventes
This commit is contained in:
parent
efea92b5d2
commit
b12b5c938f
2 changed files with 13 additions and 15 deletions
|
@ -3,15 +3,6 @@
|
|||
|
||||
{% block realcontent %}
|
||||
<h2>Inscriptions pour BdA-Revente</h2>
|
||||
{% if success %}
|
||||
<p class="success">Ton inscription a bien été prise en compte !</p>
|
||||
{% endif %}
|
||||
{% if deja_revente %}
|
||||
<p class="success">Des reventes existent déjà pour certains de ces spectacles ; vérifie les places disponibles sans tirage !</p>
|
||||
{% elif inscrit_revente %}
|
||||
<p class="success">Tu as été inscrit à une revente en cours pour ce spectacle !</p>
|
||||
{% endif %}
|
||||
|
||||
<form action="" class="form-horizontal" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="form-group">
|
19
bda/views.py
19
bda/views.py
|
@ -427,7 +427,7 @@ def list_revente(request, tirage_id):
|
|||
user=request.user, tirage=tirage)
|
||||
deja_revente = False
|
||||
success = False
|
||||
inscrit_revente = False
|
||||
inscrit_revente = []
|
||||
if request.method == 'POST':
|
||||
form = InscriptionReventeForm(tirage, request.POST)
|
||||
if form.is_valid():
|
||||
|
@ -454,17 +454,24 @@ def list_revente(request, tirage_id):
|
|||
if min_resell is not None:
|
||||
min_resell.answered_mail.add(participant)
|
||||
min_resell.save()
|
||||
inscrit_revente = True
|
||||
inscrit_revente.append(spectacle)
|
||||
success = True
|
||||
else:
|
||||
form = InscriptionReventeForm(
|
||||
tirage,
|
||||
initial={'spectacles': participant.choicesrevente.all()})
|
||||
# Messages
|
||||
if success:
|
||||
messages.success(request, "Ton inscription a bien été prise en compte")
|
||||
if deja_revente:
|
||||
messages.info(request, "Des reventes existent déjà pour certains de "
|
||||
"ces spectacles, vérifie les places "
|
||||
"disponibles sans tirage !")
|
||||
for spectacle in inscrit_revente:
|
||||
messages.info(request, "Tu as été inscrit à une revente en cours pour "
|
||||
"{!s}".format(spectacle))
|
||||
|
||||
return render(request, "liste-reventes.html",
|
||||
{"form": form,
|
||||
"deja_revente": deja_revente, "success": success,
|
||||
"inscrit_revente": inscrit_revente})
|
||||
return render(request, "bda/liste-reventes.html", {"form": form})
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
Loading…
Add table
Reference in a new issue