Merge branch 'marietje-zuid' into dsprenkels/remove_executed

This commit is contained in:
Daan Sprenkels
2019-03-20 11:19:50 +01:00
2 changed files with 6 additions and 8 deletions

View File

@ -15,18 +15,16 @@ from .decorators import token_required
@token_required @token_required
def queue(request): def queue(request):
current_queue = get_object_or_404(Queue, id=request.POST.get('queue')) current_queue = get_object_or_404(Queue, id=request.POST.get('queue'))
commands = current_queue.queuecommand_set
commands = current_queue.queuecommand_set.filter(executed=False) response = JsonResponse({
for command in commands:
command.executed = True
command.save()
return JsonResponse({
'current_song': playlist_song_to_dict(current_queue.current_song(), include_hash=True, include_replaygain=True), 'current_song': playlist_song_to_dict(current_queue.current_song(), include_hash=True, include_replaygain=True),
'queue': [playlist_song_to_dict(playlist_song, include_hash=True, include_replaygain=True) for playlist_song in current_queue.queue()[:1]], 'queue': [playlist_song_to_dict(playlist_song, include_hash=True, include_replaygain=True) for playlist_song in current_queue.queue()[:1]],
'commands': [command.command for command in commands] 'commands': [command.command for command in commands]
}) })
for command in commands:
command.delete()
return response
@csrf_exempt @csrf_exempt
@token_required @token_required

View File

@ -157,9 +157,9 @@ class QueueCommand(models.Model):
queue = models.ForeignKey( queue = models.ForeignKey(
Queue, Queue,
on_delete=models.CASCADE, on_delete=models.CASCADE,
db_index=True,
) )
command = models.TextField() command = models.TextField()
executed = models.BooleanField(default=False)
def __str__(self): def __str__(self):
return self.command return self.command