Commit fa60e052 authored by Agate's avatar Agate 💬
Browse files

Merge branch '1158-subsonic-crash' into 'master'

Resolve "Subsonic integration: Error when loading list of albums"

See merge request funkwhale/funkwhale!1142
parents 2e3eff47 19211276
......@@ -458,9 +458,7 @@ class SubsonicViewSet(viewsets.GenericViewSet):
elif type == "alphabeticalByName" or not type:
queryset = queryset.order_by("artist__title")
elif type == "recent" or not type:
queryset = queryset.exclude(release_date__in=["", None]).order_by(
"-release_date"
)
queryset = queryset.exclude(release_date=None).order_by("-release_date")
elif type == "newest" or not type:
queryset = queryset.order_by("-creation_date")
elif type == "byGenre" and data.get("genre"):
......
......@@ -435,6 +435,21 @@ def test_get_album_list2(
playable_by.assert_called_once()
def test_get_album_list2_recent(db, logged_in_api_client, factories):
url = reverse("api:subsonic-get_album_list2")
assert url.endswith("getAlbumList2") is True
factories["music.Album"](playable=True, release_date=None)
album2 = factories["music.Album"](playable=True)
album3 = factories["music.Album"](playable=True)
response = logged_in_api_client.get(url, {"f": "json", "type": "recent"})
assert response.status_code == 200
expected_albums = reversed(sorted([album3, album2], key=lambda a: a.release_date))
assert response.data == {
"albumList2": {"album": serializers.get_album_list2_data(expected_albums)}
}
@pytest.mark.parametrize("f", ["json"])
def test_get_album_list2_pagination(f, db, logged_in_api_client, factories):
url = reverse("api:subsonic-get_album_list2")
......
Fixed crash when loading recent albums via Subsonic (#1158)
Supports Markdown
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