Refactor case size rendering logic and update user uploads template for improved UI

This commit is contained in:
Ross
2026-05-28 23:15:01 +01:00
parent d74cfe73e0
commit 060333c006
3 changed files with 23 additions and 9 deletions
+18 -2
View File
@@ -161,14 +161,30 @@ 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
# If still missing, fall back to summing per-series sizes.
if value is None:
return "-"
return filesizeformat(value)
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))
associated_cases = tables.Column(
verbose_name="Associated Cases", accessor="pk", orderable=False