tidy up table image dlocks

This commit is contained in:
Ross
2023-06-12 12:34:38 +01:00
parent e0f0c7619a
commit d1ba8c87dc
10 changed files with 66 additions and 154 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

+3 -11
View File
@@ -1,6 +1,8 @@
import django_tables2 as tables
from django_tables2.utils import A
from generic.tables import SingleImageColumn
from .models import AnatomyQuestion, UserAnswer
from django.utils.html import format_html
@@ -11,16 +13,6 @@ from easy_thumbnails.exceptions import InvalidImageFormatError
#from generic.tables import UserAnswerTable
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 AnatomyQuestionTable(tables.Table):
edit = tables.LinkColumn(
"anatomy:anatomy_question_update", text="Edit", args=[A("pk")], orderable=False
@@ -28,7 +20,7 @@ class AnatomyQuestionTable(tables.Table):
view = tables.LinkColumn(
"anatomy:question_detail", text="View", args=[A("pk")], orderable=False
)
image = ImageColumn("image", orderable=False)
image = SingleImageColumn("image", orderable=False)
# clone = tables.LinkColumn('anatomy:anatomy_question_clone',
# text='Clone',
# args=[A('pk')],