Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Marzal
funkwhale
Commits
bf6fe44b
Verified
Commit
bf6fe44b
authored
7 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
More filters / ordering option on playlist API
parent
f503466a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/funkwhale_api/playlists/filters.py
+9
-0
9 additions, 0 deletions
api/funkwhale_api/playlists/filters.py
api/funkwhale_api/playlists/views.py
+2
-2
2 additions, 2 deletions
api/funkwhale_api/playlists/views.py
with
11 additions
and
2 deletions
api/funkwhale_api/playlists/filters.py
+
9
−
0
View file @
bf6fe44b
from
django_filters
import
rest_framework
as
filters
from
funkwhale_api.music
import
utils
from
.
import
models
class
PlaylistFilter
(
filters
.
FilterSet
):
q
=
filters
.
CharFilter
(
name
=
'
_
'
,
method
=
'
filter_q
'
)
class
Meta
:
model
=
models
.
Playlist
fields
=
{
'
user
'
:
[
'
exact
'
],
'
name
'
:
[
'
exact
'
,
'
icontains
'
],
'
q
'
:
'
exact
'
,
}
def
filter_q
(
self
,
queryset
,
name
,
value
):
query
=
utils
.
get_query
(
value
,
[
'
name
'
,
'
user__username
'
])
return
queryset
.
filter
(
query
)
This diff is collapsed.
Click to expand it.
api/funkwhale_api/playlists/views.py
+
2
−
2
View file @
bf6fe44b
...
...
@@ -8,15 +8,14 @@ from rest_framework.decorators import detail_route
from
rest_framework.response
import
Response
from
rest_framework.permissions
import
IsAuthenticatedOrReadOnly
from
funkwhale_api.music.models
import
Track
from
funkwhale_api.common
import
permissions
from
funkwhale_api.common
import
fields
from
funkwhale_api.music.models
import
Track
from
.
import
filters
from
.
import
models
from
.
import
serializers
class
PlaylistViewSet
(
mixins
.
RetrieveModelMixin
,
mixins
.
CreateModelMixin
,
...
...
@@ -37,6 +36,7 @@ class PlaylistViewSet(
]
owner_checks
=
[
'
write
'
]
filter_class
=
filters
.
PlaylistFilter
ordering_fields
=
(
'
id
'
,
'
name
'
,
'
creation_date
'
,
'
modification_date
'
)
def
get_serializer_class
(
self
):
if
self
.
request
.
method
in
[
'
PUT
'
,
'
PATCH
'
,
'
DELETE
'
,
'
POST
'
]:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment