diff --git a/photologue/views.py b/photologue/views.py index 01c2abd..8d75d87 100644 --- a/photologue/views.py +++ b/photologue/views.py @@ -26,8 +26,14 @@ from .models import Gallery, Photo, Tag class GalleryDateView(LoginRequiredMixin): model = Gallery date_field = 'date_start' - uses_datetime_field = False # Fix related object access - allow_empty = True + + def get_queryset(self): + """Hide galleries with only private photos""" + qs = super().get_queryset() + if self.request.user.is_staff: + return qs + else: + return qs.filter(photos__is_public=True).distinct() class GalleryArchiveIndexView(GalleryDateView, ArchiveIndexView):