diff --git a/anatomy/templates/anatomy/exam_overview.html b/anatomy/templates/anatomy/exam_overview.html
index 5c7c43de..fda4465c 100644
--- a/anatomy/templates/anatomy/exam_overview.html
+++ b/anatomy/templates/anatomy/exam_overview.html
@@ -15,7 +15,13 @@
-
+
+ {% if question.image %}
+
+ {% else %}
+ No image added.
+ {% endif %}
+
diff --git a/generic/models.py b/generic/models.py
index c4ab7401..d417a405 100644
--- a/generic/models.py
+++ b/generic/models.py
@@ -231,6 +231,29 @@ class QuestionBase(models.Model, AuthorMixin, QuestionMixin):
return False
+ def get_thumbnail(self, recreate=False, fail_loudly=False):
+ images = self.images.all()
+
+ if len(images) < 1:
+ return "No images", 0
+
+ img = findMiddle(images).image
+ try:
+ thumbnailer = get_thumbnailer(img)
+ if recreate:
+ thumbnailer.delete_thumbnails()
+ thumbnail = thumbnailer["exam-list"]
+
+ except InvalidImageFormatError as e:
+ if fail_loudly:
+ raise e
+ return format_html(
+ '
', img
+ ), len(images)
+ return format_html('
', thumbnail), len(images)
+
+
+
class SeriesImageBase(models.Model):
"""
diff --git a/generic/urls.py b/generic/urls.py
index 37a71cd9..5efa64b7 100755
--- a/generic/urls.py
+++ b/generic/urls.py
@@ -265,6 +265,8 @@ def generic_view_urls(generic_views: GenericViewBase):
path(
"question//", generic_views.question_detail, name="question_detail"
),
+ path("question//thumbnail/fail", generic_views.question_thumbnail_fail, name="series_thumbnail_fail"),
+ path("question//thumbnail", generic_views.question_thumbnail, name="series_thumbnail"),
path(
"question//user_answers",
generic_views.question_user_answers,
diff --git a/generic/views.py b/generic/views.py
index 2ca12d98..02e8c8fc 100644
--- a/generic/views.py
+++ b/generic/views.py
@@ -2639,6 +2639,18 @@ class GenericViewBase:
self.cid_user_answer_object.objects.get(pk=id).delete()
return JsonResponse({"status": "success"})
+ @method_decorator(login_required)
+ def question_thumbnail_fail(self, request, pk):
+ return self.question_thumbnail(request, pk=pk, fail_loudly=True)
+
+ @method_decorator(login_required)
+ def question_thumbnail(self, request, pk, fail_loudly=False):
+ question = get_object_or_404(self.question_object, pk=pk)
+
+ thumbnail, _ = question.get_thumbnail(recreate=True, fail_loudly=fail_loudly)
+
+ return HttpResponse(thumbnail)
+
@method_decorator(login_required)
def question_detail(self, request, pk):
question: QuestionBase = get_object_or_404(self.question_object, pk=pk)
diff --git a/rapids/templates/rapids/exam_overview.html b/rapids/templates/rapids/exam_overview.html
index 495263ea..06649893 100644
--- a/rapids/templates/rapids/exam_overview.html
+++ b/rapids/templates/rapids/exam_overview.html
@@ -22,6 +22,8 @@
{% for image in question.get_images %}
+ {% empty %}
+ No image added.
{% endfor %}
diff --git a/shorts/templates/shorts/exam_overview.html b/shorts/templates/shorts/exam_overview.html
index ffe482aa..b9196862 100644
--- a/shorts/templates/shorts/exam_overview.html
+++ b/shorts/templates/shorts/exam_overview.html
@@ -22,18 +22,21 @@
{% for image in question.get_images %}
+ {% empty %}
+ No image added.
{% endfor %}
-
+
{% if question.get_best_sample_answer %}
- {{ question.get_best_sample_answer }}
+ {{ question.get_best_sample_answer }} (Score: {{question.get_best_sample_answer.score}})
{% else %}
- No sample answer available.
+ No sample answer available. Add one now?
{% endif %}
+
Examination: {{ question.get_examinations }},
diff --git a/shorts/views.py b/shorts/views.py
index 419ff3ac..cbf70159 100644
--- a/shorts/views.py
+++ b/shorts/views.py
@@ -117,8 +117,6 @@ def question_split(request, pk):
images = question.images.all()
- old_abnormality = question.abnormality.all()
- old_region = question.region.all()
old_examination = question.examination.all()
# old_site = rapid.site.all()
old_author = question.author.all()
@@ -131,8 +129,6 @@ def question_split(request, pk):
question.save()
- question.abnormality.set(old_abnormality)
- question.region.set(old_region)
question.examination.set(old_examination)
# question.site.set(old_site)
question.author.set(old_author)
@@ -197,8 +193,6 @@ class QuestionCreateBase(RevisionMixin, LoginRequiredMixin, CreateView):
# @login_required
class QuestionCreate(QuestionCreateBase):
- # initial = {"laterality": Question.NONE}
-
def get_initial(self):
if "pk" in self.kwargs:
initial = super().get_initial()