Backend event list: Sort event series by their actual dates, like in the frontend (Z#23187301) (#4993)

This commit is contained in:
Raphael Michel
2025-04-07 14:34:32 +02:00
committed by GitHub
parent 899994ef1e
commit b4d8e9ccc4
4 changed files with 32 additions and 26 deletions

View File

@@ -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',

View File

@@ -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