fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mobile PDF option
[redakcja.git]
/
apps
/
cover
/
views.py
diff --git
a/apps/cover/views.py
b/apps/cover/views.py
index
f493392
..
bbcf28e
100644
(file)
--- a/
apps/cover/views.py
+++ b/
apps/cover/views.py
@@
-46,8
+46,8
@@
def preview(request, book, chunk=None, rev=None):
return HttpResponseRedirect(os.path.join(settings.STATIC_URL, "img/sample_cover.png"))
cover = make_cover(info)
response = HttpResponse(content_type=cover.mime_type())
return HttpResponseRedirect(os.path.join(settings.STATIC_URL, "img/sample_cover.png"))
cover = make_cover(info)
response = HttpResponse(content_type=cover.mime_type())
- im
age
= cover.image().resize(PREVIEW_SIZE, Image.ANTIALIAS)
- im
age
.save(response, cover.format)
+ im
g
= cover.image().resize(PREVIEW_SIZE, Image.ANTIALIAS)
+ im
g
.save(response, cover.format)
return response
return response
@@
-75,35
+75,40
@@
def preview_from_xml(request):
except OSError:
pass
fname = os.path.join(cover_dir, "%s.%s" % (coverid, cover.ext()))
except OSError:
pass
fname = os.path.join(cover_dir, "%s.%s" % (coverid, cover.ext()))
- im
age
= cover.image().resize(PREVIEW_SIZE, Image.ANTIALIAS)
- im
age
.save(os.path.join(settings.MEDIA_ROOT, fname))
+ im
g
= cover.image().resize(PREVIEW_SIZE, Image.ANTIALIAS)
+ im
g
.save(os.path.join(settings.MEDIA_ROOT, fname))
return HttpResponse(os.path.join(settings.MEDIA_URL, fname))
@active_tab('cover')
def image(request, pk):
return HttpResponse(os.path.join(settings.MEDIA_URL, fname))
@active_tab('cover')
def image(request, pk):
- im
age
= get_object_or_404(Image, pk=pk)
+ im
g
= get_object_or_404(Image, pk=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, request.FILES, instance=im
age
)
+ form = forms.ImageEditForm(request.POST, request.FILES, instance=im
g
)
if form.is_valid():
form.save()
if form.is_valid():
form.save()
- return HttpResponseRedirect(im
age
.get_absolute_url())
+ return HttpResponseRedirect(im
g
.get_absolute_url())
else:
else:
- form = forms.ImageEditForm(instance=im
age
)
+ form = forms.ImageEditForm(instance=im
g
)
editable = True
else:
editable = True
else:
- form = forms.ReadonlyImageEditForm(instance=im
age
)
+ form = forms.ReadonlyImageEditForm(instance=im
g
)
editable = False
return render(request, "cover/image_detail.html", {
editable = False
return render(request, "cover/image_detail.html", {
- "object": Image.objects.get(id=im
age
.id),
+ "object": Image.objects.get(id=im
g
.id),
"form": form,
"editable": editable,
})
"form": form,
"editable": editable,
})
+def image_file(request, pk):
+ img = get_object_or_404(Image, pk=pk)
+ return HttpResponseRedirect(img.file.url)
+
+
@active_tab('cover')
def image_list(request):
return render(request, "cover/image_list.html", {
@active_tab('cover')
def image_list(request):
return render(request, "cover/image_list.html", {