From 7d6d9651910b9078c717b1346de0510b38f603ac Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Mar 2022 21:56:04 +0100 Subject: [PATCH] Show private photos count for admins --- photologue/models.py | 5 +++++ photologue/templates/photologue/includes/gallery_sample.html | 1 + 2 files changed, 6 insertions(+) diff --git a/photologue/models.py b/photologue/models.py index d3f32c6..c1148a9 100644 --- a/photologue/models.py +++ b/photologue/models.py @@ -187,7 +187,12 @@ class Gallery(models.Model): else: return self.photos.count() + def photo_private_count(self): + """Return a count of private photos in this gallery.""" + return self.photos.filter(is_public=False).count() + photo_count.short_description = _('count') + photo_private_count.short_description = _('private count') class ImageModel(models.Model): diff --git a/photologue/templates/photologue/includes/gallery_sample.html b/photologue/templates/photologue/includes/gallery_sample.html index 8282074..68f249d 100644 --- a/photologue/templates/photologue/includes/gallery_sample.html +++ b/photologue/templates/photologue/includes/gallery_sample.html @@ -7,6 +7,7 @@
{{ gallery.title }}
{% if gallery.date_start %}

{{ gallery.date_start }}{% if gallery.date_end and gallery.date_end != gallery.date_start %} - {{ gallery.date_end }}{% endif %}

{% endif %} + {% if request.user.is_staff and gallery.photo_private_count %}

{{ gallery.photo_private_count }} photos censurées

{% endif %}