From d38583180b6f0e5e5ffdddc58186b902c768699f Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 21 Jan 2021 19:13:19 +0000 Subject: [PATCH] . --- rapids/tables.py | 18 +++++++++++++++++- .../templates/rapids/rapid_display_block.html | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/rapids/tables.py b/rapids/tables.py index a11c49ce..aa2de77f 100755 --- a/rapids/tables.py +++ b/rapids/tables.py @@ -3,6 +3,21 @@ from django_tables2.utils import A from .models import Rapid +from django.utils.html import format_html + +from easy_thumbnails.files import get_thumbnailer + +from easy_thumbnails.exceptions import InvalidImageFormatError + + +class ImageColumn(tables.Column): + def render(self, value): + try: + thumbnailer = get_thumbnailer(value) + return format_html('', thumbnailer["exam-list"]) + except InvalidImageFormatError: + return format_html('Invalid image url', value) + class RapidTable(tables.Table): edit = tables.LinkColumn('rapids:rapid_update', @@ -17,10 +32,11 @@ class RapidTable(tables.Table): text='Clone', args=[A('pk')], orderable=False) + image = ImageColumn("image", orderable=False) class Meta: model = Rapid template_name = "django_tables2/bootstrap4.html" fields = ("normal", "abnormality", "region", "examination", "laterality", "site", "created_date", "author") - sequence = ("view", ) \ No newline at end of file + sequence = ("view", "image") \ No newline at end of file diff --git a/rapids/templates/rapids/rapid_display_block.html b/rapids/templates/rapids/rapid_display_block.html index 054020a1..1b39cd60 100755 --- a/rapids/templates/rapids/rapid_display_block.html +++ b/rapids/templates/rapids/rapid_display_block.html @@ -11,8 +11,8 @@

Images: {% for image in rapid.images.all %} Image {{ forloop.counter }}{% if image.feedback_image %} [feedback image]{% endif %}: -
-

+ +
{% endfor %}

Feedback: {{ rapid.feedback }}

Author(s): {% for author in rapid.author.all %}