.
This commit is contained in:
+39
-1
@@ -906,7 +906,6 @@ class QuestionSchemaDelete(AuthorOrCheckerRequiredMixin, DeleteView):
|
||||
model = QuestionSchema
|
||||
template_name = "confirm_delete.html"
|
||||
|
||||
|
||||
class FindingUpdate(RevisionMixin, LoginRequiredMixin, UpdateView):
|
||||
model = Finding
|
||||
form_class = FindingForm
|
||||
@@ -3061,3 +3060,42 @@ def remove_case_from_collection(request, case_pk, collection_pk):
|
||||
collection.cases.remove(case)
|
||||
|
||||
return HttpResponse(f"Case removed from collection: {collection.name}")
|
||||
|
||||
|
||||
def linked_cases_overview(request, case_id):
|
||||
"""
|
||||
View to display an overview of linked cases via the previous_case field.
|
||||
"""
|
||||
# Get the current case
|
||||
case = get_object_or_404(Case, pk=case_id)
|
||||
|
||||
# Traverse backward to get all previous cases
|
||||
previous_cases = []
|
||||
try:
|
||||
current_case = case.previous_case
|
||||
while current_case:
|
||||
previous_cases.insert(0, current_case) # Insert at the beginning to maintain order
|
||||
current_case = current_case.previous_case
|
||||
except ObjectDoesNotExist:
|
||||
pass
|
||||
|
||||
# Traverse forward to get all next cases
|
||||
next_cases = []
|
||||
try:
|
||||
current_case = case.next_case
|
||||
while current_case:
|
||||
next_cases.append(current_case)
|
||||
current_case = current_case.next_case
|
||||
except ObjectDoesNotExist:
|
||||
pass
|
||||
|
||||
# Render the template with the linked cases
|
||||
return render(
|
||||
request,
|
||||
"atlas/linked_cases_overview.html",
|
||||
{
|
||||
"case": case,
|
||||
"previous_cases": previous_cases,
|
||||
"next_cases": next_cases,
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user