From 233130499206ff5d40f3c451b7df9e670e0c2e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 10 Jun 2016 15:43:37 +0200 Subject: [PATCH 1/3] Adopte le comportement de python3 pour la division MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les deux seuls fichiers touchés sont `bda/views.py` et `bda/algorithm.py` d'après un `grep -r '/' . | grep '\.py' | grep -v '^Binary' à la racine du projet. --- bda/algorithm.py | 4 +++- bda/views.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bda/algorithm.py b/bda/algorithm.py index bce41282..a6caf531 100644 --- a/bda/algorithm.py +++ b/bda/algorithm.py @@ -1,5 +1,7 @@ # coding: utf-8 +from __future__ import division + from django.conf import settings from django.db.models import Max @@ -62,7 +64,7 @@ class Algorithm(object): def __call__(self, seed): random.seed(seed) results = [] - shows = sorted(self.shows, key = lambda x: float(x.nrequests) / x.slots, reverse = True) + shows = sorted(self.shows, key = lambda x: x.nrequests / x.slots, reverse = True) for show in shows: # On regroupe tous les gens ayant le même rang groups = dict([(i, []) for i in range(1, self.max_group + 1)]) diff --git a/bda/views.py b/bda/views.py index f4495f55..6dc36b55 100644 --- a/bda/views.py +++ b/bda/views.py @@ -1,5 +1,7 @@ # coding: utf-8 +from __future__ import division + from django.contrib.auth.models import User from django.shortcuts import render, get_object_or_404 from django.contrib.auth.decorators import login_required @@ -49,13 +51,13 @@ def etat_places(request, tirage_id): spectacles_dict[spectacle["spectacle"]].total += spectacle["total"] spectacles_dict[spectacle["spectacle"]].ratio = \ spectacles_dict[spectacle["spectacle"]].total / \ - float(spectacles_dict[spectacle["spectacle"]].slots) + spectacles_dict[spectacle["spectacle"]].slots total += spectacle["total"] for spectacle in spectacles2: spectacles_dict[spectacle["spectacle"]].total += 2*spectacle["total"] spectacles_dict[spectacle["spectacle"]].ratio = \ spectacles_dict[spectacle["spectacle"]].total / \ - float(spectacles_dict[spectacle["spectacle"]].slots) + spectacles_dict[spectacle["spectacle"]].slots total += spectacle["total"] return render(request, "etat-places.html", {"spectacles": spectacles, "total": total, 'tirage': tirage}) From 624c431d773cf4dc5d3f81888d4c0bc218d6dc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 10 Jun 2016 17:04:00 +0200 Subject: [PATCH 2/3] Customise la vue Tirage dans admin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajoute des infos les infos suivantes sur la liste des tirages : - Titre - Ouverture - Fermeture - Tirage actif On permet la recherche sur le champ titre. On empêche l'édition de la graine du tirage (`token`). Il s'agit d'une archive et ne doit pas être modifiée. --- bda/admin.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bda/admin.py b/bda/admin.py index 8af71d00..aa3ce254 100644 --- a/bda/admin.py +++ b/bda/admin.py @@ -128,9 +128,16 @@ class SpectacleAdmin(admin.ModelAdmin): list_filter = ("location",) search_fields = ("title", "location__name") +class TirageAdmin(admin.ModelAdmin): + model = Tirage + list_display = ("title", "ouverture", "fermeture", "active") + readonly_fields = ("token", ) + list_filter = ("active", ) + search_fields = ("title", ) + admin.site.register(Spectacle, SpectacleAdmin) admin.site.register(Salle) admin.site.register(Participant, ParticipantAdmin) admin.site.register(Attribution, AttributionAdmin) admin.site.register(ChoixSpectacle, ChoixSpectacleAdmin) -admin.site.register(Tirage) +admin.site.register(Tirage, TirageAdmin) From 7a8e27d0a3e08b03576ec4a0bf6a3c8fce6edf9f Mon Sep 17 00:00:00 2001 From: Qwann Date: Fri, 10 Jun 2016 18:01:03 +0200 Subject: [PATCH 3/3] affiche maintenant le prix dans dans l'interface admin, quand on clique sur un particpant --- bda/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bda/admin.py b/bda/admin.py index 8af71d00..07d082d1 100644 --- a/bda/admin.py +++ b/bda/admin.py @@ -38,6 +38,7 @@ class ParticipantAdmin(admin.ModelAdmin): actions = ['send_attribs',] actions_on_bottom = True list_per_page = 400 + readonly_fields = ("total",) def send_attribs(self, request, queryset): for member in queryset.all():