fixed sorting (was incomplete and broken in previous commit)

This commit is contained in:
Yohan Bataille 2013-03-30 19:59:59 +01:00
parent e25a90aef1
commit 9c147d6f51
3 changed files with 5 additions and 10 deletions

View File

@ -12,9 +12,6 @@ from brie.model.ldap import *
from brie.controllers import auth
from brie.controllers.auth import AuthenticatedBaseController, AuthenticatedRestController
from operator import itemgetter
class RoomsController(AuthenticatedBaseController):
require_group = groups_enum.admin
@ -38,10 +35,10 @@ class RoomsController(AuthenticatedBaseController):
#end def
def reverse_sort_name(self, name_items):
return sorted(name_items, key=itemgetter(0), reverse=True)
return sorted(name_items, key=lambda t:t[0].cn.first(), reverse=True)
def sort_name(self, name_items):
return sorted(name_items, key=itemgetter(0))
return sorted(name_items, key=lambda t:t[0].cn.first())
@expose("brie.templates.rooms.index")
def index(self, residence_name):
@ -54,7 +51,7 @@ class RoomsController(AuthenticatedBaseController):
#end if
for area in Room.get_areas(self.user, residence_dn):
areas[area] = list()
areas[area] = dict()
for floor in Room.get_floors(self.user, area.dn):
areas[area][floor] = list()
@ -71,9 +68,7 @@ class RoomsController(AuthenticatedBaseController):
#end if
#end for room
areas[area][floor] = sorted(areas[area][floor], key=lambda r:r.cn.first())
#end for floor
areas[area] = sorted(areas[area].items(), key=lambda t:t[0])
#end for area
return {

View File

@ -49,7 +49,7 @@
<span class="section_name">${("Aile " + 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 rooms" class="room_number">
<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>
</div>

View File

@ -17,7 +17,7 @@ error_email_from = paste@localhost
[server:main]
use = egg:Paste#http
host = 0.0.0.0
port = 9010
port = 9004
[app:main]
use = egg:Brie