tidy up table image dlocks
This commit is contained in:
+2
-48
@@ -1,6 +1,8 @@
|
||||
import django_tables2 as tables
|
||||
from django_tables2.utils import A
|
||||
|
||||
from generic.tables import SeriesImageColumn
|
||||
|
||||
from .models import (
|
||||
Case,
|
||||
Condition,
|
||||
@@ -19,53 +21,7 @@ from easy_thumbnails.files import get_thumbnailer
|
||||
from easy_thumbnails.exceptions import InvalidImageFormatError
|
||||
|
||||
|
||||
class AtlasImageColumn(tables.Column):
|
||||
def render(self, value):
|
||||
blocks = []
|
||||
for obj in value.all():
|
||||
blocks.append(obj.get_block())
|
||||
return format_html(
|
||||
"""<span class='multi-image-block'>
|
||||
{}
|
||||
</span>""".format("".join(blocks))
|
||||
)
|
||||
|
||||
obj = value.first()
|
||||
|
||||
if obj is None:
|
||||
return format_html("<span>No image<span>")
|
||||
|
||||
return obj.get_thumbnail()[0]
|
||||
|
||||
# image_object = obj.image
|
||||
# try:
|
||||
# thumbnailer = get_thumbnailer(image_object)
|
||||
# return format_html('<img src="/media/{}" />', thumbnailer["exam-list"])
|
||||
# except InvalidImageFormatError:
|
||||
# return format_html('<span title="{}">Invalid image url<span>', image_object)
|
||||
|
||||
|
||||
class SeriesImageColumn(tables.Column):
|
||||
def render(self, value):
|
||||
obj = value.first()
|
||||
|
||||
if obj is None:
|
||||
return "None"
|
||||
|
||||
image_object = obj.image
|
||||
try:
|
||||
thumbnailer = get_thumbnailer(image_object)
|
||||
return format_html(
|
||||
'<img src="/media/{}" /><br/>[{}]',
|
||||
thumbnailer["exam-list"],
|
||||
value.count(),
|
||||
)
|
||||
except InvalidImageFormatError:
|
||||
return format_html(
|
||||
'<span title="{}">Invalid image url<span><br/>[{}]',
|
||||
image_object,
|
||||
value.count(),
|
||||
)
|
||||
|
||||
|
||||
class CaseTable(tables.Table):
|
||||
@@ -81,7 +37,6 @@ class CaseTable(tables.Table):
|
||||
delete = tables.LinkColumn(
|
||||
"atlas:case_delete", text="Delete", args=[A("pk")], orderable=False
|
||||
)
|
||||
#series = AtlasImageColumn("Images", orderable=False)
|
||||
|
||||
#differential = tables.ManyToManyColumn(verbose_name="Differential")
|
||||
|
||||
@@ -329,7 +284,6 @@ class CaseCollectionTable(tables.Table):
|
||||
delete = tables.LinkColumn(
|
||||
"atlas:collection_delete", text="Delete", args=[A("pk")], orderable=False
|
||||
)
|
||||
#series = AtlasImageColumn("Images", orderable=False)
|
||||
|
||||
#differential = tables.ManyToManyColumn(verbose_name="Differential")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user