see if atomic transactions fixes case uploads
This commit is contained in:
+6
-2
@@ -3,6 +3,8 @@ from typing import List, Tuple
|
|||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from ninja import ModelSchema, Router, Schema, Field
|
from ninja import ModelSchema, Router, Schema, Field
|
||||||
|
|
||||||
|
from django.db import transaction
|
||||||
|
|
||||||
# from .decorators import user_is_author_or_rapid_checker
|
# from .decorators import user_is_author_or_rapid_checker
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
import pydicom
|
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)
|
# Check if series with the id already exists (in which case we just add to htat)
|
||||||
try:
|
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:
|
except Series.DoesNotExist:
|
||||||
series = Series(
|
series = Series(
|
||||||
modality=modality,
|
modality=modality,
|
||||||
@@ -240,7 +243,8 @@ def check_images_hashes(request, hashes: List[str]):
|
|||||||
for hash in hashes:
|
for hash in hashes:
|
||||||
try:
|
try:
|
||||||
# TOOD also check against uncategorised dicoms?
|
# 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 = {
|
data = {
|
||||||
"id": series_image.pk,
|
"id": series_image.pk,
|
||||||
"url": series_image.series.get_absolute_url(),
|
"url": series_image.series.get_absolute_url(),
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
console.log(event);
|
console.log(event);
|
||||||
if (event.data.type == "open") {
|
if (event.data.type == "open") {
|
||||||
document.getElementById("viewer").src = event.data.url;
|
document.getElementById("viewer").src = event.data.url;
|
||||||
|
document.querySelectorAll("[data-cy='seriesList-btn']")[0].click()
|
||||||
bc.postMessage({"type": "open-complete", "url" : event.data.url});
|
bc.postMessage({"type": "open-complete", "url" : event.data.url});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user