From ab9b16e7f9371335d80a0306ece21bba88471b08 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 15 Apr 2024 10:07:27 +0100 Subject: [PATCH] allow basic thumbnail recreation --- atlas/templates/atlas/series_image_dicom.html | 4 ++++ atlas/urls.py | 1 + atlas/views.py | 9 +++++++++ generic/models.py | 4 +++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/atlas/templates/atlas/series_image_dicom.html b/atlas/templates/atlas/series_image_dicom.html index 30b15603..bbed0993 100755 --- a/atlas/templates/atlas/series_image_dicom.html +++ b/atlas/templates/atlas/series_image_dicom.html @@ -4,5 +4,9 @@
{{image.get_dicom_info|safe}} +
+ Download DICOM Image +
+ {% endblock %} diff --git a/atlas/urls.py b/atlas/urls.py index 6fd077d5..49d3b61c 100755 --- a/atlas/urls.py +++ b/atlas/urls.py @@ -241,6 +241,7 @@ urlpatterns = [ name="structure_update", ), path("structure/create", views.StructureCreate.as_view(), name="structure_create"), + path("series//thumbnail", views.series_thumbnail, name="series_thumbnail"), path("series/", views.series_detail, name="series_detail"), path("series//authors", views.SeriesAuthorUpdate.as_view(), name="series_authors"), path("series/", views.SeriesView.as_view(), name="series_view"), diff --git a/atlas/views.py b/atlas/views.py index 131185e9..8a286fcf 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -184,6 +184,15 @@ def case_detail(request, pk): # logging.debug(atlas.subspecialty.first().name.all()) return render(request, "atlas/case_detail.html", {"case": case}) +@login_required +@user_is_author_or_atlas_series_checker_or_atlas_marker +def series_thumbnail(request, pk, finding_pk=None): + series = get_object_or_404(Series, pk=pk) + + thumbnail, _ = series.get_thumbnail(recreate=True) + + return HttpResponse(thumbnail) + @login_required @user_is_author_or_atlas_series_checker_or_atlas_marker diff --git a/generic/models.py b/generic/models.py index a0ca3931..a75f2097 100644 --- a/generic/models.py +++ b/generic/models.py @@ -404,7 +404,7 @@ class SeriesBase(models.Model): else: return format_html('", "'.join(images)) - def get_thumbnail(self): + def get_thumbnail(self, recreate=False): images = self.images.filter(removed=False) if len(images) < 1: @@ -413,6 +413,8 @@ class SeriesBase(models.Model): img = findMiddle(images).image try: thumbnailer = get_thumbnailer(img) + if recreate: + thumbnailer.delete_thumbnails() thumbnail = thumbnailer["exam-list"] except InvalidImageFormatError: return format_html(