Page de statistiques pour le moment réservée à Aurore : à généraliser pour les autres associations et pouvoir utiliser comme un bloc dans d'autres pages (membres, pièces, etc). C'est horriblement lent mais l'optimisation viendra plus tard. Ce code a été insuffisamment testé pour le moment : NE PAS DÉPLOYER EN PRODUCTION.

This commit is contained in:
Yohan Bataille 2014-01-24 22:19:22 +01:00
parent 93362f4f3c
commit f3ccf6d06c
8 changed files with 37 additions and 24 deletions

View File

@ -42,14 +42,16 @@ class RoomsController(AuthenticatedBaseController):
@expose("brie.templates.rooms.index")
def index(self, residence_name):
stats = dict()
status = dict()
areas = dict()
residence_dn = Residences.get_dn_by_name(self.user, residence_name)
if residence_dn is None:
raise Exception("unknown residence")
#end if
status = CotisationComputes.members_status_from_residence(self.user, residence_dn)
stats = CotisationComputes.members_status_from_residence(self.user, residence_dn)
stats['number_of_rooms'] = Room.get_number_of_rooms(self.user, residence_dn)
stats['empty_rooms'] = []
for area in Room.get_areas(self.user, residence_dn):
areas[area] = dict()
@ -58,13 +60,14 @@ class RoomsController(AuthenticatedBaseController):
for room in Room.get_rooms_of_floor(self.user, floor.dn):
areas[area][floor].append(room)
if not room.has("x-memberIn"):
stats['empty_rooms'].append(room)
color = self.color_picker("foobar")
if color in stats:
stats[color] = stats[color] + 1
if color in status:
status[color] = status[color] + 1
else:
stats[color] = 0
status[color] = 0
#end if
#end for room

View File

@ -21,6 +21,7 @@ from brie.controllers.show import ShowController
from brie.controllers.search import SearchController
from brie.controllers.edit import EditController
from brie.controllers.administration import AdministrationController
from brie.controllers.stats import StatsController
from brie.controllers.error import ErrorController
from brie.controllers.registration import RegistrationController
from brie.controllers.treasury import TreasuryController
@ -52,6 +53,7 @@ class RootController(BaseController):
show = ShowController()
edit = EditController(show)
administration = AdministrationController()
stats = StatsController()
error = ErrorController()
search = SearchController()
registration = RegistrationController(edit)

View File

@ -55,11 +55,9 @@ def disconnect_members_job():
residences = Residences.get_residences(user)
for residence in residences:
print "Disconnect job on : " + residence.uniqueMember.first()
disconnect_members_from_residence(
user, residence.uniqueMember.first())
disconnect_members_from_residence(user, residence.uniqueMember.first())
#end for
# user.ldap_bind.disconnect()

View File

@ -92,6 +92,11 @@ class Room(object):
return user_session.ldap_bind.search(ldap_config.room_base_dn + residence_dn, "(objectClass=pacaterieRoom)")
#end def
@staticmethod
def get_number_of_rooms(user_session, residence_dn):
return len(Room.get_rooms(user_session, residence_dn))
#end def
#end class

View File

@ -12,7 +12,7 @@
<form action="/auth/login" method="post">
<p class="error">${error}</p>
<div>
<span class="item_name">Résidence</span>
<span class="item_name">Domaine</span>
<select name="residence">
<option value=""></option>
<py:for each="residence in residences">

View File

@ -10,12 +10,12 @@
<div class="navbar-inner">
<a class="brand" href="/">Brie d'Aurore</a>
<ul class="nav">
<li py:if="user.groups.admin"><a href="/rooms/index/${residence}">CHAMBRES</a></li>
<li py:if="user.groups.admin"><a href="/rooms/index/${residence}">PIÈCES</a></li>
<li py:if="user.groups.admin"><a href="/members/index/${residence}">MEMBRES</a></li>
<li py:if="user.groups.admin"><a href="/registration/">INSCRIPTION</a></li>
<li py:if="user.groups.tresorier"><a href="/treasury/">TRESORIE</a></li>
<li py:if="user.groups.tresorier"><a href="/treasury/">TRÉSORIE</a></li>
<li py:if="user.groups.responsablereseau"><a href="/administration/">ADMINISTRATION</a></li>
<li py:if="user.residence_dn == 'dc=aurore,dc=u-psud,dc=fr'"><a href="/stats/">STATISTIQUES</a></li>
</ul>
</div>
</div>

View File

@ -11,32 +11,37 @@
<xi:include href="navbar.html" />
<div class="rooms_legend">
<py:def function="display_stat(name)">
<div class="room_number ok_color">${"%03d" % stats[name]}</div>
<py:def function="display_status(name)">
<div class="room_number ok_color">${"%03d" % status[name]}</div>
</py:def>
<div>
<div class="room_number ok_color">${"%03d" % len(status['cotisation_paid_members'])}</div>
<div class="room_number ok_color">${"%03d" % len(stats['cotisation_paid_members'])}</div>
<span>Cotisations à jour</span>
</div>
<div>
<div class="room_number non_certif_color">${"%03d" % len(status['cotisation_late_members'])}</div>
<div class="room_number non_certif_color">${"%03d" % len(stats['cotisation_late_members'])}</div>
<span>Cotisations en retard</span>
</div>
<div>
<div class="room_number non_paye_color">${"%03d" % len(status['no_cotisation_members'])}</div>
<div class="room_number non_paye_color">${"%03d" % len(stats['no_cotisation_members'])}</div>
<span>Sans cotisations</span>
</div>
<div>
<div class="room_number vide_color">${"%03d" % len(status['old_members'])}</div>
<div class="room_number vide_color">${"%03d" % len(stats['old_members'])}</div>
<span>Anciens membres</span>
</div>
<div>
<div class="room_number vide_color">${"%03d" % len(status['WTF_members'])}</div>
<div class="room_number vide_color">${"%03d" % len(stats['WTF_members'])}</div>
<span>Membres WTF</span>
</div>
<div>
<!--${display_stat("vide_color")}-->
<span>Chambres vides</span>
<div class="room_number vide_color">${"%03d" % stats['number_of_rooms']}</div>
<span>Pièces</span>
</div>
<div>
<!--${display_status("vide_color")}-->
<div class="room_number vide_color">${"%03d" % len(stats['empty_rooms'])}</div>
<span>Pièces vides</span>
</div>
</div>
<div class="area section">
@ -48,7 +53,7 @@
</div>
<div class="preview_part preview_name" py:choose="member_ldap is not None">
<span py:when="True"><a href="/show/member/${residence}/${member_ldap.uid.first()}">${member_ldap.cn.first()}</a></span>
<span py:otherwise=""><a href="/show/room/${residence}/${room_preview.uid.first()}">Chambre Vide</a></span>
<span py:otherwise=""><a href="/show/room/${residence}/${room_preview.uid.first()}">Pièce Vide</a></span>
</div>
</py:with>
</div>

View File

@ -13,7 +13,7 @@
<a href="/edit/room/${room_ldap.uid.first()}" class="button">EDITER</a>
<div py:choose="room_ldap">
<span class="section_name" py:when="None">Pas de chambre associée</span>
<span class="section_name" py:when="None">Pas de pièce associée</span>
<div py:otherwise="">${room_view(room_ldap, member_ldap)}</div>
</div>
</body>