diff --git a/atlas/templates/atlas/partials/displayset_row.html b/atlas/templates/atlas/partials/displayset_row.html index 88c93c64..5bfead5b 100644 --- a/atlas/templates/atlas/partials/displayset_row.html +++ b/atlas/templates/atlas/partials/displayset_row.html @@ -55,12 +55,10 @@
Show advanced (viewer state & annotations)
- Viewer State: -
{{ ds.viewerstate|default:"{}" }}
+ {% include 'atlas/partials/json_pretty.html' with json_value=ds.viewerstate title='Viewer State' %}
- Annotations: -
{{ ds.annotations|default:"{}" }}
+ {% include 'atlas/partials/json_pretty.html' with json_value=ds.annotations title='Annotations' %}
diff --git a/atlas/templates/atlas/partials/json_pretty.html b/atlas/templates/atlas/partials/json_pretty.html new file mode 100644 index 00000000..07e8e4ca --- /dev/null +++ b/atlas/templates/atlas/partials/json_pretty.html @@ -0,0 +1,78 @@ +
+
+ {{ title }} +
+ + +
+
+ +
+ + +
diff --git a/atlas/templatetags/json_filters.py b/atlas/templatetags/json_filters.py new file mode 100644 index 00000000..0e701e96 --- /dev/null +++ b/atlas/templatetags/json_filters.py @@ -0,0 +1,27 @@ +import json +from django import template +from django.utils.safestring import mark_safe +from django.utils.html import escape + +register = template.Library() + + +@register.filter(name="pretty_json") +def pretty_json(value): + """Pretty-print a JSON string or Python object for display inside
.
+
+    Returns an HTML-escaped, pretty-formatted JSON string (marked safe).
+    """
+    try:
+        if isinstance(value, str):
+            obj = json.loads(value)
+        else:
+            obj = value
+        pretty = json.dumps(obj, indent=2, default=str, sort_keys=True)
+    except Exception:
+        try:
+            pretty = str(value) if value is not None else "{}"
+        except Exception:
+            pretty = "{}"
+
+    return mark_safe(escape(pretty))
diff --git a/atlas/views.py b/atlas/views.py
index 79b58926..45d724a8 100755
--- a/atlas/views.py
+++ b/atlas/views.py
@@ -3395,6 +3395,19 @@ def case_download(request, pk):
                 "id": case.pk,
                 "title": case.title,
                 "authors": [str(a) for a in case.author.all()],
+                # Non-DICOM metadata
+                "description": case.description,
+                "history": case.history,
+                "discussion": case.discussion,
+                "report": case.report,
+                "created_date": getattr(case, "created_date", None),
+                "modified_date": getattr(case, "modified_date", None),
+                "presentation": [str(p) for p in case.presentation.all()],
+                "subspecialty": [str(s) for s in case.subspecialty.all()],
+                "pathological_process": [str(p) for p in case.pathological_process.all()],
+                "procedures": [str(p) for p in case.procedures.all()],
+                "conditions": [str(c) for c in case.condition.all()],
+                "case_size_bytes": case.get_total_series_images_size() if hasattr(case, "get_total_series_images_size") else None,
             },
             "series": [],
         }