Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Philipp Wolfer
funkwhale
Commits
19211276
Unverified
Commit
19211276
authored
Jun 11, 2020
by
Agate
💬
Browse files
Fix
#1158
: crash when loading recent albums via Subsonic
parent
b637a94e
Changes
3
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/subsonic/views.py
View file @
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"
):
...
...
api/tests/subsonic/test_views.py
View file @
19211276
...
...
@@ -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"
)
...
...
changes/changelog.d/1158.bugfix
0 → 100644
View file @
19211276
Fixed crash when loading recent albums via Subsonic (#1158)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment