From 943742ed545ef7c3597202390cb28b7908447f95 Mon Sep 17 00:00:00 2001 From: Yohan Bataille Date: Fri, 24 Jan 2014 23:01:03 +0100 Subject: [PATCH] =?UTF-8?q?En=20faisant=20un=20hg=20add=20c'est=20mieux?= =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Brie/brie/controllers/getemails.py | 56 ++++++++++++++++ Brie/brie/controllers/stats.py | 56 ++++++++++++++++ Brie/brie/templates/getemails/__init__.py | 0 Brie/brie/templates/getemails/index.html | 47 +++++++++++++ Brie/brie/templates/stats/__init__.py | 0 Brie/brie/templates/stats/index.html | 81 +++++++++++++++++++++++ 6 files changed, 240 insertions(+) create mode 100644 Brie/brie/controllers/getemails.py create mode 100644 Brie/brie/controllers/stats.py create mode 100644 Brie/brie/templates/getemails/__init__.py create mode 100644 Brie/brie/templates/getemails/index.html create mode 100644 Brie/brie/templates/stats/__init__.py create mode 100644 Brie/brie/templates/stats/index.html diff --git a/Brie/brie/controllers/getemails.py b/Brie/brie/controllers/getemails.py new file mode 100644 index 0000000..41ba272 --- /dev/null +++ b/Brie/brie/controllers/getemails.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +from tg import session +from tg.controllers import redirect +from tg.decorators import expose, validate + +from brie.config import ldap_config +from brie.lib.ldap_helper import * +from brie.lib.aurore_helper import * +from brie.model.ldap import * + +from brie.controllers import auth +from brie.controllers.auth import AuthenticatedBaseController, AuthenticatedRestController + +from operator import itemgetter + +class GetEmailsController(AuthenticatedBaseController): + + @expose("brie.templates.getemails.index") + def index(self): + residences = [] + rooms_stats = dict() + members_stats = dict() + residences_ldap = Residences.get_residences(self.user) + 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]['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']) + members_stats[residence_name]['number_of_old_members'] = len(members_stats[residence_name]['old_members']) + members_stats[residence_name]['number_of_current_members'] = members_stats[residence_name]['number_of_cotisation_paid_members'] + members_stats[residence_name]['number_of_cotisation_late_members'] + members_stats[residence_name]['number_of_no_cotisation_members'] + rooms_stats[residence_name] = dict() + rooms_stats[residence_name]['number_of_rooms'] = Room.get_number_of_rooms(self.user, residence_dn) + rooms_stats[residence_name]['empty_rooms'] = [] + for room in Room.get_rooms(self.user, residence_dn): + if not room.has("x-memberIn"): + rooms_stats[residence_name]['empty_rooms'].append(room) + + residence = None + if self.user is not None: + residence = Residences.get_name_by_dn(self.user, self.user.residence_dn) + #end if + + return { + "user" : self.user, + "residence" : residence, + "residences" : residences, + "rooms_stats" : rooms_stats, + "members_stats" : members_stats + } + #end def +#end class + diff --git a/Brie/brie/controllers/stats.py b/Brie/brie/controllers/stats.py new file mode 100644 index 0000000..7ead8e5 --- /dev/null +++ b/Brie/brie/controllers/stats.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +from tg import session +from tg.controllers import redirect +from tg.decorators import expose, validate + +from brie.config import ldap_config +from brie.lib.ldap_helper import * +from brie.lib.aurore_helper import * +from brie.model.ldap import * + +from brie.controllers import auth +from brie.controllers.auth import AuthenticatedBaseController, AuthenticatedRestController + +from operator import itemgetter + +class StatsController(AuthenticatedBaseController): + + @expose("brie.templates.stats.index") + def index(self): + residences = [] + rooms_stats = dict() + members_stats = dict() + residences_ldap = Residences.get_residences(self.user) + 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]['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']) + members_stats[residence_name]['number_of_old_members'] = len(members_stats[residence_name]['old_members']) + members_stats[residence_name]['number_of_current_members'] = members_stats[residence_name]['number_of_cotisation_paid_members'] + members_stats[residence_name]['number_of_cotisation_late_members'] + members_stats[residence_name]['number_of_no_cotisation_members'] + rooms_stats[residence_name] = dict() + rooms_stats[residence_name]['number_of_rooms'] = Room.get_number_of_rooms(self.user, residence_dn) + rooms_stats[residence_name]['empty_rooms'] = [] + for room in Room.get_rooms(self.user, residence_dn): + if not room.has("x-memberIn"): + rooms_stats[residence_name]['empty_rooms'].append(room) + + residence = None + if self.user is not None: + residence = Residences.get_name_by_dn(self.user, self.user.residence_dn) + #end if + + return { + "user" : self.user, + "residence" : residence, + "residences" : residences, + "rooms_stats" : rooms_stats, + "members_stats" : members_stats + } + #end def +#end class + diff --git a/Brie/brie/templates/getemails/__init__.py b/Brie/brie/templates/getemails/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Brie/brie/templates/getemails/index.html b/Brie/brie/templates/getemails/index.html new file mode 100644 index 0000000..12f48d5 --- /dev/null +++ b/Brie/brie/templates/getemails/index.html @@ -0,0 +1,47 @@ + + + + + + + + +
+ Adresses mails des adhérents de ${residence} + +
+ + diff --git a/Brie/brie/templates/stats/__init__.py b/Brie/brie/templates/stats/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Brie/brie/templates/stats/index.html b/Brie/brie/templates/stats/index.html new file mode 100644 index 0000000..65df8e2 --- /dev/null +++ b/Brie/brie/templates/stats/index.html @@ -0,0 +1,81 @@ + + + + + + + + +
+
+ ${residence} +
+
+
${"%03d" % members_stats[residence]['number_of_cotisation_paid_members']}
+ Cotisations à jour +
+
+
${"%03d" % members_stats[residence]['number_of_cotisation_late_members']}
+ Cotisations en retard +
+
+
${"%03d" % members_stats[residence]['number_of_no_cotisation_members']}
+ Sans cotisations +
+
+
${"%03d" % members_stats[residence]['number_of_current_members']}
+ Adhérents actuels +
+ + +
+
+
+
${"%03d" % members_stats[residence]['number_of_old_members']}
+ Anciens membres +
+
+
${"%03d" % rooms_stats[residence]['number_of_rooms']}
+ Pièces +
+
+
${"%03d" % len(rooms_stats[residence]['empty_rooms'])}
+ Pièces vides +
+ +
+
+ + +
+ +