fix many issues

This commit is contained in:
Ross
2026-06-03 20:38:29 +01:00
parent 46518a45c1
commit 2e854c43b6
7 changed files with 166 additions and 12 deletions
+10 -5
View File
@@ -1379,7 +1379,7 @@ def _populate_case_study_date_on_series_image_save(sender, instance, **kwargs):
if not instance.series_id:
return
tags = instance.basic_dicom_tags or {}
tags = getattr(instance, "basic_dicom_tags", None) or {}
raw_date = tags.get("StudyDate") or tags.get("AcquisitionDate") or tags.get("SeriesDate")
parsed = Case._parse_dicom_date(raw_date)
if not parsed:
@@ -1520,6 +1520,14 @@ class Series(SeriesBase):
self.pk, self.get_examination_full(), self.description, case_id
)
def get_viewer_stack_description(self) -> str:
description = self.description or str(self.examination or "Series")
if self.plane:
description = f"{description} ({self.plane})"
if self.contrast:
description = f"{description} / {self.contrast}"
return description
def get_absolute_url(self):
return reverse("atlas:series_detail", kwargs={"pk": self.pk})
@@ -1558,10 +1566,7 @@ class Series(SeriesBase):
# else:
# instances.append(image.get_image_dicom_json(image_index))
description = f"{self.examination} ({self.plane})"
if self.contrast and self.contrast is not None:
description = f"{description} / {self.contrast}"
series_json["SeriesDescription"] = description
series_json["SeriesDescription"] = self.get_viewer_stack_description()
series_json["instances"] = instances
return series_json
@@ -6,7 +6,7 @@
id="series-block-{{ series.pk }}"
data-series-id="{{series.pk}}"
data-series-label="Series {{ forloop.counter }}"
data-series-name="{{ series|escape }}"
data-series-name="{{ series.get_viewer_stack_description|escape }}"
data-image-ids='{{ series.get_image_url_array_and_count.0 }}'
data-series-detail-url="{% url 'atlas:series_detail' pk=series.pk %}"
data-series-popup-url="/atlas/series/{{series.pk}}"
@@ -43,7 +43,7 @@
class="btn btn-link btn-sm text-muted series-open-primary-btn"
title="View series in viewer"
data-series-id="{{series.pk}}"
data-series-name="{{ series|escape }}">
data-series-name="{{ series.get_viewer_stack_description|escape }}">
<i class="bi bi-eye"></i> View
</button>
<div class="series-card-inline-actions">
@@ -57,7 +57,7 @@
class="btn btn-outline-info btn-sm series-open-new-viewport-btn d-none"
title="View series in a new pane"
data-series-id="{{series.pk}}"
data-series-name="{{ series|escape }}"
data-series-name="{{ series.get_viewer_stack_description|escape }}"
tabindex="-1"
aria-hidden="true">
<i class="bi bi-layout-split"></i> View in new pane
@@ -1357,7 +1357,9 @@
}
document.querySelectorAll(".select-series-btn").forEach(function(btn) {
btn.addEventListener("click", function() {
btn.addEventListener("click", function(event) {
event.preventDefault();
event.stopPropagation();
const parent = btn.closest(".series-block");
toggleSeriesSelection(parent);
});
@@ -0,0 +1,20 @@
from __future__ import annotations
import pytest
from atlas.models import SeriesImage, _populate_case_study_date_on_series_image_save
@pytest.mark.django_db
def test_series_viewer_stack_description_includes_plane_and_contrast(create_series):
series = create_series
assert series.get_viewer_stack_description() == "Test Examination (Test Plane) / Test Contrast"
assert series.get_series_dicom_json()["SeriesDescription"] == "Test Examination (Test Plane) / Test Contrast"
@pytest.mark.django_db
def test_series_image_save_hook_handles_missing_basic_dicom_tags(create_series):
image = SeriesImage(series=create_series)
_populate_case_study_date_on_series_image_save(SeriesImage, image)
+1
View File
@@ -3576,6 +3576,7 @@ def uploads_import_htmx(request, case_id: int | None = None):
imported = import_dicoms_helper(request, case_id=case_id, dicoms=dicoms)
except Exception as exc:
logger.exception("Error during uploads import")
logging.getLogger(__name__).exception("Error during uploads import")
return HttpResponse(
f'<div class="alert alert-danger mb-0">Import failed: {escape(str(exc))}</div>',
status=500,