prefetch data in atlas cables

This commit is contained in:
Ross
2023-10-30 22:07:01 +00:00
parent a9950802ee
commit fbdb187967
+20 -3
View File
@@ -58,7 +58,7 @@ class CaseTable(tables.Table):
def __init__(self, data=None, *args, **kwargs):
super().__init__(
data.prefetch_related(
#"condition", "condition__synonym"
"author",#"condition", "condition__synonym"
),
*args,
**kwargs,
@@ -115,8 +115,16 @@ class SeriesTable(tables.Table):
)
sequence = ("view", "popup", "images", "case")
def __init__(self, data=None, *args, **kwargs):
super().__init__(
data.prefetch_related(
"modality", "case", "examination", "plane", "contrast", "author", "findings", "images"
),
*args,
**kwargs,
)
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,
@@ -147,6 +155,15 @@ class ConditionTable(tables.Table):
fields = ("primary", "subspecialty", "rcr_curriculum_map", "rcr_curriculum")
sequence = ("name",)
def __init__(self, data=None, *args, **kwargs):
super().__init__(
data.prefetch_related(
"subspecialty", "rcr_curriculum_map", "parent"
),
*args,
**kwargs,
)
def render_synonym(self, value, record):
return format_html(record.get_synonym_link())
return f"{record.get_synonym_link()}"
@@ -306,7 +323,7 @@ class CaseCollectionTable(tables.Table):
def __init__(self, data=None, *args, **kwargs):
super().__init__(
data.prefetch_related(
#"condition", "condition__synonym"
"author", #"conditionI"", "condition__synonym"
),
*args,
**kwargs,