diff --git a/atlas/api.py b/atlas/api.py index bc16dcf7..c6057cbd 100644 --- a/atlas/api.py +++ b/atlas/api.py @@ -3,6 +3,8 @@ from typing import List, Tuple from django.shortcuts import get_object_or_404 from ninja import ModelSchema, Router, Schema, Field +from django.db import transaction + # from .decorators import user_is_author_or_rapid_checker from django.core.exceptions import PermissionDenied import pydicom @@ -123,7 +125,8 @@ def import_dicoms_helper(request, case_id: int | None = None): # Check if series with the id already exists (in which case we just add to htat) try: - series = Series.objects.get(series_instance_uid=tags["SeriesInstanceUID"]) + with transaction.atomic(): + series = Series.objects.get(series_instance_uid=tags["SeriesInstanceUID"]) except Series.DoesNotExist: series = Series( modality=modality, @@ -240,7 +243,8 @@ def check_images_hashes(request, hashes: List[str]): for hash in hashes: try: # TOOD also check against uncategorised dicoms? - series_image = SeriesImage.objects.get(image_blake3_hash=hash) + with transaction.atomic(): + series_image = SeriesImage.objects.get(image_blake3_hash=hash) data = { "id": series_image.pk, "url": series_image.series.get_absolute_url(), diff --git a/atlas/templates/atlas/viewer.html b/atlas/templates/atlas/viewer.html index e01c3bda..3177ff8e 100644 --- a/atlas/templates/atlas/viewer.html +++ b/atlas/templates/atlas/viewer.html @@ -32,6 +32,7 @@ console.log(event); if (event.data.type == "open") { document.getElementById("viewer").src = event.data.url; + document.querySelectorAll("[data-cy='seriesList-btn']")[0].click() bc.postMessage({"type": "open-complete", "url" : event.data.url}); } }; diff --git a/rcr/tests/test_models.py b/rcr/tests/test_rcr_models.py similarity index 100% rename from rcr/tests/test_models.py rename to rcr/tests/test_rcr_models.py