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
Environments
Terraform modules
Monitor
Incidents
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
Philipp Wolfer
funkwhale
Commits
798e3c03
Unverified
Commit
798e3c03
authored
4 years ago
by
Agate
💬
Browse files
Options
Downloads
Patches
Plain Diff
Fix #1078: Include tracks by album artist when filtering by artist on /api/v1/tracks
parent
1638a319
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/funkwhale_api/music/filters.py
+8
-1
8 additions, 1 deletion
api/funkwhale_api/music/filters.py
api/tests/music/test_filters.py
+19
-0
19 additions, 0 deletions
api/tests/music/test_filters.py
changes/changelog.d/1078.bugfix
+1
-0
1 addition, 0 deletions
changes/changelog.d/1078.bugfix
with
28 additions
and
1 deletion
api/funkwhale_api/music/filters.py
+
8
−
1
View file @
798e3c03
from
django.db.models
import
Q
from
django_filters
import
rest_framework
as
filters
from
funkwhale_api.audio
import
filters
as
audio_filters
...
...
@@ -112,6 +114,9 @@ class TrackFilter(
scope
=
common_filters
.
ActorScopeFilter
(
actor_field
=
"
uploads__library__actor
"
,
distinct
=
True
)
artist
=
filters
.
ModelChoiceFilter
(
field_name
=
"
_
"
,
method
=
"
filter_artist
"
,
queryset
=
models
.
Artist
.
objects
.
all
()
)
class
Meta
:
model
=
models
.
Track
...
...
@@ -119,7 +124,6 @@ class TrackFilter(
"
title
"
:
[
"
exact
"
,
"
iexact
"
,
"
startswith
"
,
"
icontains
"
],
"
playable
"
:
[
"
exact
"
],
"
id
"
:
[
"
exact
"
],
"
artist
"
:
[
"
exact
"
],
"
album
"
:
[
"
exact
"
],
"
license
"
:
[
"
exact
"
],
"
scope
"
:
[
"
exact
"
],
...
...
@@ -134,6 +138,9 @@ class TrackFilter(
actor
=
utils
.
get_actor_from_request
(
self
.
request
)
return
queryset
.
playable_by
(
actor
,
value
).
distinct
()
def
filter_artist
(
self
,
queryset
,
name
,
value
):
return
queryset
.
filter
(
Q
(
artist
=
value
)
|
Q
(
album__artist
=
value
))
class
UploadFilter
(
audio_filters
.
IncludeChannelsFilterSet
):
library
=
filters
.
CharFilter
(
"
library__uuid
"
)
...
...
This diff is collapsed.
Click to expand it.
api/tests/music/test_filters.py
+
19
−
0
View file @
798e3c03
...
...
@@ -184,3 +184,22 @@ def test_library_filter_artist(factories, queryset_equal_list, mocker, anonymous
)
assert
filterset
.
qs
==
[
upload
.
track
.
artist
]
def
test_track_filter_artist_includes_album_artist
(
factories
,
mocker
,
queryset_equal_list
,
anonymous_user
):
factories
[
"
music.Track
"
]()
track1
=
factories
[
"
music.Track
"
]()
track2
=
factories
[
"
music.Track
"
](
album__artist
=
track1
.
artist
,
artist
=
factories
[
"
music.Artist
"
]()
)
qs
=
models
.
Track
.
objects
.
all
()
filterset
=
filters
.
TrackFilter
(
{
"
artist
"
:
track1
.
artist
.
pk
},
request
=
mocker
.
Mock
(
user
=
anonymous_user
),
queryset
=
qs
,
)
assert
filterset
.
qs
==
[
track2
,
track1
]
This diff is collapsed.
Click to expand it.
changes/changelog.d/1078.bugfix
0 → 100644
+
1
−
0
View file @
798e3c03
Include tracks by album artist when filtering by artist on /api/v1/tracks (#1078)
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