Refactor case size rendering logic for efficiency and update user uploads field choices

This commit is contained in:
Ross
2026-05-28 23:22:07 +01:00
parent 060333c006
commit 4cc758bc66
2 changed files with 4 additions and 24 deletions
+3 -24
View File
@@ -161,30 +161,9 @@ class CaseTable(SelectionTable):
return "No collections"
def render_case_size(self, value, record):
# Prefer cached case-level value, then model helper.
if value is None:
try:
value = record.get_total_series_images_size()
except Exception:
value = None
value = record.get_total_series_images_size()
# If still missing, fall back to summing per-series sizes.
if value is None:
computed_total = 0
try:
for series in record.series.all():
series_size = series.total_image_size
if series_size is None:
try:
series_size = series.get_total_image_size(refresh=True)
except Exception:
series_size = 0
computed_total += int(series_size or 0)
except Exception:
computed_total = 0
value = computed_total
return filesizeformat(int(value or 0))
return filesizeformat(value)
associated_cases = tables.Column(
verbose_name="Associated Cases", accessor="pk", orderable=False
@@ -195,7 +174,7 @@ class CaseTable(SelectionTable):
)
case_size = tables.Column(
verbose_name="Case size", accessor="total_images_series_size"
verbose_name="Case size", accessor="pk"
)
edit = tables.LinkColumn(
+1
View File
@@ -3461,6 +3461,7 @@ def user_uploads(
"size": 8,
}
)
field.widget.choices = field.choices
return render(
request,