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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user