From 8da2dd27dab4721e20f6f9026ca062c1d07de8de Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 13 Nov 2025 22:17:43 +0000 Subject: [PATCH] Enhance normals list display and update case state handling in views --- atlas/templates/atlas/normals_list.html | 14 ++++++++++++-- atlas/views.py | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/atlas/templates/atlas/normals_list.html b/atlas/templates/atlas/normals_list.html index fecf2923..260191a3 100644 --- a/atlas/templates/atlas/normals_list.html +++ b/atlas/templates/atlas/normals_list.html @@ -27,8 +27,18 @@
{% for normal in page_obj.object_list %} - {{ normal.case.title }}{% if normal.age_years %} — {{ normal.age_years }} yrs{% endif %} -
Added {{ normal.added_date }}
+
+
{{ normal.case.title }}
+ {{ normal.added_date|date:"Y-m-d" }} +
+

+ Age: {{ normal.age_years|default:"unknown" }} yrs + {% if normal.examination %} • Exam: {{ normal.examination }}{% endif %} + {% if normal.modality %} • Modality: {{ normal.modality }}{% endif %} +

+ {% if normal.notes %} +

{{ normal.notes }}

+ {% endif %}
{% endfor %}
diff --git a/atlas/views.py b/atlas/views.py index 8dfb084e..d6423cfc 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -500,6 +500,14 @@ def toggle_case_normal(request, pk): if normal is not None: normal.delete() + # Remove any cached relation on the case and reload so the template + # sees the updated state (no normal_case). + try: + if hasattr(case, "normal_case"): + delattr(case, "normal_case") + except Exception: + pass + case = get_case_for_case_detail(pk) else: # Attempt to auto-extract age from DICOM age = None @@ -668,6 +676,14 @@ def create_case_normal(request, pk): nc.added_by = request.user nc.save() + # Ensure the case reflects the newly created NormalCase when rendering + try: + if hasattr(case, "normal_case"): + delattr(case, "normal_case") + except Exception: + pass + case = get_case_for_case_detail(pk) + # Return the updated toggle fragment and close modal via inline script is_atlas_editor = request.user.is_superuser or request.user.groups.filter(name="atlas_editor").exists() is_case_author = case.author.filter(id=request.user.id).exists()