.
This commit is contained in:
+24
-12
@@ -7,24 +7,27 @@ from django.utils.html import format_html
|
|||||||
|
|
||||||
from easy_thumbnails.files import get_thumbnailer
|
from easy_thumbnails.files import get_thumbnailer
|
||||||
|
|
||||||
|
from easy_thumbnails.exceptions import InvalidImageFormatError
|
||||||
|
|
||||||
|
|
||||||
class ImageColumn(tables.Column):
|
class ImageColumn(tables.Column):
|
||||||
def render(self, value):
|
def render(self, value):
|
||||||
|
try:
|
||||||
thumbnailer = get_thumbnailer(value)
|
thumbnailer = get_thumbnailer(value)
|
||||||
return format_html('<img src="/media/{}" />', thumbnailer["exam-list"])
|
return format_html('<img src="/media/{}" />', thumbnailer["exam-list"])
|
||||||
|
except InvalidImageFormatError:
|
||||||
|
return format_html('<span title="{}">Invalid image url<span>', value)
|
||||||
|
|
||||||
|
|
||||||
class AnatomyQuestionTable(tables.Table):
|
class AnatomyQuestionTable(tables.Table):
|
||||||
edit = tables.LinkColumn('anatomy:anatomy_question_update',
|
edit = tables.LinkColumn(
|
||||||
text='Edit',
|
"anatomy:anatomy_question_update", text="Edit", args=[A("pk")], orderable=False
|
||||||
args=[A('pk')],
|
)
|
||||||
orderable=False)
|
view = tables.LinkColumn(
|
||||||
view = tables.LinkColumn('anatomy:question_detail',
|
"anatomy:question_detail", text="View", args=[A("pk")], orderable=False
|
||||||
text='View',
|
)
|
||||||
args=[A('pk')],
|
|
||||||
orderable=False)
|
|
||||||
image = ImageColumn("image", orderable=False)
|
image = ImageColumn("image", orderable=False)
|
||||||
#clone = tables.LinkColumn('anatomy:anatomy_question_clone',
|
# clone = tables.LinkColumn('anatomy:anatomy_question_clone',
|
||||||
# text='Clone',
|
# text='Clone',
|
||||||
# args=[A('pk')],
|
# args=[A('pk')],
|
||||||
# orderable=False)
|
# orderable=False)
|
||||||
@@ -33,6 +36,15 @@ class AnatomyQuestionTable(tables.Table):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = AnatomyQuestion
|
model = AnatomyQuestion
|
||||||
template_name = "django_tables2/bootstrap4.html"
|
template_name = "django_tables2/bootstrap4.html"
|
||||||
fields = ("question_type", "description", "examination", "modality", "region",
|
fields = (
|
||||||
"body_part", "created_date", "open_access", "author")
|
"question_type",
|
||||||
|
"description",
|
||||||
|
"examination",
|
||||||
|
"modality",
|
||||||
|
"region",
|
||||||
|
"body_part",
|
||||||
|
"created_date",
|
||||||
|
"open_access",
|
||||||
|
"author",
|
||||||
|
)
|
||||||
sequence = ("view", "image", "exams")
|
sequence = ("view", "image", "exams")
|
||||||
Reference in New Issue
Block a user