From 74fb319e699a4357cd3cb60c259a46c9be95b4d2 Mon Sep 17 00:00:00 2001 From: MizukiTemma Date: Mon, 20 Jan 2025 16:29:56 +0100 Subject: [PATCH 1/3] Offer long-term event --- integreat_cms/cms/forms/events/event_form.py | 25 +- .../cms/forms/events/recurrence_rule_form.py | 48 +--- .../cms/migrations/0112_alter_event_end.py | 56 +++++ integreat_cms/cms/models/events/event.py | 10 +- .../templates/events/_event_duration_tab.html | 22 ++ .../event_form_sidebar/date_and_time_box.html | 227 ++++++++++-------- .../cms/templates/events/event_list_row.html | 10 +- integreat_cms/locale/de/LC_MESSAGES/django.po | 97 +++++--- integreat_cms/static/src/index.ts | 1 + integreat_cms/static/src/js/event-duration.ts | 44 ++++ .../src/js/events/conditional-fields.ts | 22 -- 11 files changed, 360 insertions(+), 202 deletions(-) create mode 100644 integreat_cms/cms/migrations/0112_alter_event_end.py create mode 100644 integreat_cms/cms/templates/events/_event_duration_tab.html create mode 100644 integreat_cms/static/src/js/event-duration.ts diff --git a/integreat_cms/cms/forms/events/event_form.py b/integreat_cms/cms/forms/events/event_form.py index 3d79fcd43b..a5e64e2280 100644 --- a/integreat_cms/cms/forms/events/event_form.py +++ b/integreat_cms/cms/forms/events/event_form.py @@ -2,11 +2,10 @@ import logging import zoneinfo -from datetime import datetime, time, timedelta +from datetime import datetime, time from typing import TYPE_CHECKING from django import forms -from django.conf import settings from django.utils.translation import gettext_lazy as _ from ...constants import status @@ -48,6 +47,7 @@ class EventForm(CustomModelForm): widget=forms.DateInput(format="%Y-%m-%d", attrs={"type": "date"}), ) end_date = forms.DateField( + required=False, label=_("end date"), widget=forms.DateInput(format="%Y-%m-%d", attrs={"type": "date"}), ) @@ -61,6 +61,9 @@ class EventForm(CustomModelForm): required=False, widget=forms.TimeInput(format="%H:%M", attrs={"type": "time"}), ) + is_long_term = forms.BooleanField( + required=False, + ) class Meta: """ @@ -78,6 +81,7 @@ class Meta: "location", "external_calendar", "external_event_id", + "only_weekdays", ] #: The widgets which are used in this form widgets = { @@ -104,6 +108,7 @@ def __init__(self, **kwargs: Any) -> None: # since they will be set later in the clean method self.fields["start"].required = False self.fields["end"].required = False + self.fields["is_long_term"].initial = False if self.instance.id: # Initialize non-model fields based on event self.fields["start_date"].initial = self.instance.start_local.date() @@ -119,6 +124,8 @@ def __init__(self, **kwargs: Any) -> None: else None ) self.fields["external_event_id"].initial = self.instance.external_event_id + if not self.instance.start_local.date() == self.instance.end_local.date(): + self.fields["is_long_term"].initial = True def clean(self) -> dict[str, Any]: """ @@ -160,6 +167,9 @@ def clean(self) -> dict[str, Any]: ] == time.max.replace(second=0, microsecond=0): self.data["is_all_day"] = True + if not cleaned_data.get("is_long_term"): + cleaned_data["end_date"] = cleaned_data.get("start_date") + if (start_date := cleaned_data.get("start_date")) and ( end_date := cleaned_data.get("end_date") ): @@ -190,16 +200,7 @@ def clean(self) -> dict[str, Any]: code="invalid", ), ) - elif end_date - start_date > timedelta(settings.MAX_EVENT_DURATION - 1): - self.add_error( - "end_date", - forms.ValidationError( - _( - "The maximum duration for events is {} days. Consider using recurring events if the event is not continuous." - ).format(settings.MAX_EVENT_DURATION), - code="invalid", - ), - ) + # If everything looks good until now, combine the dates and times into timezone-aware datetimes if not self.errors: tzinfo = zoneinfo.ZoneInfo(self.instance.timezone) diff --git a/integreat_cms/cms/forms/events/recurrence_rule_form.py b/integreat_cms/cms/forms/events/recurrence_rule_form.py index f31fc79ae8..84c887acd5 100644 --- a/integreat_cms/cms/forms/events/recurrence_rule_form.py +++ b/integreat_cms/cms/forms/events/recurrence_rule_form.py @@ -21,10 +21,6 @@ class RecurrenceRuleForm(CustomModelForm): Form for creating and modifying event recurrence rule objects """ - has_recurrence_end_date = forms.BooleanField( - required=False, label=_("Recurrence ends") - ) - class Meta: """ This class contains additional meta configuration of the form class, see the :class:`django.forms.ModelForm` @@ -63,12 +59,6 @@ def __init__(self, **kwargs: Any) -> None: # Instantiate CustomModelForm super().__init__(**kwargs) - if self.instance.id: - # Initialize BooleanField based on RecurrenceRule properties - self.fields["has_recurrence_end_date"].initial = bool( - self.instance.recurrence_end_date - ) - def clean(self) -> dict[str, Any]: """ Validate form fields which depend on each other, see :meth:`django.forms.Form.clean` @@ -109,32 +99,18 @@ def clean(self) -> dict[str, Any]: ), ) - if cleaned_data.get("has_recurrence_end_date"): - if not cleaned_data.get("recurrence_end_date"): - self.add_error( - "recurrence_end_date", - forms.ValidationError( - _( - "If the recurrence ends, the recurrence end date is required" - ), - code="required", - ), - ) - elif ( - self.event_start_date - and cleaned_data.get("recurrence_end_date") <= self.event_start_date - ): - self.add_error( - "recurrence_end_date", - forms.ValidationError( - _( - "The recurrence end date has to be after the event's start date" - ), - code="invalid", - ), - ) - else: - cleaned_data["recurrence_end_date"] = None + if ( + cleaned_data.get("recurrence_end_date") + and self.event_start_date + and cleaned_data.get("recurrence_end_date") <= self.event_start_date + ): + self.add_error( + "recurrence_end_date", + forms.ValidationError( + _("The recurrence end date has to be after the event's start date"), + code="invalid", + ), + ) logger.debug( "RecurrenceRuleForm validated [2] with cleaned data %r", cleaned_data diff --git a/integreat_cms/cms/migrations/0112_alter_event_end.py b/integreat_cms/cms/migrations/0112_alter_event_end.py new file mode 100644 index 0000000000..53a9ca8730 --- /dev/null +++ b/integreat_cms/cms/migrations/0112_alter_event_end.py @@ -0,0 +1,56 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + +from django.db import migrations, models + +if TYPE_CHECKING: + from django.apps.registry import Apps + from django.db.backends.base.schema import BaseDatabaseSchemaEditor + + +# pylint: disable=unused-argument +def remove_end_date_from_existing_events( + apps: Apps, schema_editor: BaseDatabaseSchemaEditor +) -> None: + """ + Set the end date of existing events equal to start date, if they have recurrence rule. + """ + Event = apps.get_model("cms", "Event") + events = Event.objects.all() + for event in events: + if ( + not event.start.date == event.end.date + and event.recurrence_rule + and not event.recurrence_rule.recurrence_end_date + ): + event.recurrence_rule.recurrence_end_date = event.end.date + event.end = event.start + + +class Migration(migrations.Migration): + """ + Offer long-term events + """ + + dependencies = [ + ("cms", "0111_alter_language_language_color"), + ] + + operations = [ + migrations.RunPython(remove_end_date_from_existing_events), + migrations.AlterField( + model_name="event", + name="end", + field=models.DateTimeField(blank=True, verbose_name="end"), + ), + migrations.AddField( + model_name="event", + name="only_weekdays", + field=models.BooleanField( + default=False, + help_text="Tick if this event takes place only on weekdays", + verbose_name="Only weekdays", + ), + ), + ] diff --git a/integreat_cms/cms/models/events/event.py b/integreat_cms/cms/models/events/event.py index 26dd35ae96..ce9fa4d8c5 100644 --- a/integreat_cms/cms/models/events/event.py +++ b/integreat_cms/cms/models/events/event.py @@ -100,7 +100,15 @@ class Event(AbstractContentModel): verbose_name=_("location"), ) start = models.DateTimeField(verbose_name=_("start")) - end = models.DateTimeField(verbose_name=_("end")) + end = models.DateTimeField( + verbose_name=_("end"), + blank=True, + ) + only_weekdays = models.BooleanField( + default=False, + verbose_name=_("Only weekdays"), + help_text=_("Tick if this event takes place only on weekdays"), + ) #: If the event is recurring, the recurrence rule contains all necessary information on the frequency, interval etc. #: which is needed to calculate the single instances of a recurring event recurrence_rule = models.OneToOneField( diff --git a/integreat_cms/cms/templates/events/_event_duration_tab.html b/integreat_cms/cms/templates/events/_event_duration_tab.html new file mode 100644 index 0000000000..24645a2eed --- /dev/null +++ b/integreat_cms/cms/templates/events/_event_duration_tab.html @@ -0,0 +1,22 @@ +{% load i18n %} +{% load content_filters %} + diff --git a/integreat_cms/cms/templates/events/event_form_sidebar/date_and_time_box.html b/integreat_cms/cms/templates/events/event_form_sidebar/date_and_time_box.html index cdaf3d9e5d..3ef96fb80d 100644 --- a/integreat_cms/cms/templates/events/event_form_sidebar/date_and_time_box.html +++ b/integreat_cms/cms/templates/events/event_form_sidebar/date_and_time_box.html @@ -10,110 +10,139 @@ {% translate "Date and time" %} {% endblock collapsible_box_title %} {% block collapsible_box_content %} -
-
-
- - {% render_field event_form.start_date|add_error_class:"border-red-500" %} -
-
- - {% render_field event_form.end_date|add_error_class:"border-red-500" %} + {% include "../_event_duration_tab.html" %} + {% render_field event_form.is_long_term class+="hidden" %} +
+
+
+ {% translate "One-time events take place on a specific date. For recurring events (e.g. weekly) this can be set under “Recurring”." %}
-
-
-
- - {% render_field event_form.start_time|add_error_class:"border-red-500" %} -
-
- - {% render_field event_form.end_time|add_error_class:"border-red-500" %} +
+ {% translate "These events take place over a longer period of time. E.g. Christmas markets or similar." %}
-
- {% render_field event_form.is_all_day %} - -
-
- {% render_field event_form.is_recurring id="recurrence-rule-checkbox" %} - -
- {{ event_form.is_recurring.help_text }} -
-
- - {% render_field recurrence_rule_form.frequency|add_error_class:"border-red-500" %} -
- - -
-
- - {% render_field recurrence_rule_form.week_for_monthly|add_error_class:"border-red-500" %} -
diff --git a/integreat_cms/cms/templates/events/event_list_row.html b/integreat_cms/cms/templates/events/event_list_row.html index 3532f8fcd6..6eafdc6930 100644 --- a/integreat_cms/cms/templates/events/event_list_row.html +++ b/integreat_cms/cms/templates/events/event_list_row.html @@ -112,10 +112,14 @@ {% endif %} - {% if event.recurrence_rule %} - {{ event.recurrence_rule.get_frequency_display }} + {% if not event.start_local.date == event.end_local.date %} + {% translate "Long-term" %} {% else %} - {% translate "One-time" %} + {% if event.recurrence_rule %} + {{ event.recurrence_rule.get_frequency_display }} + {% else %} + {% translate "One-time" %} + {% endif %} {% endif %} diff --git a/integreat_cms/locale/de/LC_MESSAGES/django.po b/integreat_cms/locale/de/LC_MESSAGES/django.po index 7b8658860d..680dd16665 100644 --- a/integreat_cms/locale/de/LC_MESSAGES/django.po +++ b/integreat_cms/locale/de/LC_MESSAGES/django.po @@ -1955,19 +1955,6 @@ msgstr "" msgid "The end of the event can't be before the start of the event" msgstr "Das Ende der Veranstaltung kann nicht vor ihrem Beginn sein" -#: cms/forms/events/event_form.py -msgid "" -"The maximum duration for events is {} days. Consider using recurring events " -"if the event is not continuous." -msgstr "" -"Die maximale Veranstaltungsdauer beträgt {} Tage. Verwenden Sie " -"wiederkehrende Veranstaltungen, wenn die Veranstaltung nicht kontinuierlich " -"stattfindet." - -#: cms/forms/events/recurrence_rule_form.py -msgid "Recurrence ends" -msgstr "Wiederholung endet" - #: cms/forms/events/recurrence_rule_form.py msgid "No recurrence frequency selected" msgstr "Keine Häufigkeit der Wiederholung angegeben" @@ -1984,12 +1971,6 @@ msgstr "Kein Wochentag für die monatliche Wiederholung eingegeben" msgid "No week for monthly recurrence selected" msgstr "Keine Woche für die monatliche Wiederholung eingegeben" -#: cms/forms/events/recurrence_rule_form.py -msgid "If the recurrence ends, the recurrence end date is required" -msgstr "" -"Wenn die Wiederholung endet, ist ein End-Datum für die Wiederholung " -"erforderlich" - #: cms/forms/events/recurrence_rule_form.py msgid "The recurrence end date has to be after the event's start date" msgstr "Das Ende der Wiederholung muss nach dem Veranstaltungsbeginn sein" @@ -2859,6 +2840,14 @@ msgstr "Beginn" msgid "end" msgstr "Ende" +#: cms/models/events/event.py +msgid "Only weekdays" +msgstr "Nur Wochentags" + +#: cms/models/events/event.py +msgid "Tick if this event takes place only on weekdays" +msgstr "Kreuzen Sie an, wenn diese Veranstaltung nur wochentags stattfindet" + #: cms/models/events/event.py cms/models/events/recurrence_rule.py msgid "recurrence rule" msgstr "Wiederholungs-Regel" @@ -5960,6 +5949,15 @@ msgstr "Fehler" msgid "Return back home" msgstr "Zurück zur Startseite" +#: cms/templates/events/_event_duration_tab.html +msgid "One-time or recurrent" +msgstr "Einmalig oder wiederkehrend" + +#: cms/templates/events/_event_duration_tab.html +#: cms/templates/events/event_list_row.html +msgid "Long-term" +msgstr "Fortlaufend" + #: cms/templates/events/_event_filter_form.html #: cms/templates/feedback/_admin_feedback_filter_form.html #: cms/templates/feedback/_region_feedback_filter_form.html @@ -6093,6 +6091,35 @@ msgstr "Diese Veranstaltung löschen" msgid "Date and time" msgstr "Datum und Uhrzeit" +#: cms/templates/events/event_form_sidebar/date_and_time_box.html +msgid "" +"One-time events take place on a specific date. For recurring events (e.g. " +"weekly) this can be set under “Recurring”." +msgstr "" +"Einmalige Veranstaltungen finden an einem bestimmten Termin statt. Bei " +"wiederkehrenden Veranstaltungen (z.B. wöchentlich) kann dies unter " +"“wiederkehrend” eingestellt werden." + +#: cms/templates/events/event_form_sidebar/date_and_time_box.html +msgid "" +"These events take place over a longer period of time. E.g. Christmas markets " +"or similar." +msgstr "" +"Diese Veranstaltungen finden über einen längeren Zeitraum statt. Z.B. " +"Weihnachtsmärkte o.ä." + +#: cms/templates/events/event_form_sidebar/date_and_time_box.html +msgid "These events take place daily." +msgstr "Diese Veranstaltungen finden täglich statt." + +#: cms/templates/events/event_form_sidebar/date_and_time_box.html +msgid "Please create daily repeating events under “Long-term”." +msgstr "Täglich wiederholende Events bitte unter “Fortlaufend” anlegen." + +#: cms/templates/events/event_form_sidebar/date_and_time_box.html +msgid " (optional)" +msgstr " (optional)" + #: cms/templates/events/event_form_sidebar/minor_edit_box.html #: cms/templates/pages/page_form_sidebar/minor_edit_box.html #: cms/templates/pois/poi_form_sidebar/minor_edit_box.html @@ -11319,6 +11346,22 @@ msgstr "" #~ "Ergänzen Sie fehlende Daten oder ändern bestehende Daten. Wählen Sie die " #~ "Daten aus, die übernommen werden sollen." +#~ msgid "Recurrence end date" +#~ msgstr "Enddatum der Widerholung" + +#~ msgid "If the recurrence ends, the recurrence end date is required" +#~ msgstr "" +#~ "Wenn die Wiederholung endet, ist ein End-Datum für die Wiederholung " +#~ "erforderlich" + +#~ msgid "" +#~ "The maximum duration for events is {} days. Consider using recurring " +#~ "events if the event is not continuous." +#~ msgstr "" +#~ "Die maximale Veranstaltungsdauer beträgt {} Tage. Verwenden Sie " +#~ "wiederkehrende Veranstaltungen, wenn die Veranstaltung nicht " +#~ "kontinuierlich stattfindet." + #~ msgid "An error occurred while importing events from this external calendar" #~ msgstr "Ein Fehler mit dem Import von Veranstaltungen ist aufgetreten" @@ -11458,17 +11501,16 @@ msgstr "" #~ "Wir laden im Hintergrund gerade Ihre veralteten und fehlenden " #~ "Übersetzungen. Bitte haben Sie noch ein wenig Geduld." -#, python-format #~ msgid "" -#~ "Your pages currently have " -#~ "%(number_of_missing_or_outdated_translations)s pages that have an " +#~ "Your pages currently have " +#~ "%(number_of_missing_or_outdated_translations)s pages that have an " #~ "outdated or no translation. In order for the users to benefit from your " #~ "content you should translate them or have them translated." #~ msgstr "" -#~ "Ihre Inhalten haben aktuell " -#~ "%(number_of_missing_or_outdated_translations)s Seiten mit " -#~ "fehlender oder veralteter Übersetzung. Damit die Nutzer:innen von Ihren " -#~ "Inhalten profitieren können, sollten Sie diese übersetzen (lassen)." +#~ "Ihre Inhalten haben aktuell " +#~ "%(number_of_missing_or_outdated_translations)s Seiten mit fehlender " +#~ "oder veralteter Übersetzung. Damit die Nutzer:innen von Ihren Inhalten " +#~ "profitieren können, sollten Sie diese übersetzen (lassen)." #~ msgid "View location" #~ msgstr "Ort ansehen" @@ -13042,9 +13084,6 @@ msgstr "" #~ msgid "Week" #~ msgstr "Woche" -#~ msgid "Recurrence end date" -#~ msgstr "Wiederholung Enddatum" - #~ msgid "Common Region Identifier" #~ msgstr "Gemeindeschlüssel" diff --git a/integreat_cms/static/src/index.ts b/integreat_cms/static/src/index.ts index 9278ded123..190769ee16 100644 --- a/integreat_cms/static/src/index.ts +++ b/integreat_cms/static/src/index.ts @@ -31,6 +31,7 @@ import "./js/language-tabs"; import "./js/machine-translation-overlay"; import "./js/revisions"; import "./js/search-query"; +import "./js/event-duration"; import "./js/forms/slug-error"; import "./js/forms/update-permalink"; diff --git a/integreat_cms/static/src/js/event-duration.ts b/integreat_cms/static/src/js/event-duration.ts new file mode 100644 index 0000000000..3ef20b7e7e --- /dev/null +++ b/integreat_cms/static/src/js/event-duration.ts @@ -0,0 +1,44 @@ +const toggleTabColorAndBorder = (tabId: string, color: string) => { + const targetTab = document.getElementById(tabId); + + if (color === "bg-white") { + targetTab.children[0].classList.remove("bg-water-500"); + targetTab.children[0].classList.add(color); + targetTab.children[0].children[0].children[0].classList.remove("border-b"); + } else { + targetTab.children[0].classList.remove("bg-white"); + targetTab.children[0].classList.add(color); + targetTab.children[0].children[0].children[0].classList.add("border-b"); + } +}; + +const showOneTimeEventTab = () => { + document.getElementById("end-date").classList.add("hidden"); + document.getElementById("recurrence-setting").classList.remove("hidden"); + document.getElementById("one-time-recurring-explanation").classList.remove("hidden"); + document.getElementById("long-term-explanation").classList.add("hidden"); + document.getElementById("long-term-info").classList.add("hidden"); + + toggleTabColorAndBorder("one-time-and-recurring-tab", "bg-white"); + toggleTabColorAndBorder("long-term-tab", "bg-water-500"); + + (document.getElementById("id_is_long_term") as HTMLInputElement).checked = false; +}; + +const showLongTermEventTab = () => { + document.getElementById("end-date").classList.remove("hidden"); + document.getElementById("recurrence-setting").classList.add("hidden"); + document.getElementById("one-time-recurring-explanation").classList.add("hidden"); + document.getElementById("long-term-explanation").classList.remove("hidden"); + document.getElementById("long-term-info").classList.remove("hidden"); + + toggleTabColorAndBorder("one-time-and-recurring-tab", "bg-water-500"); + toggleTabColorAndBorder("long-term-tab", "bg-white"); + + (document.getElementById("id_is_long_term") as HTMLInputElement).checked = true; +}; + +window.addEventListener("load", () => { + document.getElementById("one-time-and-recurring-tab")?.addEventListener("click", showOneTimeEventTab); + document.getElementById("long-term-tab")?.addEventListener("click", showLongTermEventTab); +}); diff --git a/integreat_cms/static/src/js/events/conditional-fields.ts b/integreat_cms/static/src/js/events/conditional-fields.ts index c7eadbe039..e07a8a916b 100644 --- a/integreat_cms/static/src/js/events/conditional-fields.ts +++ b/integreat_cms/static/src/js/events/conditional-fields.ts @@ -61,28 +61,6 @@ window.addEventListener("load", () => { }); } - // event handler to show recurrence end date - const recurrenceEndData = document.getElementById("id_has_recurrence_end_date"); - if (recurrenceEndData) { - recurrenceEndData.addEventListener("click", ({ target }) => { - const recurrenceEnd = document.getElementById("recurrence-end"); - if ((target as HTMLInputElement).checked) { - const dateInputField = recurrenceEnd.querySelector("input"); - dateInputField.required = true; - if (!dateInputField.getAttribute("value")) { - dateInputField.value = ""; - } - } else { - const dateInputField = recurrenceEnd.querySelector("input"); - dateInputField.removeAttribute("required"); - if (!dateInputField.getAttribute("value")) { - dateInputField.removeAttribute("value"); - } - } - recurrenceEnd.classList.toggle("hidden", !(target as HTMLInputElement).checked); - }); - } - // event handler to show location selection document.getElementById("id_has_not_location")?.addEventListener("click", () => { document.getElementById("location-block").classList.toggle("hidden"); From ff9609fab238a8f7b80d834ff9551028c565b735 Mon Sep 17 00:00:00 2001 From: MizukiTemma Date: Thu, 23 Jan 2025 17:25:42 +0100 Subject: [PATCH 2/3] Fix migration, add release note --- .../{0112_alter_event_end.py => 0113_alter_event_end.py} | 2 +- integreat_cms/release_notes/current/unreleased/3070.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) rename integreat_cms/cms/migrations/{0112_alter_event_end.py => 0113_alter_event_end.py} (96%) create mode 100644 integreat_cms/release_notes/current/unreleased/3070.yml diff --git a/integreat_cms/cms/migrations/0112_alter_event_end.py b/integreat_cms/cms/migrations/0113_alter_event_end.py similarity index 96% rename from integreat_cms/cms/migrations/0112_alter_event_end.py rename to integreat_cms/cms/migrations/0113_alter_event_end.py index 53a9ca8730..85ab4ef79e 100644 --- a/integreat_cms/cms/migrations/0112_alter_event_end.py +++ b/integreat_cms/cms/migrations/0113_alter_event_end.py @@ -34,7 +34,7 @@ class Migration(migrations.Migration): """ dependencies = [ - ("cms", "0111_alter_language_language_color"), + ("cms", "0112_sort_contacts_by_POI_and_name"), ] operations = [ diff --git a/integreat_cms/release_notes/current/unreleased/3070.yml b/integreat_cms/release_notes/current/unreleased/3070.yml new file mode 100644 index 0000000000..7a4586a16b --- /dev/null +++ b/integreat_cms/release_notes/current/unreleased/3070.yml @@ -0,0 +1,2 @@ +en: Add a new event type "long-term" for events longer than 28 days +de: Fügen einen neuen Veranstaltungstyp „Fortlaufend“ für Veranstaltungen hinzu, die länger als 28 Tage dauern From 8eeeae2010b09d54571860a7c169bdfbcd74dc13 Mon Sep 17 00:00:00 2001 From: MizukiTemma Date: Thu, 23 Jan 2025 17:53:18 +0100 Subject: [PATCH 3/3] Remove DAILY from the recurrence option --- integreat_cms/cms/constants/frequency.py | 3 --- .../cms/migrations/0113_alter_event_end.py | 15 +++++++++++++++ .../event_form_sidebar/date_and_time_box.html | 5 ----- integreat_cms/locale/de/LC_MESSAGES/django.po | 8 ++++---- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/integreat_cms/cms/constants/frequency.py b/integreat_cms/cms/constants/frequency.py index 0c5deafb16..3cf918fc3a 100644 --- a/integreat_cms/cms/constants/frequency.py +++ b/integreat_cms/cms/constants/frequency.py @@ -16,8 +16,6 @@ # The frequencies must adhere to the icalendar naming: https://icalendar.org/iCalendar-RFC-5545/3-3-10-recurrence-rule.html -#: Daily -DAILY: Final = "DAILY" #: Weekly WEEKLY: Final = "WEEKLY" #: Monthly @@ -27,7 +25,6 @@ #: Choices to use these constants in a database field CHOICES: Final[list[tuple[str, Promise]]] = [ - (DAILY, _("Daily")), (WEEKLY, _("Weekly")), (MONTHLY, _("Monthly")), (YEARLY, _("Yearly")), diff --git a/integreat_cms/cms/migrations/0113_alter_event_end.py b/integreat_cms/cms/migrations/0113_alter_event_end.py index 85ab4ef79e..808357c2a5 100644 --- a/integreat_cms/cms/migrations/0113_alter_event_end.py +++ b/integreat_cms/cms/migrations/0113_alter_event_end.py @@ -53,4 +53,19 @@ class Migration(migrations.Migration): verbose_name="Only weekdays", ), ), + migrations.AlterField( + model_name="recurrencerule", + name="frequency", + field=models.CharField( + choices=[ + ("WEEKLY", "Weekly"), + ("MONTHLY", "Monthly"), + ("YEARLY", "Yearly"), + ], + default="WEEKLY", + help_text="How often the event recurs", + max_length=7, + verbose_name="frequency", + ), + ), ] diff --git a/integreat_cms/cms/templates/events/event_form_sidebar/date_and_time_box.html b/integreat_cms/cms/templates/events/event_form_sidebar/date_and_time_box.html index 3ef96fb80d..5e3c616764 100644 --- a/integreat_cms/cms/templates/events/event_form_sidebar/date_and_time_box.html +++ b/integreat_cms/cms/templates/events/event_form_sidebar/date_and_time_box.html @@ -130,11 +130,6 @@ {{ recurrence_rule_form.interval.label }} {% render_field recurrence_rule_form.interval|add_error_class:"border-red-500" %} - {% render_field recurrence_rule_form.has_recurrence_end_date %} -