Hide empty galleries
This commit is contained in:
parent
4b3cf83181
commit
3c8e34db92
1 changed files with 8 additions and 2 deletions
|
|
@ -26,8 +26,14 @@ from .models import Gallery, Photo, Tag
|
||||||
class GalleryDateView(LoginRequiredMixin):
|
class GalleryDateView(LoginRequiredMixin):
|
||||||
model = Gallery
|
model = Gallery
|
||||||
date_field = 'date_start'
|
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):
|
class GalleryArchiveIndexView(GalleryDateView, ArchiveIndexView):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue