skip books with isbn metadata
[redakcja.git] / apps / cover / views.py
index 4bb6d50..25033c1 100644 (file)
@@ -15,7 +15,6 @@ from catalogue.models import Chunk
 from cover.models import Image
 from cover import forms
 
 from cover.models import Image
 from cover import forms
 
-
 PREVIEW_SIZE = (216, 300)
 
 
 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)
     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
     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":
 
     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())
             if form.is_valid():
                 form.save()
                 return HttpResponseRedirect(image.get_absolute_url())
@@ -99,7 +98,7 @@ def image(request, pk):
         editable = False
 
     return render(request, "cover/image_detail.html", {
         editable = False
 
     return render(request, "cover/image_detail.html", {
-        "object": image,
+        "object": Image.objects.get(id=image.id),
         "form": form,
         "editable": editable,
     })
         "form": form,
         "editable": editable,
     })
@@ -107,8 +106,6 @@ def image(request, pk):
 
 @active_tab('cover')
 def image_list(request):
 
 @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'),
     return render(request, "cover/image_list.html", {
         'object_list': Image.objects.all(),
         'can_add': request.user.has_perm('cover.add_image'),