Commit 33f79934 authored by Ciarán Ainsworth's avatar Ciarán Ainsworth Committed by Georg Krause
Browse files

Add missing playable serializer

parent 26f8f7db
......@@ -201,7 +201,6 @@ class AlbumSerializer(OptionalDescriptionMixin, serializers.Serializer):
release_date = serializers.DateField()
creation_date = serializers.DateTimeField()
is_local = serializers.BooleanField()
is_playable = serializers.SerializerMethodField()
get_attributed_to = serialize_attributed_to
......@@ -302,6 +301,7 @@ class TrackSerializer(OptionalDescriptionMixin, serializers.Serializer):
license = serializers.SerializerMethodField()
cover = cover_field
get_attributed_to = serialize_attributed_to
is_playable = serializers.SerializerMethodField()
def get_artist(self, o):
return serialize_artist_simple(o.artist)
......@@ -323,6 +323,9 @@ class TrackSerializer(OptionalDescriptionMixin, serializers.Serializer):
def get_license(self, o):
return o.license_id
def get_is_playable(self, obj):
return bool(getattr(obj, "playable_uploads", []))
@common_serializers.track_fields_for_update("name", "description", "privacy_level")
class LibraryForOwnerSerializer(serializers.ModelSerializer):
......
......@@ -255,6 +255,7 @@ def test_track_serializer(factories, to_api_date):
"attributed_to": federation_serializers.APIActorSerializer(actor).data,
"cover": common_serializers.AttachmentSerializer(track.attachment_cover).data,
"downloads_count": track.downloads_count,
"is_playable": bool(track.playable_uploads),
}
serializer = serializers.TrackSerializer(track)
assert serializer.data == expected
......
Added missing is_playable serializer for the tracks endpoint.
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