Nouvelle fonctionnalité : nombre d'IPs libres dans le pool DHCP pour chaque résidence dans la page de statistiques.

This commit is contained in:
Yohan Bataille 2014-09-10 19:14:54 +02:00
parent 3d3249f7ab
commit 53ac78d4ae
3 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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 + "))")

View File

@ -27,6 +27,10 @@
<div py:for="residence in residences">
<span class="section_name show_section_name">${residence}</span>
<div>
<div>
<div class="room_number vide_color">${"%03d" % free_ips_in_dhcp_pool[residence]}</div>
<span>IPs libres</span>
</div>
<div>
<div class="room_number ok_color">${"%03d" % members_stats[residence]['number_of_cotisation_paid_members']}</div>
<span>Cotisations à jour</span>