Merge branch 'Kerl/division' into 'master'

Adopte le comportement de python3 pour la division

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.

Fixes #30 

See merge request !30
This commit is contained in:
Basile Clement 2016-06-10 23:05:37 +02:00
commit 6a2cd517aa
2 changed files with 7 additions and 3 deletions

View file

@ -1,5 +1,7 @@
# coding: utf-8 # coding: utf-8
from __future__ import division
from django.conf import settings from django.conf import settings
from django.db.models import Max from django.db.models import Max
@ -62,7 +64,7 @@ class Algorithm(object):
def __call__(self, seed): def __call__(self, seed):
random.seed(seed) random.seed(seed)
results = [] 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: for show in shows:
# On regroupe tous les gens ayant le même rang # On regroupe tous les gens ayant le même rang
groups = dict([(i, []) for i in range(1, self.max_group + 1)]) groups = dict([(i, []) for i in range(1, self.max_group + 1)])

View file

@ -1,5 +1,7 @@
# coding: utf-8 # coding: utf-8
from __future__ import division
from django.contrib.auth.models import User from django.contrib.auth.models import User
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
@ -49,13 +51,13 @@ def etat_places(request, tirage_id):
spectacles_dict[spectacle["spectacle"]].total += spectacle["total"] spectacles_dict[spectacle["spectacle"]].total += spectacle["total"]
spectacles_dict[spectacle["spectacle"]].ratio = \ spectacles_dict[spectacle["spectacle"]].ratio = \
spectacles_dict[spectacle["spectacle"]].total / \ spectacles_dict[spectacle["spectacle"]].total / \
float(spectacles_dict[spectacle["spectacle"]].slots) spectacles_dict[spectacle["spectacle"]].slots
total += spectacle["total"] total += spectacle["total"]
for spectacle in spectacles2: for spectacle in spectacles2:
spectacles_dict[spectacle["spectacle"]].total += 2*spectacle["total"] spectacles_dict[spectacle["spectacle"]].total += 2*spectacle["total"]
spectacles_dict[spectacle["spectacle"]].ratio = \ spectacles_dict[spectacle["spectacle"]].ratio = \
spectacles_dict[spectacle["spectacle"]].total / \ spectacles_dict[spectacle["spectacle"]].total / \
float(spectacles_dict[spectacle["spectacle"]].slots) spectacles_dict[spectacle["spectacle"]].slots
total += spectacle["total"] total += spectacle["total"]
return render(request, "etat-places.html", return render(request, "etat-places.html",
{"spectacles": spectacles, "total": total, 'tirage': tirage}) {"spectacles": spectacles, "total": total, 'tirage': tirage})