.
This commit is contained in:
+17
-1
@@ -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('<img src="/media/{}" />', thumbnailer["exam-list"])
|
||||
except InvalidImageFormatError:
|
||||
return format_html('<span title="{}">Invalid image url<span>', 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", )
|
||||
sequence = ("view", "image")
|
||||
@@ -11,8 +11,8 @@
|
||||
<p class="pre-whitespace"><b>Images:</b>
|
||||
{% for image in rapid.images.all %}
|
||||
Image {{ forloop.counter }}{% if image.feedback_image %} [feedback image]{% endif %}:
|
||||
<img class="rapid-img {% if image.feedback_image %}feedback-img{% endif %}" src="{{ image.image.url }}"><br/>
|
||||
<div class="dicom-image" data-url="http://penracourses.org.uk{{ image.image.url}}"></div>
|
||||
<!-- <img class="rapid-img {% if image.feedback_image %}feedback-img{% endif %}" src="{{ image.image.url }}"><br/> -->
|
||||
<div class="dicom-image rapid-img {% if image.feedback_image %}feedback-img{% endif %}" data-url="http://penracourses.org.uk{{ image.image.url}}"></div>
|
||||
{% endfor %}</p>
|
||||
<p class="pre-whitespace"><b>Feedback:</b> {{ rapid.feedback }}</p>
|
||||
<p><b>Author(s):</b> {% for author in rapid.author.all %} <a
|
||||
|
||||
Reference in New Issue
Block a user