fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Librarian in regular requirements.
[redakcja.git]
/
apps
/
cover
/
views.py
diff --git
a/apps/cover/views.py
b/apps/cover/views.py
index
f493392
..
3f2c46f
100644
(file)
--- a/
apps/cover/views.py
+++ b/
apps/cover/views.py
@@
-41,13
+41,13
@@
def preview(request, book, chunk=None, rev=None):
xml = revision.materialize().encode('utf-8')
try:
xml = revision.materialize().encode('utf-8')
try:
- info = BookInfo.from_
string
(xml)
+ info = BookInfo.from_
bytes
(xml)
except:
return HttpResponseRedirect(os.path.join(settings.STATIC_URL, "img/sample_cover.png"))
cover = make_cover(info)
response = HttpResponse(content_type=cover.mime_type())
except:
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
@@
-63,7
+63,7
@@
def preview_from_xml(request):
xml = request.POST['xml']
try:
xml = request.POST['xml']
try:
- info = BookInfo.from_
string
(xml.encode('utf-8'))
+ info = BookInfo.from_
bytes
(xml.encode('utf-8'))
except:
return HttpResponse(os.path.join(settings.STATIC_URL, "img/sample_cover.png"))
coverid = sha1(etree.tostring(info.to_etree())).hexdigest()
except:
return HttpResponse(os.path.join(settings.STATIC_URL, "img/sample_cover.png"))
coverid = sha1(etree.tostring(info.to_etree())).hexdigest()
@@
-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", {