fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
yet another fix for beta
[redakcja.git]
/
apps
/
cover
/
views.py
diff --git
a/apps/cover/views.py
b/apps/cover/views.py
index
25033c1
..
bbcf28e
100644
(file)
--- a/
apps/cover/views.py
+++ b/
apps/cover/views.py
@@
-25,7
+25,7
@@
def preview(request, book, chunk=None, rev=None):
If rev is not given, use publishable version.
"""
from PIL import Image
If rev is not given, use publishable version.
"""
from PIL import Image
- from librarian.cover import
DefaultEbookC
over
+ from librarian.cover import
make_c
over
from librarian.dcparser import BookInfo
chunk = Chunk.get(book, chunk)
from librarian.dcparser import BookInfo
chunk = Chunk.get(book, chunk)
@@
-44,10
+44,10
@@
def preview(request, book, chunk=None, rev=None):
info = BookInfo.from_string(xml)
except:
return HttpResponseRedirect(os.path.join(settings.STATIC_URL, "img/sample_cover.png"))
info = BookInfo.from_string(xml)
except:
return HttpResponseRedirect(os.path.join(settings.STATIC_URL, "img/sample_cover.png"))
- cover =
DefaultEbookC
over(info)
+ cover =
make_c
over(info)
response = HttpResponse(content_type=cover.mime_type())
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
@@
-58,7
+58,7
@@
def preview_from_xml(request):
from PIL import Image
from os import makedirs
from lxml import etree
from PIL import Image
from os import makedirs
from lxml import etree
- from librarian.cover import
DefaultEbookC
over
+ from librarian.cover import
make_c
over
from librarian.dcparser import BookInfo
xml = request.POST['xml']
from librarian.dcparser import BookInfo
xml = request.POST['xml']
@@
-67,7
+67,7
@@
def preview_from_xml(request):
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()
- cover =
DefaultEbookC
over(info)
+ cover =
make_c
over(info)
cover_dir = 'cover/preview'
try:
cover_dir = 'cover/preview'
try:
@@
-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", {