1 from django.contrib.auth.decorators import permission_required
2 from django.shortcuts import redirect, get_object_or_404
3 from django.urls import reverse
4 from django.views.decorators.http import require_POST
5 from archive.constants import status
6 from archive.models import Audiobook
12 @permission_required('archive.change_audiobook')
13 def publish(request, aid, publish=True):
14 audiobook = get_object_or_404(Audiobook, id=aid)
16 #audiobook.set_youtube_tags(tags)
17 audiobook.youtube_status = status.WAITING
18 audiobook.save(update_fields=['youtube_status'])
19 audiobook.youtube_task = tasks.YouTubeTask.delay(request.user.id, aid, publish).task_id
20 audiobook.save(update_fields=['youtube_task'])
21 return redirect(reverse('file', args=[aid]))