Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
concrexit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
70
Issues
70
List
Boards
Labels
Service Desk
Milestones
Merge Requests
10
Merge Requests
10
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
thalia
concrexit
Commits
6b9e2f32
Verified
Commit
6b9e2f32
authored
Feb 09, 2018
by
Sébastiaan Versteeg
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix availability of photo albums on the website
parent
8400b431
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
5 deletions
+5
-5
website/photos/api/viewsets.py
website/photos/api/viewsets.py
+2
-2
website/photos/services.py
website/photos/services.py
+2
-2
website/photos/views.py
website/photos/views.py
+1
-1
No files found.
website/photos/api/viewsets.py
View file @
6b9e2f32
...
...
@@ -14,8 +14,8 @@ class AlbumsViewSet(ModelViewSet):
queryset
=
Album
.
objects
.
all
()
def
get_queryset
(
self
):
return
services
.
annotate
_accessible_albums
(
self
.
request
,
Album
.
objects
.
all
())
return
services
.
get_annotated
_accessible_albums
(
self
.
request
,
Album
.
objects
.
all
())
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
if
self
.
request
.
user
.
has_perm
(
'photos.create_album'
):
...
...
website/photos/services.py
View file @
6b9e2f32
...
...
@@ -18,7 +18,7 @@ def is_album_accessible(request, album):
# 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
:
# The user is currently not a member
# so only show photos that were made during their membership
...
...
@@ -49,4 +49,4 @@ def can_view_album(request, album):
filter
=
Q
(
since__lte
=
album
.
date
)
&
(
Q
(
until__gte
=
album
.
date
)
|
Q
(
until
=
None
))
return
request
.
member
.
membership_set
.
filter
(
filter
).
count
()
>
0
return
Fals
e
return
Tru
e
website/photos/views.py
View file @
6b9e2f32
...
...
@@ -22,7 +22,7 @@ def index(request):
# Only show published albums
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'
)
paginator
=
Paginator
(
albums
,
12
)
...
...
Thom Wiggers
@twiggers
mentioned in commit
ae677965
·
Feb 10, 2018
mentioned in commit
ae677965
mentioned in commit ae677965e340fa208afb1ba27d2b24593ff4174a
Toggle commit list
Sébastiaan Versteeg
@sversteeg
mentioned in merge request
!716 (merged)
·
Feb 10, 2018
mentioned in merge request
!716 (merged)
mentioned in merge request !716
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment