From 048fbd1537ce882cb0a5b76958bda8bdfc25a9d8 Mon Sep 17 00:00:00 2001 From: Dorian Lesbre <dorian.lesbre@gmail.com> Date: Mon, 29 Mar 2021 14:31:40 +0200 Subject: [PATCH] Prettier activity displays --- home/admin.py | 2 +- home/models.py | 8 +++++++- home/static/css/style.css | 7 ++++++- home/templates/activites.html | 8 +++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/home/admin.py b/home/admin.py index d93a6c0..30e6931 100644 --- a/home/admin.py +++ b/home/admin.py @@ -24,7 +24,7 @@ class InterludesActivityAdmin(ExportCsvMixin, admin.ModelAdmin): ("min_participants", "max_participants"), "must_subscribe", "communicate_participants", - "description", + "description", "desc_as_html", "display", "room", "start", "on_planning", diff --git a/home/models.py b/home/models.py index 8c5f534..5714442 100644 --- a/home/models.py +++ b/home/models.py @@ -49,7 +49,13 @@ class InterludesActivity(models.Model): ) host_name = models.CharField("nom de l'organisateur", max_length=50) host_email = models.EmailField("email de l'organisateur") - description = models.TextField("description", max_length=2000) + description = models.TextField( + "description", max_length=2000, + help_text='Texte ou html selon la valeur de "Description HTML".\n' + ) + desc_as_html = models.BooleanField("Description au format HTML", default=False, + help_text="Assurer vous que le texte est bien formaté, cette option peut casser la page activités." + ) on_planning = models.BooleanField( "afficher sur le planning", default=False, diff --git a/home/static/css/style.css b/home/static/css/style.css index d364970..9b7d0fd 100644 --- a/home/static/css/style.css +++ b/home/static/css/style.css @@ -273,9 +273,14 @@ dl dd { justify-self: start; text-align: left; } -p.desc { +div.desc { margin-top: 0; padding: 0 10px 20px; +} +div.desc p { + margin: 0; +} +div.desc p.indent { text-indent: 25px; } diff --git a/home/templates/activites.html b/home/templates/activites.html index 04b14c1..19d8246 100644 --- a/home/templates/activites.html +++ b/home/templates/activites.html @@ -109,7 +109,13 @@ {% endif %} <dt>Description :</dt> </dl> - <p class="desc">{{ activity.description|linebreaksbr }}</p> + <div class="desc"> + {% if activity.desc_as_html %} + {{ activity.description|safe }} + {% else %} + <p class="indent">{{ activity.description|linebreaksbr }}</p> + {% endif %} + </div> {% empty %} <p>Il n'y a aucune activité pour l'instant, revenez dans quelques jour pour avoir une liste plus remplie.</p> -- GitLab