refreshing flickr cover images + some cleanup
[redakcja.git] / apps / cover / views.py
index 4bb6d50..607d808 100644 (file)
@@ -15,7 +15,6 @@ from catalogue.models import Chunk
 from cover.models import Image
 from cover import forms
 
-
 PREVIEW_SIZE = (216, 300)
 
 
@@ -46,7 +45,7 @@ def preview(request, book, chunk=None, rev=None):
     except:
         return HttpResponseRedirect(os.path.join(settings.STATIC_URL, "img/sample_cover.png"))
     cover = DefaultEbookCover(info)
-    response = HttpResponse(mimetype=cover.mime_type())
+    response = HttpResponse(content_type=cover.mime_type())
     image = cover.image().resize(PREVIEW_SIZE, Image.ANTIALIAS)
     image.save(response, cover.format)
     return response
@@ -87,7 +86,7 @@ def image(request, pk):
 
     if request.user.has_perm('cover.change_image'):
         if request.method == "POST":
-            form = forms.ImageEditForm(request.POST, instance=image)
+            form = forms.ImageEditForm(request.POST, request.FILES, instance=image)
             if form.is_valid():
                 form.save()
                 return HttpResponseRedirect(image.get_absolute_url())
@@ -107,8 +106,6 @@ def image(request, pk):
 
 @active_tab('cover')
 def image_list(request):
-    objects = Image.objects.all()
-    enable_add = request.user.has_perm('cover.add_image')
     return render(request, "cover/image_list.html", {
         'object_list': Image.objects.all(),
         'can_add': request.user.has_perm('cover.add_image'),