Adapte la vue du tirage.
Désormais, les tirages peuvent être lancés sans modifier le code et avec moult avertissements.
This commit is contained in:
parent
9e50a825e0
commit
45864fdcb0
6 changed files with 37 additions and 15 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
{% block extracontent %}
|
||||
|
||||
<h1>Attribution (détails)</h1>
|
||||
<h1>Attributions (détails)</h1>
|
||||
<h2>Token :</h2>
|
||||
<pre>{{ token }}</pre>
|
||||
<h2>Placés : {{ total_slots }} ; Déçus : {{ total_losers }}</h2>
|
||||
|
|
|
@ -7,7 +7,12 @@
|
|||
|
||||
{% block realcontent %}
|
||||
|
||||
<h1>Attribution</h1>
|
||||
<h1>Attributions</h1>
|
||||
|
||||
<br />
|
||||
<h2 class="important">Pensez à désactiver le lancement du tirage dès maintenant dans
|
||||
l'<a href="{% url "admin:index" %}">interface admin</a> </h2>
|
||||
|
||||
<h2>Token :</h2>
|
||||
<pre>{{ token }}</pre>
|
||||
<h2>Placés : {{ total_slots }} ; Déçus : {{ total_losers }}</h2>
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
<div>
|
||||
{{ form.token }}
|
||||
</div>
|
||||
<input type="submit" value="Go" />
|
||||
<input type="submit" onclick="return confirm('Voulez vous lancer le Tirage maintenant ?\n\nCECI REMETTRA À ZÉRO TOUTES LES DONNÉES si le tirage a déjà été lancé.')" value="Go" />
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
9
bda/templates/tirage-failed.html
Normal file
9
bda/templates/tirage-failed.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{% extends "base_title.html" %}
|
||||
|
||||
{% block realcontent %}
|
||||
<h2>Raté, le tirage ne peut pas être lancé !</h2>
|
||||
|
||||
<p>Si vous savez ce que vous faites, vous pouvez autoriser le lancement du
|
||||
tirage dans l'<a href="{% url "admin:index" %}">interface admin</a>.
|
||||
Pensez à le désactiver à nouveau ensuite.</p>
|
||||
{% endblock %}
|
23
bda/views.py
23
bda/views.py
|
@ -181,11 +181,11 @@ def inscription(request, tirage_id):
|
|||
|
||||
def do_tirage(request, tirage_id):
|
||||
tirage_elt = get_object_or_404(Tirage, id=tirage_id)
|
||||
if not tirage_elt.enable_do_tirage:
|
||||
return render(request, "tirage-failed.html", {'tirage': tirage_elt})
|
||||
form = TokenForm(request.POST)
|
||||
if not form.is_valid():
|
||||
return tirage(request)
|
||||
tirage_elt.token = form.cleaned_data['token']
|
||||
tirage_elt.save()
|
||||
start = time.time()
|
||||
data = {}
|
||||
shows = tirage_elt.spectacle_set.select_related().all()
|
||||
|
@ -235,16 +235,15 @@ def do_tirage(request, tirage_id):
|
|||
members2 = members2.items()
|
||||
data["members2"] = sorted(members2, key=lambda m: m[0].user.last_name)
|
||||
# À partir d'ici, le tirage devient effectif
|
||||
# FIXME: Établir les conditions de validations (formulaire ?)
|
||||
# cf. issue #32
|
||||
if False:
|
||||
Attribution.objects.filter(
|
||||
spectacle__tirage=tirage_elt
|
||||
).delete()
|
||||
for (show, members, _) in results:
|
||||
for (member, _, _, _) in members:
|
||||
attrib = Attribution(spectacle=show, participant=member)
|
||||
attrib.save()
|
||||
Attribution.objects.filter(spectacle__tirage=tirage_elt).delete()
|
||||
tirage_elt.tokens += "%s\n\"\"\"%s\"\"\"\n" % (
|
||||
timezone.now().strftime("%y-%m-%d %H:%M:%S"),
|
||||
form.cleaned_data['token'])
|
||||
tirage_elt.save()
|
||||
for (show, members, _) in results:
|
||||
for (member, _, _, _) in members:
|
||||
attrib = Attribution(spectacle=show, participant=member)
|
||||
attrib.save()
|
||||
return render(request, "bda-attrib-extra.html", data)
|
||||
else:
|
||||
return render(request, "bda-attrib.html", data)
|
||||
|
|
|
@ -246,6 +246,15 @@ fieldset legend {
|
|||
background-color: transparent;
|
||||
}
|
||||
|
||||
.important {
|
||||
font-weight: bold;
|
||||
color: #F90;
|
||||
}
|
||||
|
||||
.important a {
|
||||
color: #F90;
|
||||
}
|
||||
|
||||
#main form ul.errorlist li {
|
||||
font-weight: bold;
|
||||
color: #B00000;
|
||||
|
|
Loading…
Reference in a new issue