Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
cc428fbf
Commit
cc428fbf
authored
May 16, 2018
by
Thom Wiggers
📐
Browse files
Merge branch 'feature/photos-api-filters' into 'master'
Add search filter to photos api See merge request
!795
parents
2c452863
a218b28e
Changes
1
Hide whitespace changes
Inline
Side-by-side
website/photos/api/viewsets.py
View file @
cc428fbf
from
rest_framework
import
permissions
from
rest_framework
import
permissions
,
filters
from
rest_framework.exceptions
import
PermissionDenied
from
rest_framework.mixins
import
CreateModelMixin
,
\
UpdateModelMixin
...
...
@@ -12,6 +12,8 @@ from photos.models import Album, Photo
class
AlbumsViewSet
(
ModelViewSet
):
permission_classes
=
(
permissions
.
IsAuthenticated
,)
queryset
=
Album
.
objects
.
all
()
filter_backends
=
(
filters
.
SearchFilter
,)
search_fields
=
(
'title_en'
,
'title_nl'
,
'date'
,
'slug'
)
def
get_queryset
(
self
):
return
services
.
get_annotated_accessible_albums
(
self
.
request
,
...
...
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