Unverified Commit 0c9af964 authored by Agate's avatar Agate 💬

Merge branch 'master' into develop

parents 2fefe149 adbd62af
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")
......
......@@ -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]
Include tracks by album artist when filtering by artist on /api/v1/tracks (#1078)
Ensure player doesn't disappear when last queue track is removed manually (#1092)
......@@ -20,7 +20,7 @@ If you have the channel's full social network name:
URL to the channel
- Click "Subscribe"
Following Funwkhale Channels Through the Fediverse
Following Funkwhale Channels Through the Fediverse
--------------------------------------------------
Funkwhale channels can be followed from different ActivityPub-enabled applications
......
......@@ -104,8 +104,13 @@ export default {
commit('splice', {start: index, size: 1})
if (index < state.currentIndex) {
commit('currentIndex', state.currentIndex - 1)
}
if (current) {
} else if (index > 0 && index === state.tracks.length) {
// kind of a edge case: if you delete the last track of the queue
// we set current index to the previous one to avoid the queue tab from
// being stuck because the player disappeared
// cf #1092
commit('currentIndex', state.tracks.length - 1)
} else if (current) {
// we play next track, which now have the same index
commit('currentIndex', index)
}
......
......@@ -133,7 +133,7 @@ describe('store/queue', () => {
testAction({
action: store.actions.cleanTrack,
payload: 3,
params: {state: {currentIndex: 2, tracks: []}},
params: {state: {currentIndex: 2, tracks: [1, 2, 3, 4, 5]}},
expectedMutations: [
{ type: 'splice', payload: {start: 3, size: 1} }
]
......
Markdown is supported
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