From f8b7248175d1e046d725531ef4df93c75b10e6c7 Mon Sep 17 00:00:00 2001 From: Dorian Lesbre <dorian.lesbre@gmail.com> Date: Tue, 16 Mar 2021 18:48:43 +0100 Subject: [PATCH] Beautify activity page --- home/models.py | 18 ++++++++++++++++-- home/static/css/style.css | 5 +++-- home/templates/activites.html | 9 +++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/home/models.py b/home/models.py index 0dd8207..e8522cc 100644 --- a/home/models.py +++ b/home/models.py @@ -65,8 +65,22 @@ class InterludesActivity(models.Model): @property def nb_participants(self) -> str: if self.max_participants == 0: - return "Illimité" - return "{} - {}".format(self.min_paricipants, self.max_participants) + ret = "Illimités" + else: + ret = "{} - {}".format(self.min_participants, self.max_participants) + if self.must_subscribe: + ret += " (sur inscription)" + return ret + + @property + def pretty_duration(self) -> str: + hours, rem = divmod(self.duration.seconds, 3600) + minutes = "{:02}".format(rem // 60) if rem // 60 else "" + return "{}h{}".format(hours, minutes) + + @property + def pretty_type(self) -> str: + return self.Types(self.act_type).label def __str__(self): return self.title diff --git a/home/static/css/style.css b/home/static/css/style.css index 47c2ae6..f191d57 100644 --- a/home/static/css/style.css +++ b/home/static/css/style.css @@ -201,10 +201,11 @@ main a:link { dl { list-style: none; display: grid; - grid-template-columns: 1fr 4fr; + grid-template-columns: auto auto; + justify-content: left; + padding-left: 10px; } dl dt { - grid-column: 1 / span 1; justify-self: end; text-align: right; font-weight: bold; diff --git a/home/templates/activites.html b/home/templates/activites.html index a5170b6..8d9ee0d 100644 --- a/home/templates/activites.html +++ b/home/templates/activites.html @@ -98,11 +98,12 @@ {% for activity in activities %} <h3 id="act-{{ activity.id }}"">{{ activity.title }}</h3> + {{ activity.html_display }} <dl> - <dt>Durée :</dt><dd>{{ activity.duration }}</dd> - <dt>MJ :</dt><dd>{{ activity.host_name }}</dd> - <dt>Nombre de places :</dt><dd>{{ activity.nb_participants }}</dd> - <dt>Sur inscription :</dt><dd>{% if activity.must_subscribe %} Oui {% else %} Non {% endif %}</dd> + <dt>Durée :</dt><dd>{{ activity.pretty_duration }}</dd> + <dt>Orga :</dt><dd>{{ activity.host_name }}</dd> + <dt>Type :</dt><dd>{{ activity.pretty_type }}</dd> + <dt>Places :</dt><dd>{{ activity.nb_participants }}</dd> <dt>Description :</dt><dd>{{ activity.description|linebreaksbr }}</dd> </dl> {% endfor %} -- GitLab