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