From 256fed1e2e52ff9af8718357b5e2b6e0aacc4f28 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Fri, 29 Nov 2024 00:01:48 +0100 Subject: [PATCH] =?UTF-8?q?les=20param=C3=A8tres=20de=20r=C3=A9currence=20?= =?UTF-8?q?ne=20sont=20affich=C3=A9s=20que=20s'ils=20existent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cf #224 --- src/agenda_culturel/forms.py | 9 ++++++++- .../templates/agenda_culturel/forms/div_group.html | 12 ++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/agenda_culturel/forms.py b/src/agenda_culturel/forms.py index 3cb16c9..f93b4db 100644 --- a/src/agenda_culturel/forms.py +++ b/src/agenda_culturel/forms.py @@ -254,7 +254,14 @@ class EventForm(GroupFormMixin, ModelForm): self.fields['end_day'].group_id = 'end' self.fields['end_time'].group_id = 'end' - self.add_group('recurrences', _('This is a recurring event'), maskable=True, default_masked=True) + self.add_group('recurrences', + _('This is a recurring event'), + maskable=True, + default_masked=not (self.instance and + self.instance.recurrences and + self.instance.recurrences.rrules and + len(self.instance.recurrences.rrules) > 0)) + self.fields['recurrences'].group_id = 'recurrences' self.add_group('details', _('Details')) diff --git a/src/agenda_culturel/templates/agenda_culturel/forms/div_group.html b/src/agenda_culturel/templates/agenda_culturel/forms/div_group.html index 969e31f..43d7257 100644 --- a/src/agenda_culturel/templates/agenda_culturel/forms/div_group.html +++ b/src/agenda_culturel/templates/agenda_culturel/forms/div_group.html @@ -6,7 +6,13 @@ {% for group, fields in form.fields_by_group %}
{% if group.maskable %} - + {% endif %}
{% for field in fields %} @@ -36,7 +42,9 @@