38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
import django_tables2 as tables
|
|
from django_tables2.utils import A
|
|
|
|
from .models import AnatomyQuestion
|
|
|
|
from django.utils.html import format_html
|
|
|
|
from easy_thumbnails.files import get_thumbnailer
|
|
|
|
class ImageColumn(tables.Column):
|
|
def render(self, value):
|
|
thumbnailer = get_thumbnailer(value)
|
|
return format_html('<img src="/media/{}" />', thumbnailer["exam-list"])
|
|
|
|
|
|
|
|
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)
|
|
image = ImageColumn("image", orderable=False)
|
|
#clone = tables.LinkColumn('anatomy:anatomy_question_clone',
|
|
# text='Clone',
|
|
# args=[A('pk')],
|
|
# orderable=False)
|
|
exams = tables.ManyToManyColumn(verbose_name="Exams")
|
|
|
|
class Meta:
|
|
model = AnatomyQuestion
|
|
template_name = "django_tables2/bootstrap4.html"
|
|
fields = ("question_type", "description", "examination", "modality", "region",
|
|
"body_part", "created_date", "open_access", "author")
|
|
sequence = ("view", "image", "exams") |