Show private photos count for admins

This commit is contained in:
Alexandre Iooss 2022-03-01 21:56:04 +01:00
parent aa45386976
commit 7d6d965191
2 changed files with 6 additions and 0 deletions

View file

@ -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):

View file

@ -7,6 +7,7 @@
<div class="card-body">
<h5 class="card-title">{{ gallery.title }}</h5>
{% if gallery.date_start %}<p class="card-text text-muted small mb-0">{{ gallery.date_start }}{% if gallery.date_end and gallery.date_end != gallery.date_start %} - {{ gallery.date_end }}{% endif %}</p>{% endif %}
{% if request.user.is_staff and gallery.photo_private_count %}<p class="card-text text-danger small mb-0">{{ gallery.photo_private_count }} photos censurées</p>{% endif %}
<a href="{{ gallery.get_absolute_url }}" class="stretched-link"></a>
</div>
</div>