correction erreur dans les anniversary_cotisation + affichage du code couleur sur les chambres

This commit is contained in:
Romain Beuque 2014-02-15 16:35:40 +01:00
parent 7f683c64e0
commit fe3631a894
3 changed files with 47 additions and 6 deletions

View File

@ -50,8 +50,17 @@ class RoomsController(AuthenticatedBaseController):
raise Exception("unknown residence")
#end if
stats = CotisationComputes.members_status_from_residence(self.user, residence_dn)
members = dict()
for label in stats:
for member in stats[label]:
members[member.dn] = label
#end for member
#end for stats
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()
@ -59,9 +68,15 @@ class RoomsController(AuthenticatedBaseController):
areas[area][floor] = list()
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)
room.add('status', "empty_room")
elif room.get("x-memberIn").first() in members:
room.add('status', members[room.get("x-memberIn").first()])
#endif
areas[area][floor].append(room)
color = self.color_picker("foobar")
if color in status:

View File

@ -99,11 +99,11 @@ class CotisationComputes:
@staticmethod
def anniversary_from_ldap_items(ldap_cotisations):
result = []
months = []
for cotisation in ldap_cotisations:
anniversary_data = cotisation.get("x-time").first()
anniversary_datetime = datetime.datetime.strptime(anniversary_data,
"%Y-%m-%d %H:%M:%S.%f")
months = []
for month in cotisation.get("x-validMonth").all():
months.append(int(month))
#end for
@ -116,7 +116,6 @@ class CotisationComputes:
if result != []:
anniversary_day = result[0][0].day
months = result[0][1]
SORT_ORDER = {9: 0, 10: 1, 11: 2, 12: 3, 1: 4, 2: 5, 3: 6, 4: 7, 5: 8, 6: 9, 7: 10, 8: 11}
months.sort(key=lambda val: SORT_ORDER[val])
anniversary_month = months[-1] + 1

View File

@ -21,10 +21,16 @@
<div>
<div class="room_number non_certif_color">${"%03d" % len(stats['cotisation_late_members'])}</div>
<span>Cotisations en retard</span>
<div py:for="member in stats['cotisation_late_members']">
<span><a href="/show/member/${residence}/${member.uid.first()}">${member.cn.first()}</a></span><br />
</div>
</div>
<div>
<div class="room_number non_paye_color">${"%03d" % len(stats['no_cotisation_members'])}</div>
<span>Sans cotisations</span>
<div py:for="member in stats['no_cotisation_members']">
<span><a href="/show/member/${residence}/${member.uid.first()}">${member.cn.first()}</a></span><br />
</div>
</div>
<div>
<div class="room_number vide_color">${"%03d" % len(stats['old_members'])}</div>
@ -59,9 +65,30 @@
<span class="section_name">${(area.cn.first()).upper()}</span>
<div py:for="floor, rooms in reverse_sorted_name(floors.iteritems())" class="floor">
<span class="floor_name">étage ${floor.cn.first()}</span>
<div py:for="room in sorted(rooms, key=lambda t:t.cn.first())" class="room_number">
<a href="/rooms/preview/${residence}/${room.uid.first()}"><span>${room.cn.first()}</span></a>
</div>
<py:for each="room in sorted(rooms, key=lambda t:t.cn.first())" class="room_number">
<py:choose test="room.status.first()">
<py:when test="'cotisation_paid_members'">
<div class="room_number ok_color">
<a href="/rooms/preview/${residence}/${room.uid.first()}"><span>${room.cn.first()}</span></a>
</div>
</py:when>
<py:when test="'cotisation_late_members'">
<div class="room_number non_certif_color">
<a href="/rooms/preview/${residence}/${room.uid.first()}"><span>${room.cn.first()}</span></a>
</div>
</py:when>
<py:when test="'no_cotisation_members'">
<div class="room_number non_paye_color">
<a href="/rooms/preview/${residence}/${room.uid.first()}"><span>${room.cn.first()}</span></a>
</div>
</py:when>
<py:otherwise>
<div class="room_number vide_color">
<a href="/rooms/preview/${residence}/${room.uid.first()}"><span>${room.cn.first()}</span></a>
</div>
</py:otherwise>
</py:choose>
</py:for>
</div>
</div>
</div>