.
This commit is contained in:
+26
-14
@@ -7,24 +7,27 @@ 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):
|
||||
thumbnailer = get_thumbnailer(value)
|
||||
return format_html('<img src="/media/{}" />', thumbnailer["exam-list"])
|
||||
|
||||
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 AnatomyQuestionTable(tables.Table):
|
||||
edit = tables.LinkColumn('anatomy:anatomy_question_update',
|
||||
text='Edit',
|
||||
args=[A('pk')],
|
||||
orderable=False)
|
||||
view = tables.LinkColumn('anatomy:question_detail',
|
||||
text='View',
|
||||
args=[A('pk')],
|
||||
orderable=False)
|
||||
edit = tables.LinkColumn(
|
||||
"anatomy:anatomy_question_update", text="Edit", args=[A("pk")], orderable=False
|
||||
)
|
||||
view = tables.LinkColumn(
|
||||
"anatomy:question_detail", text="View", args=[A("pk")], orderable=False
|
||||
)
|
||||
image = ImageColumn("image", orderable=False)
|
||||
#clone = tables.LinkColumn('anatomy:anatomy_question_clone',
|
||||
# clone = tables.LinkColumn('anatomy:anatomy_question_clone',
|
||||
# text='Clone',
|
||||
# args=[A('pk')],
|
||||
# orderable=False)
|
||||
@@ -33,6 +36,15 @@ class AnatomyQuestionTable(tables.Table):
|
||||
class Meta:
|
||||
model = AnatomyQuestion
|
||||
template_name = "django_tables2/bootstrap4.html"
|
||||
fields = ("question_type", "description", "examination", "modality", "region",
|
||||
"body_part", "created_date", "open_access", "author")
|
||||
fields = (
|
||||
"question_type",
|
||||
"description",
|
||||
"examination",
|
||||
"modality",
|
||||
"region",
|
||||
"body_part",
|
||||
"created_date",
|
||||
"open_access",
|
||||
"author",
|
||||
)
|
||||
sequence = ("view", "image", "exams")
|
||||
Reference in New Issue
Block a user