From 1675d1e102685d731c3d79053af4c3545368fbe4 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Fri, 28 Nov 2025 21:10:02 +0100 Subject: [PATCH] =?UTF-8?q?Action=20et=20affichage=20pour=20r=C3=A9p=C3=A9?= =?UTF-8?q?titions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beesgospel/admin.py | 23 +++++++++++++++++++++++ beesgospel/static/css/main.css | 15 +++++++++++++++ templates/agenda.html | 6 +++--- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/beesgospel/admin.py b/beesgospel/admin.py index a7fc1f2..7ab96b6 100644 --- a/beesgospel/admin.py +++ b/beesgospel/admin.py @@ -1,15 +1,38 @@ +import datetime +from zoneinfo import ZoneInfo + from django.contrib import admin from django.contrib.auth.admin import UserAdmin from beesgospel.models import Agenda, Chant, ChantDoc, Document, Membre, User +@admin.action(description="Générer répétition des 3 prochains mois") +def gen_repets(modeladmin, request, queryset): + next_wedn = datetime.date.today() + while next_wedn.isoweekday() != 3: + next_wedn += datetime.timedelta(days=1) + for i in range(12): + if not Agenda.objects.filter( + statut=Agenda.Statuts.REPETITION, date_heure__date=next_wedn + ).exists(): + Agenda.objects.create( + titre="Répétition", lieu="Temple Saint-Jean", + date_heure=datetime.datetime.combine( + next_wedn, datetime.time(18, 30), tzinfo=ZoneInfo("Europe/Zurich") + ), + statut=Agenda.Statuts.REPETITION, + ) + next_wedn += datetime.timedelta(days=7) + + @admin.register(Agenda) class AgendaAdmin(admin.ModelAdmin): list_display = ["titre", "lieu", "date_heure", "statut"] ordering = ["-date_heure"] search_fields = ["titre", "lieu"] date_hierarchy = "date_heure" + actions = [gen_repets] @admin.register(Document) diff --git a/beesgospel/static/css/main.css b/beesgospel/static/css/main.css index e7e4afe..71cd688 100644 --- a/beesgospel/static/css/main.css +++ b/beesgospel/static/css/main.css @@ -108,10 +108,25 @@ tr.editable:hover .edit-button, tr.editable:hover .delete-button { display: inli .agenda_line > div { text-align: center !important; margin-top: 1em !important; } } .date_agenda { background-color: #ddd; text-decoration: none; } +.titre_agenda { font-size: 1.5rem; } .prive { background-image: linear-gradient(45deg, #333333 41.67%, #6b0c0c 41.67%, #6b0c0c 50%, #333333 50%, #333333 91.67%, #6b0c0c 91.67%, #6b0c0c 100%); background-size: 33.94px 33.94px; } +.repet { + background-color: #4b2f11; +} +.repet .date_agenda { + background-color: #c2a07b; + padding-top: 0 !important; padding-bottom: 0 !important; +} +.repet .titre_agenda { + color: #c2a07b; + font-size: 1.2rem; + font-style: italic; +} +.repet .lieu_agenda { color: #c2a07b; } + .infos_internes { color: red; font-style: italic; diff --git a/templates/agenda.html b/templates/agenda.html index d0fd62d..f6ffc67 100644 --- a/templates/agenda.html +++ b/templates/agenda.html @@ -6,14 +6,14 @@

Agenda des prochaines prestations de la chorale

{% for item in object_list %} -
+
{{ item.date_heure|date:'D d F à H:i' }}
-
{{ item.titre }}
+
{{ item.titre }}{% if item.statut == 'repet' %} - {{ item.lieu }}{% endif %}
-
{{ item.lieu }}
+ {% if item.statut != 'repet' %}
{{ item.lieu }}
{% endif %} {% if item.infos %}
{{ item.infos }}
{% endif %} {% if item.infos_internes and user.is_authenticated %}
{{ item.infos_internes }}