aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2017-09-08 12:32:30 +0200
committerAlban Gruin2017-09-08 12:32:30 +0200
commitb769b34de15ab37d7d97078a72045eb49d46036b (patch)
tree3d45a6bf9ee58589cf43095f84a1afb252a27506
parentee98e2d23a0d6bf449850f5dfef756bcde62909a (diff)
Le tag format_rooms rassemble les amphis et les salles ensemble
-rw-r--r--templatetags/rooms.py22
1 files 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