mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 21:12:23 +01:00
Allow users to delete or move their requested songs down.
This commit is contained in:
@ -103,7 +103,7 @@ def queue(request):
|
||||
queue = request.user.queue
|
||||
return JsonResponse({
|
||||
'current_song': playlist_song_to_dict(queue.current_song()),
|
||||
'queue': [playlist_song_to_dict(playlist_song) for playlist_song in queue.queue()],
|
||||
'queue': [playlist_song_to_dict(playlist_song, user=request.user) for playlist_song in queue.queue()],
|
||||
'started_at': 0 if queue.started_at is None else int(time.mktime(queue.started_at.timetuple())),
|
||||
'current_time': int(time.time())
|
||||
})
|
||||
|
||||
@ -19,11 +19,12 @@ def song_to_dict(song, hash=False, user=False):
|
||||
return data
|
||||
|
||||
|
||||
def playlist_song_to_dict(playlist_song, hash=False):
|
||||
def playlist_song_to_dict(playlist_song, hash=False, user=None):
|
||||
return {
|
||||
'id': playlist_song.id,
|
||||
'requested_by': 'Marietje' if playlist_song.user is None else playlist_song.user.name,
|
||||
'song': song_to_dict(playlist_song.song, hash=hash)
|
||||
'song': song_to_dict(playlist_song.song, hash=hash),
|
||||
'can_move_down': playlist_song.user is not None and playlist_song.user == user
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user