From b769b34de15ab37d7d97078a72045eb49d46036b Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Fri, 8 Sep 2017 12:32:30 +0200 Subject: Le tag format_rooms rassemble les amphis et les salles ensemble --- templatetags/rooms.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/templatetags/rooms.py b/templatetags/rooms.py index 86515a4..5108c92 100644 --- a/templatetags/rooms.py +++ b/templatetags/rooms.py @@ -19,8 +19,22 @@ register = template.Library() @register.filter def format_rooms(rooms): - joined = ", ".join([str(room) for room in rooms]) - if len(rooms) > 1: - return "Salles {0}".format(joined) + amphi_list = [room.name for room in rooms if room.name.startswith("Amphi")] + room_list = [room.name for room in rooms if not room.name.startswith("Amphi")] + + amphis = ", ".join(amphi_list) + joined = ", ".join(room_list) + + if len(room_list) > 1: + joined = "alles " + joined + elif len(room_list) == 1: + joined = "alle " + joined + + if len(amphi_list) == 0 and len(room_list) == 0: + return "" + elif len(amphi_list) == 0: + return "S" + joined + elif len(room_list) == 0: + return amphis else: - return "Salle {0}".format(joined) + return amphis + ", s" + joined -- cgit v1.2.1