Rend la page état des demandes/ratios cohérente

- Le nombre total de demandes affiché est désormais le nombre de places
  demandées et non le nombre de personnes ayant fait des demandes. Ainsi
  ce nombre correspond à la somme des totaux par spectacle affiché

- Au passage, on déplace le template de cette vue dans un dossier plus
  adéquat et on ajoute une docstring sur la vue.
This commit is contained in:
Martin Pépin 2017-01-06 18:19:15 +01:00
parent 672b8727b7
commit 4f66f161b0
2 changed files with 14 additions and 13 deletions

View file

@ -38,7 +38,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<span class="bda-prix">Total : {{ total }} demandes</span> <span class="bda-prix">Total : {{ total }} places demandées</span>
<script type="text/javascript" <script type="text/javascript"
src="{% static "js/jquery.min.js" %}"></script> src="{% static "js/jquery.min.js" %}"></script>
<script type="text/javascript" <script type="text/javascript"

View file

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import random import random
import hashlib
import time
from datetime import timedelta
from django.shortcuts import render, get_object_or_404 from django.shortcuts import render, get_object_or_404
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
@ -15,27 +15,28 @@ from django.forms.models import inlineformset_factory
from django.http import HttpResponseBadRequest, HttpResponseRedirect from django.http import HttpResponseBadRequest, HttpResponseRedirect
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.conf import settings from django.conf import settings
import hashlib
from django.core.mail import send_mail from django.core.mail import send_mail
from django.template import loader from django.template import loader
from django.utils import timezone from django.utils import timezone
from django.views.generic.list import ListView from django.views.generic.list import ListView
import time
from datetime import timedelta
from gestioncof.decorators import cof_required, buro_required from gestioncof.decorators import cof_required, buro_required
from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution,\ from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution,\
Tirage, SpectacleRevente Tirage, SpectacleRevente
from bda.algorithm import Algorithm from bda.algorithm import Algorithm
from bda.forms import BaseBdaFormSet, TokenForm, ResellForm, AnnulForm,\ from bda.forms import BaseBdaFormSet, TokenForm, ResellForm, AnnulForm,\
InscriptionReventeForm InscriptionReventeForm
@cof_required @cof_required
def etat_places(request, tirage_id): def etat_places(request, tirage_id):
"""
Résumé des spectacles d'un tirage avec pour chaque spectacle :
- Le nombrede places en jeu
- Le nombre de demandes
- Le ratio demandes/places
Et le total de toutes les demandes
"""
tirage = get_object_or_404(Tirage, id=tirage_id) tirage = get_object_or_404(Tirage, id=tirage_id)
spectacles1 = ChoixSpectacle.objects \ spectacles1 = ChoixSpectacle.objects \
.filter(spectacle__tirage=tirage) \ .filter(spectacle__tirage=tirage) \
@ -67,8 +68,8 @@ def etat_places(request, tirage_id):
spectacles_dict[spectacle["spectacle"]].ratio = \ spectacles_dict[spectacle["spectacle"]].ratio = \
spectacles_dict[spectacle["spectacle"]].total / \ spectacles_dict[spectacle["spectacle"]].total / \
spectacles_dict[spectacle["spectacle"]].slots spectacles_dict[spectacle["spectacle"]].slots
total += spectacle["total"] total += 2*spectacle["total"]
return render(request, "etat-places.html", return render(request, "bda/etat-places.html",
{"spectacles": spectacles, "total": total, 'tirage': tirage}) {"spectacles": spectacles, "total": total, 'tirage': tirage})