kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Merge branch 'master' into develop
commit
812709ad00
|
@ -30,7 +30,7 @@ def run(filters, **kwargs):
|
||||||
|
|
||||||
if final_query:
|
if final_query:
|
||||||
candidates = candidates.filter(final_query)
|
candidates = candidates.filter(final_query)
|
||||||
return candidates.order_by("pk")
|
return candidates.order_by("pk").distinct()
|
||||||
|
|
||||||
|
|
||||||
def validate(filter_config):
|
def validate(filter_config):
|
||||||
|
@ -100,7 +100,9 @@ class GroupFilter(RadioFilter):
|
||||||
conf = collections.ChainMap(filter_config, kwargs)
|
conf = collections.ChainMap(filter_config, kwargs)
|
||||||
query = f.get_query(candidates, **conf)
|
query = f.get_query(candidates, **conf)
|
||||||
if filter_config.get("not", False):
|
if filter_config.get("not", False):
|
||||||
query = ~query
|
# query = ~query *should* work but it doesn't (see #950)
|
||||||
|
# The line below generate a proper subquery
|
||||||
|
query = ~Q(pk__in=candidates.filter(query).values_list("pk", flat=True))
|
||||||
|
|
||||||
if not final_query:
|
if not final_query:
|
||||||
final_query = query
|
final_query = query
|
||||||
|
|
|
@ -282,3 +282,41 @@ def test_session_radio_get_queryset_ignore_filtered_track_album_artist(
|
||||||
radio.start_session(user=cf.user)
|
radio.start_session(user=cf.user)
|
||||||
|
|
||||||
assert radio.get_queryset() == [valid_track]
|
assert radio.get_queryset() == [valid_track]
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_choices_for_custom_radio_exclude_artist(factories):
|
||||||
|
included_artist = factories["music.Artist"]()
|
||||||
|
excluded_artist = factories["music.Artist"]()
|
||||||
|
included_uploads = factories["music.Upload"].create_batch(
|
||||||
|
5, track__artist=included_artist
|
||||||
|
)
|
||||||
|
factories["music.Upload"].create_batch(5, track__artist=excluded_artist)
|
||||||
|
|
||||||
|
session = factories["radios.CustomRadioSession"](
|
||||||
|
custom_radio__config=[
|
||||||
|
{"type": "artist", "ids": [included_artist.pk]},
|
||||||
|
{"type": "artist", "ids": [excluded_artist.pk], "not": True},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
choices = session.radio.get_choices(filter_playable=False)
|
||||||
|
|
||||||
|
expected = [u.track.pk for u in included_uploads]
|
||||||
|
assert list(choices.values_list("id", flat=True)) == expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_choices_for_custom_radio_exclude_tag(factories):
|
||||||
|
included_uploads = factories["music.Upload"].create_batch(
|
||||||
|
5, track__set_tags=["rap"]
|
||||||
|
)
|
||||||
|
factories["music.Upload"].create_batch(5, track__set_tags=["rock", "rap"])
|
||||||
|
|
||||||
|
session = factories["radios.CustomRadioSession"](
|
||||||
|
custom_radio__config=[
|
||||||
|
{"type": "tag", "names": ["rap"]},
|
||||||
|
{"type": "tag", "names": ["rock"], "not": True},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
choices = session.radio.get_choices(filter_playable=False)
|
||||||
|
|
||||||
|
expected = [u.track.pk for u in included_uploads]
|
||||||
|
assert list(choices.values_list("id", flat=True)) == expected
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix tag exclusion in custom radios (#950)
|
Ładowanie…
Reference in New Issue