diff --git a/atlas/urls.py b/atlas/urls.py
index 26046407..07db0ee4 100755
--- a/atlas/urls.py
+++ b/atlas/urls.py
@@ -480,6 +480,11 @@ urlpatterns = [
views.series_truncate_htmx,
name="series_truncate",
),
+ path(
+ "series/
/image_size/",
+ views.series_image_size_htmx,
+ name="series_image_size",
+ ),
path("series//images/", views.series_images_partial, name="series_images"),
path("series//authors", views.SeriesAuthorUpdate.as_view(), name="series_authors"),
path("series//finding/related", views.series_finding_related, name="series_finding_related"),
diff --git a/atlas/views.py b/atlas/views.py
index 34915078..511677d1 100755
--- a/atlas/views.py
+++ b/atlas/views.py
@@ -13,6 +13,7 @@ from django.views.decorators.http import require_POST
from django.views.decorators.http import require_http_methods
from django.template.loader import render_to_string
from django.db.models import Count
+from django.template.defaultfilters import filesizeformat
# from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required, user_passes_test
@@ -235,6 +236,42 @@ def series_truncate_htmx(request, series_id, start, end):
return HttpResponse(html)
+@login_required
+def series_image_size_htmx(request, series_id):
+ """HTMX endpoint returning the total size of images in a series.
+
+ If `?refresh=1` is provided the size will be recalculated.
+ """
+ series = get_object_or_404(Series, pk=series_id)
+
+ # Permission: reuse existing series permission check if available
+ try:
+ can_view = series.check_user_can_view(request.user)
+ except Exception:
+ # fallback to basic permission: allow authenticated users
+ can_view = True
+
+ if not can_view:
+ return HttpResponse("Permission denied
")
+
+ refresh = request.GET.get("refresh") in ("1", "true", "True")
+
+ try:
+ size_bytes = series.get_total_image_size(refresh=refresh)
+ except Exception:
+ size_bytes = 0
+
+ human = filesizeformat(size_bytes)
+
+ html = render_to_string(
+ "atlas/partials/_series_image_size.html",
+ {"series": series, "size_bytes": size_bytes, "size_human": human, "refresh": refresh},
+ request=request,
+ )
+
+ return HttpResponse(html)
+
+
@login_required
def case_search_partial(request):
"""Return an HTMX partial listing cases matching the query parameter `q`.