From e8c35efd834474b017067504bbdc5801e8313f25 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 24 Nov 2025 12:02:43 +0000 Subject: [PATCH] Refactor collection_case_questions function to use case_number instead of case_id for improved clarity and consistency in case retrieval --- atlas/views.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/atlas/views.py b/atlas/views.py index 7d2d6621..c17001de 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -3173,18 +3173,13 @@ def collection_case_priors(request, exam_id, case_number): @user_is_collection_author_or_atlas_editor -def collection_case_questions(request, exam_id, case_id): - # Support either case_number (index) or case_id (case PK) +def collection_case_questions(request, exam_id, case_number): + collection = get_object_or_404(CaseCollection, pk=exam_id) try: - casedetail = CaseDetail.objects.get(case=case_id, collection=exam_id) - collection = casedetail.collection + case_obj = collection.get_case_by_index(case_number) + casedetail = CaseDetail.objects.get(case=case_obj, collection=collection) except Exception: - collection = get_object_or_404(CaseCollection, pk=exam_id) - try: - case_obj = collection.get_case_by_index(int(case_id)) - casedetail = CaseDetail.objects.get(case=case_obj, collection=collection) - except Exception: - raise Http404("Case not found in collection") + raise Http404("Case not found in collection") if not collection.collection_type == "QUE": raise Http404("Collection not in question mode")