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] 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})