X-Git-Url: https://git.mdrn.pl/audio.git/blobdiff_plain/eee35e00bf0d0eb3d2a9f08f72c7052962fecbf6..09c7e92db4f6c0e94f8686a94bbfaa6896b0290c:/src/archive/views.py diff --git a/src/archive/views.py b/src/archive/views.py index b5850a0..55f4f07 100644 --- a/src/archive/views.py +++ b/src/archive/views.py @@ -35,8 +35,8 @@ def list_new(request): def file_new(request, filename): division = 'new' - filepath = filename.encode('utf-8') - root_filepath = os.path.join(settings.NEW_PATH, filename.encode('utf-8')) + filepath = filename + root_filepath = os.path.join(settings.NEW_PATH, filename) if request.POST: form = AudiobookForm(request.POST) if form.is_valid(): @@ -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()) @@ -171,8 +171,8 @@ def publish(request, aid, publish=True): 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())