From 15c243172dd1ce98bf6638b9b3d5fdee8910b114 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 28 Oct 2025 08:23:42 +0000 Subject: [PATCH] Add filtering options for findings, structures, conditions, subspecialties, and presentations in question overview --- sbas/templates/sbas/question_overview.html | 52 +++++++++++++++++++++ sbas/views.py | 54 ++++++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/sbas/templates/sbas/question_overview.html b/sbas/templates/sbas/question_overview.html index fbcbc0e9..c682f8e5 100644 --- a/sbas/templates/sbas/question_overview.html +++ b/sbas/templates/sbas/question_overview.html @@ -36,6 +36,58 @@ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
diff --git a/sbas/views.py b/sbas/views.py index 68519420..70ed4835 100644 --- a/sbas/views.py +++ b/sbas/views.py @@ -534,6 +534,13 @@ def question_overview(request): category_filter = request.GET.get("category") open_access = request.GET.get("open_access") + # Atlas model filters (single-select for now) + finding_filter = request.GET.get("finding") + structure_filter = request.GET.get("structure") + condition_filter = request.GET.get("condition") + subspecialty_filter = request.GET.get("subspecialty") + presentation_filter = request.GET.get("presentation") + qs = Question.objects.all().order_by("pk") # Permission filter: non-checkers see open_access or their own questions @@ -556,12 +563,42 @@ def question_overview(request): if open_access in ("0", "1"): qs = qs.filter(open_access=(open_access == "1")) + # Optional atlas M2M filters + try: + if finding_filter: + qs = qs.filter(finding__id=int(finding_filter)) + except Exception: + pass + try: + if structure_filter: + qs = qs.filter(structure__id=int(structure_filter)) + except Exception: + pass + try: + if condition_filter: + qs = qs.filter(condition__id=int(condition_filter)) + except Exception: + pass + try: + if subspecialty_filter: + qs = qs.filter(subspecialty__id=int(subspecialty_filter)) + except Exception: + pass + try: + if presentation_filter: + qs = qs.filter(presentation__id=int(presentation_filter)) + except Exception: + pass + # Build counts by category (default) counts = {} total = 0 from django.contrib.contenttypes.models import ContentType + # Import atlas models for populating filter choices + from atlas.models import Finding, Structure, Condition as AtlasCondition, Subspecialty, Presentation as AtlasPresentation + for question in qs: # Respect authors_only flag try: @@ -608,6 +645,13 @@ def question_overview(request): categories = Category.objects.all().order_by("category") + # Populate atlas filter lists + findings = Finding.objects.all().order_by("name") + structures = Structure.objects.all().order_by("name") + conditions = AtlasCondition.objects.all().order_by("name") + subspecialties = Subspecialty.objects.all().order_by("name") + presentations = AtlasPresentation.objects.all().order_by("name") + context = { "status_options": status_options, "selected_status": status, @@ -617,6 +661,16 @@ def question_overview(request): "categories": categories, "selected_category": category_filter, "selected_open_access": open_access, + "findings": findings, + "structures": structures, + "conditions": conditions, + "subspecialties": subspecialties, + "presentations": presentations, + "selected_finding": finding_filter, + "selected_structure": structure_filter, + "selected_condition": condition_filter, + "selected_subspecialty": subspecialty_filter, + "selected_presentation": presentation_filter, } return render(request, "sbas/question_overview.html", context)