Commit fbdc5dea authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch 'fix/566-photos-unavailable' into 'master'

Fix availability of photo albums on the website

Closes #566

See merge request !714
parents 2fb4a6e2 6b9e2f32
...@@ -14,8 +14,8 @@ class AlbumsViewSet(ModelViewSet): ...@@ -14,8 +14,8 @@ class AlbumsViewSet(ModelViewSet):
queryset = Album.objects.all() queryset = Album.objects.all()
def get_queryset(self): def get_queryset(self):
return services.annotate_accessible_albums(self.request, return services.get_annotated_accessible_albums(self.request,
Album.objects.all()) Album.objects.all())
def create(self, request, *args, **kwargs): def create(self, request, *args, **kwargs):
if self.request.user.has_perm('photos.create_album'): if self.request.user.has_perm('photos.create_album'):
......
...@@ -18,7 +18,7 @@ def is_album_accessible(request, album): ...@@ -18,7 +18,7 @@ def is_album_accessible(request, album):
# Annotate the albums which are accessible by the user # Annotate the albums which are accessible by the user
def annotate_accessible_albums(request, albums): def get_annotated_accessible_albums(request, albums):
if request.member and request.member.current_membership is None: if request.member and request.member.current_membership is None:
# The user is currently not a member # The user is currently not a member
# so only show photos that were made during their membership # so only show photos that were made during their membership
...@@ -49,4 +49,4 @@ def can_view_album(request, album): ...@@ -49,4 +49,4 @@ def can_view_album(request, album):
filter = Q(since__lte=album.date) & (Q(until__gte=album.date) | filter = Q(since__lte=album.date) & (Q(until__gte=album.date) |
Q(until=None)) Q(until=None))
return request.member.membership_set.filter(filter).count() > 0 return request.member.membership_set.filter(filter).count() > 0
return False return True
...@@ -22,7 +22,7 @@ def index(request): ...@@ -22,7 +22,7 @@ def index(request):
# Only show published albums # Only show published albums
albums = Album.objects.filter(hidden=False) albums = Album.objects.filter(hidden=False)
services.annotate_accessible_albums(request, albums) albums = services.get_annotated_accessible_albums(request, albums)
albums = albums.order_by('-date') albums = albums.order_by('-date')
paginator = Paginator(albums, 12) paginator = Paginator(albums, 12)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment