Add filtering options for findings, structures, conditions, subspecialties, and presentations in question overview
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user