From f95e9ae8dd22fde723162bdb1cebd390ea9ec048 Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Thu, 20 Jul 2023 13:18:04 +0300 Subject: [PATCH] sort collections in series (detail) by start date --- .../series/templates/series/series_detail.html | 2 +- scipost_django/series/views.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/scipost_django/series/templates/series/series_detail.html b/scipost_django/series/templates/series/series_detail.html index f24d7bf4a..7c5b7d6af 100644 --- a/scipost_django/series/templates/series/series_detail.html +++ b/scipost_django/series/templates/series/series_detail.html @@ -54,7 +54,7 @@ <div class="col-lg-6"> <h3 class="highlight" id="collections">Collections in this Series</h3> <ul> - {% for collection in series.collection_set.all %} + {% for collection in collections %} <li><a href="{{ collection.get_absolute_url }}">{{ collection }}</a></li> {% empty %} <li>No Collection has yet been assembled for this Series</li> diff --git a/scipost_django/series/views.py b/scipost_django/series/views.py index 4cec24bd2..d342bcc59 100644 --- a/scipost_django/series/views.py +++ b/scipost_django/series/views.py @@ -32,6 +32,15 @@ class SeriesDetailView(DetailView): model = Series + def get_context_data(self, *args, **kwargs): + context = super().get_context_data(*args, **kwargs) + + # Sort collections in series by event start date + context["collections"] = self.object.collection_set.all().order_by( + "event_start_date" + ) + return context + class CollectionDetailView(DetailView): """ -- GitLab