This commit is contained in:
Ross
2021-02-06 14:46:56 +00:00
parent 61d1828357
commit 59062d9977
+23 -29
View File
@@ -15,17 +15,18 @@ class LongImageColumn(tables.Column):
obj = value.first() obj = value.first()
if obj is None: if obj is None:
return format_html('<span>No image<span>') return format_html("<span>No image<span>")
return obj.get_thumbnail()[0] return obj.get_thumbnail()[0]
#image_object = obj.image # image_object = obj.image
#try: # try:
# thumbnailer = get_thumbnailer(image_object) # thumbnailer = get_thumbnailer(image_object)
# return format_html('<img src="/media/{}" />', thumbnailer["exam-list"]) # return format_html('<img src="/media/{}" />', thumbnailer["exam-list"])
#except InvalidImageFormatError: # except InvalidImageFormatError:
# return format_html('<span title="{}">Invalid image url<span>', image_object) # return format_html('<span title="{}">Invalid image url<span>', image_object)
class LongSeriesImageColumn(tables.Column): class LongSeriesImageColumn(tables.Column):
def render(self, value): def render(self, value):
obj = value.first() obj = value.first()
@@ -38,43 +39,36 @@ class LongSeriesImageColumn(tables.Column):
return format_html('<span title="{}">Invalid image url<span>', image_object) return format_html('<span title="{}">Invalid image url<span>', image_object)
class LongTable(tables.Table): class LongTable(tables.Table):
edit = tables.LinkColumn('longs:long_update', edit = tables.LinkColumn(
text='Edit', "longs:long_update", text="Edit", args=[A("pk")], orderable=False
args=[A('pk')], )
orderable=False) view = tables.LinkColumn(
view = tables.LinkColumn('longs:long_detail', "longs:long_detail", text="View", args=[A("pk")], orderable=False
text='View', )
args=[A('pk')], clone = tables.LinkColumn(
orderable=False) "longs:long_clone", text="Clone", args=[A("pk")], orderable=False
clone = tables.LinkColumn('longs:long_clone', )
text='Clone',
args=[A('pk')],
orderable=False)
series = LongImageColumn("Images", orderable=False) series = LongImageColumn("Images", orderable=False)
class Meta: class Meta:
model = Long model = Long
template_name = "django_tables2/bootstrap4.html" template_name = "django_tables2/bootstrap4.html"
fields = ("normal", "abnormality", "region", "examination", fields = ("examination", "created_date", "author")
"laterality", "site", "created_date", "author")
sequence = ("view", "series") sequence = ("view", "series")
class LongSeriesTable(tables.Table): class LongSeriesTable(tables.Table):
edit = tables.LinkColumn('longs:long_series_update', edit = tables.LinkColumn(
text='Edit', "longs:long_series_update", text="Edit", args=[A("pk")], orderable=False
args=[A('pk')], )
orderable=False) view = tables.LinkColumn(
view = tables.LinkColumn('longs:long_series_detail', "longs:long_series_detail", text="View", args=[A("pk")], orderable=False
text='View', )
args=[A('pk')],
orderable=False)
images = LongSeriesImageColumn("Images", orderable=False) images = LongSeriesImageColumn("Images", orderable=False)
class Meta: class Meta:
model = Long model = Long
template_name = "django_tables2/bootstrap4.html" template_name = "django_tables2/bootstrap4.html"
fields = ("normal", "abnormality", "region", "examination", fields = ("modality", "examination", "long", "description", "author")
"laterality", "site", "created_date", "author")
sequence = ("view", "images") sequence = ("view", "images")