X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/c58ede829174b66ec4d2b0c949b771a3eed27e1b..15bfd31759c7454aaceaf7107ef07718e662724a:/apps/catalogue/views.py diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 0eac8ded..84cc0972 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -274,13 +274,29 @@ def book_epub(request, slug): # TODO: move to celery doc = book.wldocument() # TODO: error handling - epub = doc.as_epub().get_string() + epub = doc.as_epub(ilustr_path=book.gallery_path()).get_string() response = HttpResponse(content_type='application/epub+zip') response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.epub' response.write(epub) return response +@never_cache +def book_mobi(request, slug): + book = get_object_or_404(Book, slug=slug) + if not book.accessible(request): + return HttpResponseForbidden("Not authorized.") + + # TODO: move to celery + doc = book.wldocument() + # TODO: error handling + mobi = doc.as_mobi(ilustr_path=book.gallery_path()).get_string() + response = HttpResponse(content_type='application/x-mobipocket-ebook') + response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.mobi' + response.write(mobi) + return response + + @never_cache def revision(request, slug, chunk=None): try: