images in epub/mobi
[redakcja.git] / apps / catalogue / views.py
index 1436fc0..564af62 100644 (file)
@@ -25,7 +25,7 @@ from apiclient import NotAuthorizedError
 from catalogue import forms
 from catalogue import helpers
 from catalogue.helpers import active_tab
-from catalogue.models import Book, Chunk, BookPublishRecord, ChunkPublishRecord
+from catalogue.models import Book, Chunk, BookPublishRecord, ChunkPublishRecord, Project
 from fileupload.views import UploadView
 
 #
@@ -252,7 +252,7 @@ def book_pdf(request, slug):
     # TODO: move to celery
     doc = book.wldocument()
     # TODO: error handling
-    pdf_file = doc.as_pdf()
+    pdf_file = doc.as_pdf(cover=True, ilustr_path=book.gallery_path())
     from catalogue.ebook_utils import serve_file
     return serve_file(pdf_file.get_filename(),
                 book.slug + '.pdf', 'application/pdf')
@@ -267,7 +267,7 @@ 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(mimetype='application/epub+zip')
     response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.epub'
     response.write(epub)
@@ -429,6 +429,17 @@ def chunk_mass_edit(request):
             for b in books_affected:
                 b.touch()  # cache
 
+        project_id = request.POST.get('project')
+        if project_id:
+            try:
+                project = Project.objects.get(pk=int(project_id))
+            except (Project.DoesNotExist, ValueError), e:
+                project = None
+            for c in chunks:
+                book = c.book
+                book.project = project
+                book.save()
+
         for c in chunks: c.save()
 
         return HttpResponse("", content_type="text/plain")