.
This commit is contained in:
+24
-8
@@ -12,10 +12,12 @@ from easy_thumbnails.exceptions import InvalidImageFormatError
|
||||
|
||||
class AtlasImageColumn(tables.Column):
|
||||
def render(self, value):
|
||||
blocks =[]
|
||||
blocks = []
|
||||
for obj in value.all():
|
||||
blocks.append(obj.get_block())
|
||||
return format_html("<span class='multi-image-block'>{}</span>".format("".join(blocks)))
|
||||
return format_html(
|
||||
"<span class='multi-image-block'>{}</span>".format("".join(blocks))
|
||||
)
|
||||
|
||||
obj = value.first()
|
||||
|
||||
@@ -42,14 +44,22 @@ class SeriesImageColumn(tables.Column):
|
||||
image_object = obj.image
|
||||
try:
|
||||
thumbnailer = get_thumbnailer(image_object)
|
||||
return format_html('<img src="/media/{}" /><br/>[{}]', thumbnailer["exam-list"], value.count())
|
||||
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())
|
||||
return format_html(
|
||||
'<span title="{}">Invalid image url<span><br/>[{}]',
|
||||
image_object,
|
||||
value.count(),
|
||||
)
|
||||
|
||||
|
||||
class AtlasTable(tables.Table):
|
||||
edit = tables.LinkColumn(
|
||||
"atlas:atlas_update", text="Edit", args=[A("pk")], orderable=False
|
||||
"atlas:case_update", text="Edit", args=[A("pk")], orderable=False
|
||||
)
|
||||
view = tables.LinkColumn(
|
||||
"atlas:case_detail", text="View", args=[A("pk")], orderable=False
|
||||
@@ -58,11 +68,11 @@ class AtlasTable(tables.Table):
|
||||
"atlas:case_clone", text="Clone", args=[A("pk")], orderable=False
|
||||
)
|
||||
delete = tables.LinkColumn(
|
||||
"atlas:atlas_delete", text="Delete", args=[A("pk")], orderable=False
|
||||
"atlas:case_delete", text="Delete", args=[A("pk")], orderable=False
|
||||
)
|
||||
series = AtlasImageColumn("Images", orderable=False)
|
||||
|
||||
#series = tables.ManyToManyColumn(verbose_name="Exams")
|
||||
# series = tables.ManyToManyColumn(verbose_name="Exams")
|
||||
exams = tables.ManyToManyColumn(verbose_name="Exams")
|
||||
|
||||
selection = tables.CheckBoxColumn(accessor="pk", orderable=False)
|
||||
@@ -73,6 +83,7 @@ class AtlasTable(tables.Table):
|
||||
fields = ("description", "history", "created_date", "author")
|
||||
sequence = ("view", "series", "exams")
|
||||
|
||||
|
||||
class PopupLinkColumn(tables.Column):
|
||||
def render(self, value):
|
||||
return format_html("<span>test: {}<span>", value)
|
||||
@@ -83,10 +94,12 @@ class PopupLinkColumn(tables.Column):
|
||||
|
||||
return obj.get_thumbnail()[0]
|
||||
|
||||
|
||||
def create_link(test):
|
||||
print(test)
|
||||
return "Hello"
|
||||
|
||||
|
||||
class SeriesTable(tables.Table):
|
||||
edit = tables.LinkColumn(
|
||||
"atlas:series_update", text="Edit", args=[A("pk")], orderable=False
|
||||
@@ -111,4 +124,7 @@ class SeriesTable(tables.Table):
|
||||
|
||||
def render_popup(self, value, record):
|
||||
print(self)
|
||||
return format_html("""<a href="#" onclick="return window.create_popup_window('/atlas/series/{}', 'Series')" >Popup</a>""", record.pk)
|
||||
return format_html(
|
||||
"""<a href="#" onclick="return window.create_popup_window('/atlas/series/{}', 'Series')" >Popup</a>""",
|
||||
record.pk,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user