diff options
-rw-r--r-- | templatetags/rooms.py | 22 |
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 |