This commit is contained in:
Ross
2025-05-04 16:50:56 +01:00
parent a43a6e0fed
commit 5f94616168
5 changed files with 83 additions and 6 deletions
@@ -2,7 +2,7 @@
<h2>Case: {{ case.title }}</h2> <h2>Case: {{ case.title }}</h2>
{% if case.previous_case or case.next_case %} {% if case.previous_case or case.next_case %}
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
This case is part of a series.<br/> This case is part of a <a href='{% url "atlas:linked_cases_overview" case.pk %}'>series.</a><br/>
<div class="row"> <div class="row">
{% if case.previous_case %} {% if case.previous_case %}
<div class="col-sm-6 mb-3 mb-sm-0"> <div class="col-sm-6 mb-3 mb-sm-0">
+5 -4
View File
@@ -22,16 +22,17 @@
(<a href='{% url "atlas:collection_case_details" casedetail.collection.pk casedetail.case.pk %}'>edit questions</a> (<a href='{% url "atlas:collection_case_details" casedetail.collection.pk casedetail.case.pk %}'>edit questions</a>
&nbsp; &nbsp;
{% if casedetail.question_schema %} {% if casedetail.question_schema %}
<i class="bi bi-question-square text-success"></i> <i class="bi bi-question-square text-success" title="This case has questions defined."></i>
{% else %} {% else %}
<i class="bi bi-question-square text-danger"></i> <i class="bi bi-question-square text-danger" title="This case has no questions defined."></i>
{% endif %} {% endif %}
) )
{% endif %} {% endif %}
{% if casedetail.case.previous_case %}
(<a href='{% url "atlas:collection_case_priors" casedetail.collection.pk casedetail.case.pk %}'>manage priors</a>) (<a href='{% url "atlas:collection_case_priors" casedetail.collection.pk casedetail.case.pk %}'>manage priors</a>)
{% endif %}
</li> </li>
{% endfor %} {% endfor %}
@@ -0,0 +1,33 @@
<!-- filepath: /home/ross/rad/rad/atlas/templates/atlas/linked_cases_overview.html -->
{% extends "base.html" %}
{% block content %}
<h1>Linked Cases Overview</h1>
<h2>Current Case: {{ case.title }}</h2>
<h3>Previous Cases</h3>
{% if previous_cases %}
<ul>
{% for prev_case in previous_cases %}
<li>
<a href="{{ prev_case.get_absolute_url }}">{{ prev_case.title }}</a>
</li>
{% endfor %}
</ul>
{% else %}
<p>No previous cases.</p>
{% endif %}
<h3>Next Cases</h3>
{% if next_cases %}
<ul>
{% for next_case in next_cases %}
<li>
<a href="{{ next_case.get_absolute_url }}">{{ next_case.title }}</a>
</li>
{% endfor %}
</ul>
{% else %}
<p>No next cases.</p>
{% endif %}
{% endblock %}
+5
View File
@@ -462,4 +462,9 @@ urlpatterns = [
name="pathological_process_detail", name="pathological_process_detail",
), ),
path("combine_series/", views.combine_series, name="combine_series"), path("combine_series/", views.combine_series, name="combine_series"),
path(
"case/<int:case_id>/linked/",
views.linked_cases_overview,
name="linked_cases_overview",
),
] ]
+39 -1
View File
@@ -906,7 +906,6 @@ class QuestionSchemaDelete(AuthorOrCheckerRequiredMixin, DeleteView):
model = QuestionSchema model = QuestionSchema
template_name = "confirm_delete.html" template_name = "confirm_delete.html"
class FindingUpdate(RevisionMixin, LoginRequiredMixin, UpdateView): class FindingUpdate(RevisionMixin, LoginRequiredMixin, UpdateView):
model = Finding model = Finding
form_class = FindingForm form_class = FindingForm
@@ -3061,3 +3060,42 @@ def remove_case_from_collection(request, case_pk, collection_pk):
collection.cases.remove(case) collection.cases.remove(case)
return HttpResponse(f"Case removed from collection: {collection.name}") 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,
},
)