aboutsummaryrefslogtreecommitdiff
path: root/templatetags
diff options
context:
space:
mode:
authorAlban Gruin2019-08-29 17:19:12 +0200
committerAlban Gruin2019-08-30 13:56:36 +0200
commit5045af42503158db4155988f00ee0db0a6a67ff7 (patch)
treefd9afd7e8f0b26f3cbb26b41b771fe8f577a4098 /templatetags
parent0717c8ccd6ac10989d86593ff73a86a0c4398408 (diff)
templatetags/rooms: correction du nom brut des salles
Les salles et amphis commencent maintenant par leur département, de cette manière : FSI / Amphi FERMAT (bat.1A) Au lieu de : Amphi FERMAT (bat.1A) Cela ne fait que rajouter du bruit sur la page. Ceci modifie le filtre de formatage des salles pour retirer le département si il est présent. Signed-off-by: Alban Gruin <alban at pa1ch dot fr>
Diffstat (limited to 'templatetags')
-rw-r--r--templatetags/rooms.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/templatetags/rooms.py b/templatetags/rooms.py
index f0e1b2e..d8b0e23 100644
--- a/templatetags/rooms.py
+++ b/templatetags/rooms.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2017 Alban Gruin
+# Copyright (C) 2017, 2019 Alban Gruin
#
# celcatsanitizer is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
@@ -18,11 +18,17 @@ from django import template
register = template.Library()
+def __filter_room_name(name):
+ if '/' in name:
+ return name.split('/')[1].strip()
+ return name
+
+
@register.filter
def format_rooms(rooms):
- 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")]
+ names = [__filter_room_name(room.name) for room in rooms]
+ amphi_list = [name for name in names if name.startswith("Amphi")]
+ room_list = [name for name in names if not name.startswith("Amphi")]
amphis = ", ".join(amphi_list)
joined = ", ".join(room_list)