diff --git a/generic/templates/generic/examcollection_list.html b/generic/templates/generic/examcollection_list.html index 91660075..cd343552 100755 --- a/generic/templates/generic/examcollection_list.html +++ b/generic/templates/generic/examcollection_list.html @@ -4,6 +4,14 @@

Exam Collections

+
+
+ + +
+
+ {% if object_list %}
{% for collection in object_list %} diff --git a/generic/views.py b/generic/views.py index 7412f453..8a57daeb 100644 --- a/generic/views.py +++ b/generic/views.py @@ -5342,8 +5342,15 @@ class ExamCollectionList(ListView): def get_queryset(self): """Annotate exam counts per collection and prefetch authors to avoid N+1 queries in templates.""" + # allow toggling whether archived collections are included via ?show_archived=1 + show_archived = self.request.GET.get("show_archived") + + base_qs = ExamCollection.objects.all() + if not show_archived: + base_qs = base_qs.filter(archive=False) + qs = ( - ExamCollection.objects.all() + base_qs .annotate( anatomy_count=Count("anatomy_exams", filter=Q(anatomy_exams__archive=False)), longs_count=Count("longs_exams", filter=Q(longs_exams__archive=False)),