From b4d8e9ccc45c180202fde917592b16d936a958a4 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 7 Apr 2025 14:34:32 +0200 Subject: [PATCH] Backend event list: Sort event series by their actual dates, like in the frontend (Z#23187301) (#4993) --- .../templates/pretixcontrol/events/index.html | 25 +++++++++++-------- .../pretixcontrol/organizers/detail.html | 25 +++++++++++-------- src/pretix/control/views/main.py | 4 +-- src/pretix/control/views/organizer.py | 4 +-- 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/pretix/control/templates/pretixcontrol/events/index.html b/src/pretix/control/templates/pretixcontrol/events/index.html index 08b32fb9e..ae09794ab 100644 --- a/src/pretix/control/templates/pretixcontrol/events/index.html +++ b/src/pretix/control/templates/pretixcontrol/events/index.html @@ -110,23 +110,26 @@ {% if not hide_orga %}{{ e.organizer }}{% endif %} {% if e.has_subevents %} - {{ e.min_from|default_if_none:""|date:"SHORT_DATETIME_FORMAT" }} + + {% trans "Event series" %} +
+ + {% if e.min_from %} + {{ e.min_from|date:"SHORT_DATETIME_FORMAT" }} –
+ {{ e.max_fromto|default_if_none:e.max_to|default_if_none:e.max_from|date:"SHORT_DATETIME_FORMAT" }} + {% else %} + {% trans "No dates" context "subevent" %} + {% endif %} +
{% else %} {{ e.get_short_date_from_display }} - {% endif %} - {% if e.has_subevents %} - {% trans "Series" %} - {% endif %} - {% if e.settings.show_date_to and e.date_to %} - –
- {% if e.has_subevents %} - {{ e.max_fromto|default_if_none:e.max_from|default_if_none:e.max_to|default_if_none:""|date:"SHORT_DATETIME_FORMAT" }} - {% else %} + {% if e.settings.show_date_to and e.date_to %} + –
{{ e.get_short_date_to_display }} {% endif %} {% endif %} {% if e.settings.timezone != request.timezone %} - + {% endif %} diff --git a/src/pretix/control/templates/pretixcontrol/organizers/detail.html b/src/pretix/control/templates/pretixcontrol/organizers/detail.html index 2d865bd25..7c2373e72 100644 --- a/src/pretix/control/templates/pretixcontrol/organizers/detail.html +++ b/src/pretix/control/templates/pretixcontrol/organizers/detail.html @@ -86,23 +86,26 @@ {% if e.has_subevents %} - {{ e.min_from|default_if_none:""|date:"SHORT_DATETIME_FORMAT" }} + + {% trans "Event series" %} +
+ + {% if e.min_from %} + {{ e.min_from|date:"SHORT_DATETIME_FORMAT" }} –
+ {{ e.max_fromto|default_if_none:e.max_to|default_if_none:e.max_from|date:"SHORT_DATETIME_FORMAT" }} + {% else %} + {% trans "No dates" context "subevent" %} + {% endif %} +
{% else %} {{ e.get_short_date_from_display }} - {% endif %} - {% if e.has_subevents %} - {% trans "Series" %} - {% endif %} - {% if e.settings.show_date_to and e.date_to %} - –
- {% if e.has_subevents %} - {{ e.max_fromto|default_if_none:e.max_from|default_if_none:e.max_to|default_if_none:""|date:"SHORT_DATETIME_FORMAT" }} - {% else %} + {% if e.settings.show_date_to and e.date_to %} + –
{{ e.get_short_date_to_display }} {% endif %} {% endif %} {% if e.settings.timezone != request.timezone %} - + {% endif %} diff --git a/src/pretix/control/views/main.py b/src/pretix/control/views/main.py index 0233e63d1..1f1b24caf 100644 --- a/src/pretix/control/views/main.py +++ b/src/pretix/control/views/main.py @@ -81,9 +81,9 @@ class EventList(PaginationMixin, ListView): max_to=Max('subevents__date_to'), max_fromto=Greatest(Max('subevents__date_to'), Max('subevents__date_from')) ).annotate( - order_from=Coalesce('min_from', 'date_from'), + order_from=Coalesce('max_from', 'date_from'), order_to=Coalesce('max_fromto', 'max_to', 'max_from', 'date_to', 'date_from'), - ) + ).order_by("-order_from") qs = qs.prefetch_related( Prefetch('quotas', diff --git a/src/pretix/control/views/organizer.py b/src/pretix/control/views/organizer.py index f16546e9f..dba56b546 100644 --- a/src/pretix/control/views/organizer.py +++ b/src/pretix/control/views/organizer.py @@ -206,9 +206,9 @@ class OrganizerDetail(OrganizerDetailViewMixin, OrganizerPermissionRequiredMixin max_to=Max('subevents__date_to'), max_fromto=Greatest(Max('subevents__date_to'), Max('subevents__date_from')) ).annotate( - order_from=Coalesce('min_from', 'date_from'), + order_from=Coalesce('max_from', 'date_from'), order_to=Coalesce('max_fromto', 'max_to', 'max_from', 'date_to', 'date_from'), - ) + ).order_by("-order_from") if self.filter_form.is_valid(): qs = self.filter_form.filter_qs(qs) return qs