Refactor case handling: update URLs and views to support case_number and case_id interchangeably, enhancing backward compatibility and maintainability

This commit is contained in:
Ross
2025-11-17 11:05:13 +00:00
parent 81cd109449
commit 6e658aca93
8 changed files with 270 additions and 38 deletions
+7
View File
@@ -1443,6 +1443,13 @@ class CaseDetail(models.Model):
def __str__(self) -> str:
return f"{self.case} -> {self.collection}"
def get_case_index(self):
"""Returns the question index (number) in the collection (0 indexed)"""
case_details = list(self.collection.casedetail_set.all().order_by("sort_order"))
return case_details.index(self)
def get_question_schema(self):
return json.dumps(self.question_schema)