Forgotten req.
[audio.git] / src / archive / views.py
index 31ea9c3..55f4f07 100644 (file)
@@ -65,7 +65,7 @@ def file_new(request, filename):
                     d[tag] = None
 
     if not request.POST:
                     d[tag] = None
 
     if not request.POST:
-        form = AudiobookForm(d)
+        form = AudiobookForm(initial=d)
     return render(request, "archive/file_new.html", locals())
 
 
     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_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)
     audiobook.save()
 
     return redirect(file_managed, aid)
@@ -258,6 +258,10 @@ def file_managed(request, id):
         tags = {}
     form = AudiobookForm(instance=audiobook)
 
         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())
 
 
     return render(request, "archive/file_managed.html", locals())