Skip to content

Commit

Permalink
Reverse playlist played entries order and add was_played to playlist …
Browse files Browse the repository at this point in the history
…serializer
  • Loading branch information
Neraste committed Apr 25, 2022
1 parent 44cb589 commit 846f699
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dakara_server/playlist/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ class Meta:
"song_id",
"use_instrumental",
"date_play",
"was_played",
)
read_only_fields = ("date_created", "date_play")
read_only_fields = ("date_created", "date_play", "was_played")

def validate(self, data):
if data.get("use_instrumental") and not data["song"].has_instrumental:
Expand Down
4 changes: 2 additions & 2 deletions dakara_server/playlist/tests/test_playlist_played.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def test_get_playlist_played_list(self):
self.assertEqual(len(response.data["results"]), 2)

# Playlist entries are in order of creation
self.check_playlist_played_entry_json(response.data["results"][0], self.pe3)
self.check_playlist_played_entry_json(response.data["results"][1], self.pe4)
self.check_playlist_played_entry_json(response.data["results"][0], self.pe4)
self.check_playlist_played_entry_json(response.data["results"][1], self.pe3)

def test_get_playlist_played_list_forbidden(self):
"""Test to verify playlist entries played list forbidden when not logged in."""
Expand Down
2 changes: 1 addition & 1 deletion dakara_server/playlist/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class PlaylistPlayedListView(drf_generics.ListAPIView):
"""List of played entries."""

serializer_class = serializers.PlaylistEntrySerializer
queryset = models.PlaylistEntry.objects.get_played()
queryset = models.PlaylistEntry.objects.get_played().reverse()


class PlayerCommandView(drf_generics.UpdateAPIView):
Expand Down

0 comments on commit 846f699

Please sign in to comment.