This commit is contained in:
Ross
2022-05-25 16:50:18 +01:00
parent 41a09ea30d
commit 5701c8d613
30 changed files with 402 additions and 226 deletions
+21 -3
View File
@@ -34,12 +34,12 @@ class LongImageColumn(tables.Column):
class LongSeriesImageColumn(tables.Column):
def render(self, value):
obj = value.first()
obj = value.all()
if obj is None:
if not obj:
return "None"
image_object = obj.image
image_object = obj[0].image
try:
thumbnailer = get_thumbnailer(image_object)
return format_html('<img src="/media/{}" /><br/>[{}]', thumbnailer["exam-list"], value.count())
@@ -73,6 +73,15 @@ class LongTable(tables.Table):
fields = ("description", "history", "created_date", "author")
sequence = ("view", "series", "exams")
def __init__(self, data=None, *args, **kwargs):
super().__init__(
data.prefetch_related(
"series", "author", "exams", "series__images", "series__examination", "series__plane", "series__contrast"
),
*args,
**kwargs,
)
class PopupLinkColumn(tables.Column):
def render(self, value):
return format_html("<span>test: {}<span>", value)
@@ -111,6 +120,15 @@ class LongSeriesTable(tables.Table):
fields = ("modality", "examination", "description", "author")
sequence = ("view", "popup", "images", "long")
def __init__(self, data=None, *args, **kwargs):
super().__init__(
data.prefetch_related(
"long", "long__series", "images", "author", "examination", "plane", "contrast", "modality"
),
*args,
**kwargs,
)
def render_popup(self, value, record):
print(self)
return format_html("""<a href="#" onclick="return window.create_popup_window('/longs/series/{}', 'Series')" >Popup</a>""", record.pk)