From 53ac78d4ae23783137a1b5bd2c02e603213a8e2f Mon Sep 17 00:00:00 2001 From: Yohan Bataille Date: Wed, 10 Sep 2014 19:14:54 +0200 Subject: [PATCH] =?UTF-8?q?Nouvelle=20fonctionnalit=C3=A9=20:=20nombre=20d?= =?UTF-8?q?'IPs=20libres=20dans=20le=20pool=20DHCP=20pour=20chaque=20r?= =?UTF-8?q?=C3=A9sidence=20dans=20la=20page=20de=20statistiques.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Brie/brie/controllers/stats.py | 7 ++++++- Brie/brie/model/ldap.py | 8 ++++++++ Brie/brie/templates/stats/index.html | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Brie/brie/controllers/stats.py b/Brie/brie/controllers/stats.py index b3bc636..2b0c828 100644 --- a/Brie/brie/controllers/stats.py +++ b/Brie/brie/controllers/stats.py @@ -22,6 +22,7 @@ class StatsController(AuthenticatedBaseController): rooms_stats = dict() members_stats = dict() total_earned = dict() + free_ips_in_dhcp_pool = dict() average_cotisation = dict() global_average_cotisation = 0 global_total_earned = 0 @@ -44,6 +45,9 @@ class StatsController(AuthenticatedBaseController): for room in Room.get_rooms(self.user, residence_dn): if not room.has("x-memberIn"): rooms_stats[residence_name]['empty_rooms'].append(room) + + free_ips_in_dhcp_pool[residence_name] = len(IpReservation.get_all_free(self.user, residence_dn)) + # FIXME : Vérifier si on compte les "extras" (vente de câbles). Il ne faudrait pas les compter. all_payments = Cotisation.get_all_payment_by_year(self.user, residence_dn, year) total_earned[residence_name] = 0 @@ -77,7 +81,8 @@ class StatsController(AuthenticatedBaseController): "average_cotisation" : average_cotisation, "global_total_earned" : global_total_earned, "global_current_members" : global_current_members, - "global_average_cotisation" : global_average_cotisation + "global_average_cotisation" : global_average_cotisation, + "free_ips_in_dhcp_pool" : free_ips_in_dhcp_pool } #end def #end class diff --git a/Brie/brie/model/ldap.py b/Brie/brie/model/ldap.py index ff055e4..4688a95 100644 --- a/Brie/brie/model/ldap.py +++ b/Brie/brie/model/ldap.py @@ -314,6 +314,14 @@ class IpReservation: return results #end def + @staticmethod + def get_all_free(user_session, residence_dn): + results = user_session.ldap_bind.search(ldap_config.ip_reservation_base_dn + residence_dn, "(&(objectClass=auroreIpReservation)(!(x-taken=*)))") + + return results + #end def + + @staticmethod def get_ip(user_session, residence_dn, ip): results = user_session.ldap_bind.search_first(ldap_config.ip_reservation_base_dn + residence_dn, "(&(objectClass=auroreIpReservation)(cn=" + ip + "))") diff --git a/Brie/brie/templates/stats/index.html b/Brie/brie/templates/stats/index.html index 30c8985..3f88368 100644 --- a/Brie/brie/templates/stats/index.html +++ b/Brie/brie/templates/stats/index.html @@ -27,6 +27,10 @@
${residence}
+
+
${"%03d" % free_ips_in_dhcp_pool[residence]}
+ IPs libres +
${"%03d" % members_stats[residence]['number_of_cotisation_paid_members']}
Cotisations à jour