From 7fc12737c735f3de1aedafb0fe5c1a6a7f7cda2e Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 2 Jan 2025 22:26:00 +0000 Subject: [PATCH] . --- atlas/api.py | 7 ++++++- atlas/models.py | 5 +++++ atlas/templates/atlas/user_upload_viewer.html | 6 +++--- generic/models.py | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/atlas/api.py b/atlas/api.py index 95b99f7a..afc7a583 100644 --- a/atlas/api.py +++ b/atlas/api.py @@ -154,7 +154,12 @@ def import_dicoms_helper(request, case_id: int | None = None): series_list = [] for series_uid in data: - modality = get_object_or_404(Modality, short_code=tags["Modality"]) + try: + modality = Modality.objects.get(short_code=tags["Modality"]) + except Modality.DoesNotExist: + modality = Modality.objects.create(short_code=tags["Modality"], modality=tags["Modality"]) + + tags = data[series_uid][0][1] # Check if series with the id already exists (in which case we just add to htat) diff --git a/atlas/models.py b/atlas/models.py index 80adf126..ec5db7c4 100644 --- a/atlas/models.py +++ b/atlas/models.py @@ -1378,6 +1378,11 @@ class UncategorisedDicom(models.Model): def get_series(self): return self.series + def get_dicom_url(self): + return f"{REMOTE_URL}self.image.url" + + + class DuplicateDicom(Exception): def __init__(self, duplicate): diff --git a/atlas/templates/atlas/user_upload_viewer.html b/atlas/templates/atlas/user_upload_viewer.html index 0c89ef79..57ba0075 100755 --- a/atlas/templates/atlas/user_upload_viewer.html +++ b/atlas/templates/atlas/user_upload_viewer.html @@ -5,7 +5,7 @@

SeriesInstanceUID: {{series_id}}

-
@@ -17,10 +17,10 @@ {% for dicom in dicoms %} {% if dicom.image %} - [{{image.image.size|filesizeformat}}] + [{{dicom.image.size|filesizeformat}}] {% endif %} - {{image.image_md5_hash}} ({{image.is_dicom}}) + {% comment %} {{dicom.image_md5_hash}} ({{dicom.is_dicom}}) {% endcomment %}
diff --git a/generic/models.py b/generic/models.py index 81fd7546..fc326260 100644 --- a/generic/models.py +++ b/generic/models.py @@ -1735,7 +1735,7 @@ class ExamCollection(models.Model, AuthorMixin): ) def __str__(self): - if self.date is not None and self.date is not "": + if self.date is not None and self.date != "": return f"{self.name} [{self.date}]" else: return f"{self.name}"