From 060333c006a9feeaf0cf13dd6b8f4cfc5fc680ac Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 28 May 2026 23:15:01 +0100 Subject: [PATCH] Refactor case size rendering logic and update user uploads template for improved UI --- atlas/tables.py | 20 ++++++++++++++++++-- atlas/templates/atlas/user_uploads.html | 2 +- atlas/views.py | 10 ++++------ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/atlas/tables.py b/atlas/tables.py index c5ad1df0..58cfee58 100755 --- a/atlas/tables.py +++ b/atlas/tables.py @@ -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 diff --git a/atlas/templates/atlas/user_uploads.html b/atlas/templates/atlas/user_uploads.html index ee98856b..e96d8ce1 100644 --- a/atlas/templates/atlas/user_uploads.html +++ b/atlas/templates/atlas/user_uploads.html @@ -174,7 +174,7 @@ class="btn btn-primary" >Import {% if case %}into case{% endif %} - +
diff --git a/atlas/views.py b/atlas/views.py index ef053f12..63f50411 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -3455,14 +3455,12 @@ def user_uploads( field = case_series_form.fields.get(field_name) if field is None: continue - attrs = dict(getattr(field.widget, "attrs", {}) or {}) - attrs.update( - { - "data-dropdown-parent": "#caseSeriesModal", - "data-width": "100%", + field.widget = forms.SelectMultiple( + attrs={ + "class": "form-select", + "size": 8, } ) - field.widget.attrs = attrs return render( request,