Enhance resource management: refresh case data and notify listeners on resource changes in case attachment/detachment

This commit is contained in:
Ross
2025-12-15 10:12:04 +00:00
parent 654d0ae686
commit 2f014ce1a5
2 changed files with 20 additions and 5 deletions
+1 -1
View File
@@ -151,7 +151,7 @@
disp.style.display='flex'; return true;
}
if (event.data.url && isMediaUrl(event.data.url)) {
// show resource overlay and do not attempt to mount DICOM viewer
+19 -4
View File
@@ -4085,9 +4085,16 @@ def case_attach_resource(request, pk):
# update flag
cr.pre_review = pre_review
cr.save()
# Render updated list
return render(request, "atlas/partials/case_resources_list.html", {"case": case})
# Refresh case from DB to ensure related sets reflect changes and render updated list
try:
case = Case.objects.get(pk=case.pk)
except Exception:
pass
html = render_to_string("atlas/partials/case_resources_list.html", {"case": case}, request=request)
resp = HttpResponse(html)
# Notify any HTMX listeners that the case resources have changed
resp["HX-Trigger"] = json.dumps({"caseResourcesChanged": {"case_id": case.pk}})
return resp
@login_required
@@ -4103,7 +4110,15 @@ def case_detach_resource(request, pk):
cr.delete()
except Exception:
pass
return render(request, "atlas/partials/case_resources_list.html", {"case": case})
# Refresh case from DB and return updated partial
try:
case = Case.objects.get(pk=case.pk)
except Exception:
pass
html = render_to_string("atlas/partials/case_resources_list.html", {"case": case}, request=request)
resp = HttpResponse(html)
resp["HX-Trigger"] = json.dumps({"caseResourcesChanged": {"case_id": case.pk}})
return resp
def series_dicom_json(request, pk):