From c743de013b652a642a697a00a7d3732ba8774425 Mon Sep 17 00:00:00 2001 From: Romain Beuque Date: Fri, 3 Oct 2014 12:40:17 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20du=20retour=20en=20arri=C3=A8re=20dans?= =?UTF-8?q?=20les=20ann=C3=A9es=20dans=20la=20page=20stats=20Aurore=20+=20?= =?UTF-8?q?blocage=20de=20la=20page=20quand=20on=20est=20pas=20dans=20la?= =?UTF-8?q?=20r=C3=A9sidence=20"Aurore"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Brie/brie/controllers/stats.py | 19 ++++++++++++++++--- Brie/brie/templates/stats/index.html | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Brie/brie/controllers/stats.py b/Brie/brie/controllers/stats.py index 2b0c828..305663b 100644 --- a/Brie/brie/controllers/stats.py +++ b/Brie/brie/controllers/stats.py @@ -17,7 +17,7 @@ from operator import itemgetter class StatsController(AuthenticatedBaseController): @expose("brie.templates.stats.index") - def index(self): + def index(self, year = None): residences = [] rooms_stats = dict() members_stats = dict() @@ -28,12 +28,24 @@ class StatsController(AuthenticatedBaseController): global_total_earned = 0 global_current_members = 0 residences_ldap = Residences.get_residences(self.user) - year = CotisationComputes.current_year() + + #on restreint l'acces a la page stats pour les membres Aurore + for residence_ldap in residences_ldap: + if residence_ldap.uniqueMember.first() == self.user.residence_dn and residence_ldap.cn.first() != "Aurore": + raise Exception("acces refuse") + #end if + #end for + + if year is None: + year = CotisationComputes.current_year() for residence_ldap in residences_ldap: residence_dn = residence_ldap.uniqueMember.first() residence_name = residence_ldap.cn.first() residences.append(residence_name) - members_stats[residence_name] = CotisationComputes.members_status_from_residence(self.user, residence_dn) + #members_stats[residence_name] = CotisationComputes.members_status_from_residence(self.user, residence_dn) + cotisations_year = Cotisation.get_all_cotisation_by_year(self.user, residence_dn, year) + members_stats[residence_name] = CotisationComputes.members_status_from_list_cotisations(self.user, residence_dn, cotisations_year) + members_stats[residence_name]['number_of_cotisation_paid_members'] = len(members_stats[residence_name]['cotisation_paid_members']) members_stats[residence_name]['number_of_cotisation_late_members'] = len(members_stats[residence_name]['cotisation_late_members']) members_stats[residence_name]['number_of_no_cotisation_members'] = len(members_stats[residence_name]['no_cotisation_members']) @@ -74,6 +86,7 @@ class StatsController(AuthenticatedBaseController): return { "user" : self.user, "residence" : residence, + "year" : int(year), "residences" : residences, "rooms_stats" : rooms_stats, "members_stats" : members_stats, diff --git a/Brie/brie/templates/stats/index.html b/Brie/brie/templates/stats/index.html index 3f88368..901a69a 100644 --- a/Brie/brie/templates/stats/index.html +++ b/Brie/brie/templates/stats/index.html @@ -6,6 +6,7 @@ + Année précédente | année scolaire ${year-1}/${year} | Année suivante
Globalement