forked from DGNum/gestioCOF
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 %}
|
{% block extracontent %}
|
||||||
|
|
||||||
<h1>Attribution (détails)</h1>
|
<h1>Attributions (détails)</h1>
|
||||||
<h2>Token :</h2>
|
<h2>Token :</h2>
|
||||||
<pre>{{ token }}</pre>
|
<pre>{{ token }}</pre>
|
||||||
<h2>Placés : {{ total_slots }} ; Déçus : {{ total_losers }}</h2>
|
<h2>Placés : {{ total_slots }} ; Déçus : {{ total_losers }}</h2>
|
||||||
|
|
|
@ -7,7 +7,12 @@
|
||||||
|
|
||||||
{% block realcontent %}
|
{% 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>
|
<h2>Token :</h2>
|
||||||
<pre>{{ token }}</pre>
|
<pre>{{ token }}</pre>
|
||||||
<h2>Placés : {{ total_slots }} ; Déçus : {{ total_losers }}</h2>
|
<h2>Placés : {{ total_slots }} ; Déçus : {{ total_losers }}</h2>
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
<div>
|
<div>
|
||||||
{{ form.token }}
|
{{ form.token }}
|
||||||
</div>
|
</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>
|
</form>
|
||||||
{% endblock %}
|
{% 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):
|
def do_tirage(request, tirage_id):
|
||||||
tirage_elt = get_object_or_404(Tirage, id=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)
|
form = TokenForm(request.POST)
|
||||||
if not form.is_valid():
|
if not form.is_valid():
|
||||||
return tirage(request)
|
return tirage(request)
|
||||||
tirage_elt.token = form.cleaned_data['token']
|
|
||||||
tirage_elt.save()
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
data = {}
|
data = {}
|
||||||
shows = tirage_elt.spectacle_set.select_related().all()
|
shows = tirage_elt.spectacle_set.select_related().all()
|
||||||
|
@ -235,16 +235,15 @@ def do_tirage(request, tirage_id):
|
||||||
members2 = members2.items()
|
members2 = members2.items()
|
||||||
data["members2"] = sorted(members2, key=lambda m: m[0].user.last_name)
|
data["members2"] = sorted(members2, key=lambda m: m[0].user.last_name)
|
||||||
# À partir d'ici, le tirage devient effectif
|
# À partir d'ici, le tirage devient effectif
|
||||||
# FIXME: Établir les conditions de validations (formulaire ?)
|
Attribution.objects.filter(spectacle__tirage=tirage_elt).delete()
|
||||||
# cf. issue #32
|
tirage_elt.tokens += "%s\n\"\"\"%s\"\"\"\n" % (
|
||||||
if False:
|
timezone.now().strftime("%y-%m-%d %H:%M:%S"),
|
||||||
Attribution.objects.filter(
|
form.cleaned_data['token'])
|
||||||
spectacle__tirage=tirage_elt
|
tirage_elt.save()
|
||||||
).delete()
|
for (show, members, _) in results:
|
||||||
for (show, members, _) in results:
|
for (member, _, _, _) in members:
|
||||||
for (member, _, _, _) in members:
|
attrib = Attribution(spectacle=show, participant=member)
|
||||||
attrib = Attribution(spectacle=show, participant=member)
|
attrib.save()
|
||||||
attrib.save()
|
|
||||||
return render(request, "bda-attrib-extra.html", data)
|
return render(request, "bda-attrib-extra.html", data)
|
||||||
else:
|
else:
|
||||||
return render(request, "bda-attrib.html", data)
|
return render(request, "bda-attrib.html", data)
|
||||||
|
|
|
@ -246,6 +246,15 @@ fieldset legend {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.important {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #F90;
|
||||||
|
}
|
||||||
|
|
||||||
|
.important a {
|
||||||
|
color: #F90;
|
||||||
|
}
|
||||||
|
|
||||||
#main form ul.errorlist li {
|
#main form ul.errorlist li {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #B00000;
|
color: #B00000;
|
||||||
|
|
Loading…
Reference in a new issue