From cf1ce5ede133f3326407088862db55f710d446c3 Mon Sep 17 00:00:00 2001 From: Dorian Lesbre <dorian.lesbre@gmail.com> Date: Mon, 29 Mar 2021 16:45:43 +0200 Subject: [PATCH] Fix time display for multiple activities --- home/models.py | 10 ++++++++++ home/templates/activites.html | 7 +++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/home/models.py b/home/models.py index 7220086..ab90b2c 100644 --- a/home/models.py +++ b/home/models.py @@ -122,6 +122,16 @@ class InterludesActivity(models.Model): id = self.canonical.id return "act-{}".format(id) + @property + def times_and_places(self) -> str: + """Returns a list of start times and place related to self + (check canonical links for multiple timetable, + only displays if on_planning is true)""" + objects = InterludesActivity.objects.filter( + models.Q(id=self.id) | models.Q(canonical=self) + ).filter(on_planning=True).values("start", "room").order_by("start") + return objects + def conflicts(self, other: "InterludesActivity") -> bool: """Check whether these activites overlap""" if self.end is None or other.end is None: diff --git a/home/templates/activites.html b/home/templates/activites.html index fe74bbe..492eba9 100644 --- a/home/templates/activites.html +++ b/home/templates/activites.html @@ -104,8 +104,11 @@ <dt>Orga :</dt><dd>{{ activity.host_name }}</dd> <dt>Type :</dt><dd>{{ activity.pretty_type }}</dd> <dt>Places :</dt><dd>{{ activity.nb_participants }}</dd> - {% if activity.start and activity.room %} - <dt>Heure/Lieu :</dt><dd>{{ activity.start|date:"l à H:i"|capfirst }} en {{ activity.room }}</dd> + {% if activity.times_and_places %} + <dt>Heure/Lieu :</dt><dd>{% for act in activity.times_and_places %} + {{ act.start|date:"l H:i" }} {{ act.room }}{% if not forloop.last %}, {% endif %} + {% endfor %} + </dd> {% endif %} <dt>Description :</dt> </dl> -- GitLab