mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 10:29:28 +02:00
Resolve "Broken 'Less listened' Radio in develop version"
This commit is contained in:
parent
4ce59adcd5
commit
fcf223ad03
3 changed files with 17 additions and 4 deletions
|
@ -8,7 +8,6 @@ from rest_framework import serializers
|
|||
from funkwhale_api.moderation import filters as moderation_filters
|
||||
from funkwhale_api.music.models import Artist, Track
|
||||
from funkwhale_api.tags.models import Tag
|
||||
from funkwhale_api.users.models import User
|
||||
|
||||
from . import filters, models
|
||||
from .registries import registry
|
||||
|
@ -263,9 +262,7 @@ class ArtistRadio(RelatedObjectRadio):
|
|||
|
||||
|
||||
@registry.register(name="less-listened")
|
||||
class LessListenedRadio(RelatedObjectRadio):
|
||||
model = User
|
||||
|
||||
class LessListenedRadio(SessionRadio):
|
||||
def clean(self, instance):
|
||||
instance.related_object = instance.user
|
||||
super().clean(instance)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import pytest
|
||||
|
||||
from django.urls import reverse
|
||||
|
||||
from funkwhale_api.music.serializers import TrackSerializer
|
||||
|
@ -129,3 +131,16 @@ def test_clean_config_is_called_on_serializer_save(mocker, factories):
|
|||
instance = serializer.save(user=user)
|
||||
spied.assert_called_once_with(data["config"][0])
|
||||
assert instance.config[0]["names"] == [artist.name]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("radio_type", ["random", "less-listened", "favorites"])
|
||||
def test_create_radio_session(radio_type, logged_in_api_client):
|
||||
|
||||
url = reverse("api:v1:radios:sessions-list")
|
||||
response = logged_in_api_client.post(url, {"radio_type": radio_type})
|
||||
|
||||
assert response.status_code == 201
|
||||
assert response.data["radio_type"] == radio_type
|
||||
assert (
|
||||
response.data["id"] == logged_in_api_client.user.radio_sessions.latest("id").pk
|
||||
)
|
||||
|
|
1
changes/changelog.d/912.bugfix
Normal file
1
changes/changelog.d/912.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Fixed broken less listened radio (#912)
|
Loading…
Add table
Add a link
Reference in a new issue