X-Git-Url: https://git.mdrn.pl/audio.git/blobdiff_plain/ac39503a5a9a16c1098e65ee16a866cf8eb19a8f..c7d2e4daae13c7c1100ec0d42ace0e8c34b5ae24:/src/archive/views.py?ds=inline diff --git a/src/archive/views.py b/src/archive/views.py index 31ea9c3..f237fab 100644 --- a/src/archive/views.py +++ b/src/archive/views.py @@ -3,7 +3,7 @@ from datetime import datetime import os import os.path -from urllib import quote +from urllib.parse import quote from archive import settings from django.contrib.auth import logout @@ -65,7 +65,7 @@ def file_new(request, filename): d[tag] = None if not request.POST: - form = AudiobookForm(d) + form = AudiobookForm(initial=d) return render(request, "archive/file_new.html", locals()) @@ -166,13 +166,13 @@ def publish(request, aid, publish=True): 'url': audiobook.url, 'tags': audiobook.new_publish_tags(), } - audiobook.mp3_tags = tags - audiobook.ogg_tags = tags + audiobook.set_mp3_tags(tags) + audiobook.set_ogg_tags(tags) audiobook.mp3_status = audiobook.ogg_status = status.WAITING audiobook.save() # isn't there a race here? - audiobook.mp3_task = tasks.Mp3Task.delay(aid, publish).task_id - audiobook.ogg_task = tasks.OggTask.delay(aid, publish).task_id + audiobook.mp3_task = tasks.Mp3Task.delay(request.user.id, aid, publish).task_id + audiobook.ogg_task = tasks.OggTask.delay(request.user.id, aid, publish).task_id audiobook.save() return redirect(file_managed, aid) @@ -258,6 +258,10 @@ def file_managed(request, id): tags = {} form = AudiobookForm(instance=audiobook) + user_can_publish = ( + request.user.is_authenticated and + request.user.oauthconnection_set.filter(access=True).exists()) + return render(request, "archive/file_managed.html", locals())