X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/c3d135f90804db7231063cb0aa6e525a55a67bfa..8906541ccda592d4e3c3d21618fb34f662916aa0:/apps/cover/views.py diff --git a/apps/cover/views.py b/apps/cover/views.py index 4bb6d504..25033c18 100644 --- a/apps/cover/views.py +++ b/apps/cover/views.py @@ -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()) @@ -99,7 +98,7 @@ def image(request, pk): editable = False return render(request, "cover/image_detail.html", { - "object": image, + "object": Image.objects.get(id=image.id), "form": form, "editable": editable, }) @@ -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'),