Refactor collection_case_questions function to use case_number instead of case_id for improved clarity and consistency in case retrieval
This commit is contained in:
+5
-10
@@ -3173,18 +3173,13 @@ def collection_case_priors(request, exam_id, case_number):
|
|||||||
|
|
||||||
|
|
||||||
@user_is_collection_author_or_atlas_editor
|
@user_is_collection_author_or_atlas_editor
|
||||||
def collection_case_questions(request, exam_id, case_id):
|
def collection_case_questions(request, exam_id, case_number):
|
||||||
# Support either case_number (index) or case_id (case PK)
|
collection = get_object_or_404(CaseCollection, pk=exam_id)
|
||||||
try:
|
try:
|
||||||
casedetail = CaseDetail.objects.get(case=case_id, collection=exam_id)
|
case_obj = collection.get_case_by_index(case_number)
|
||||||
collection = casedetail.collection
|
casedetail = CaseDetail.objects.get(case=case_obj, collection=collection)
|
||||||
except Exception:
|
except Exception:
|
||||||
collection = get_object_or_404(CaseCollection, pk=exam_id)
|
raise Http404("Case not found in collection")
|
||||||
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")
|
|
||||||
|
|
||||||
if not collection.collection_type == "QUE":
|
if not collection.collection_type == "QUE":
|
||||||
raise Http404("Collection not in question mode")
|
raise Http404("Collection not in question mode")
|
||||||
|
|||||||
Reference in New Issue
Block a user