custom pdf in dirs
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 22 Mar 2012 16:35:20 +0000 (17:35 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 22 Mar 2012 16:35:38 +0000 (17:35 +0100)
apps/catalogue/models.py
wolnelektury/settings/custom.py

index 722539a..f3b7b46 100644 (file)
@@ -30,6 +30,7 @@ from shutil import copy
 from glob import glob
 import re
 from os import path
+from waiter.settings import WAITER_ROOT
 
 import search
 
@@ -226,7 +227,7 @@ def get_customized_pdf_path(book, customizations):
     Returns a MEDIA_ROOT relative path for a customized pdf. The name will contain a hash of customization options.
     """
     h = customizations_hash(customizations)
-    pdf_name = '%s-custom-%s' % (book.slug, h)
+    pdf_name = '%s/%s-custom-%s' % (book.slug, book.slug, h)
     pdf_file = pdf_name + '.pdf'
 
     return pdf_file
@@ -236,10 +237,8 @@ def get_existing_customized_pdf(book):
     """
     Returns a list of paths to generated customized pdf of a book
     """
-    pdf_glob = '%s-custom-' % (book.slug,)
-    pdf_glob = get_dynamic_path(None, pdf_glob, ext='pdf')
-    pdf_glob = re.sub(r"[.]([a-z0-9]+)$", "*.\\1", pdf_glob)
-    return glob(path.join(settings.MEDIA_ROOT, pdf_glob))
+    pdf_glob = path.join(WAITER_ROOT, book.slug, '*')
+    return glob(pdf_glob)
 
 
 class BookMedia(models.Model):
@@ -513,7 +512,8 @@ class Book(models.Model):
         from django.core.files import File
         from catalogue.utils import remove_zip
 
-        pdf = self.wldocument().as_pdf(customizations=customizations)
+        pdf = self.wldocument().as_pdf(customizations=customizations,
+            morefloats=settings.LIBRARIAN_PDF_MOREFLOATS)
 
         if file_name is None:
             # we'd like to be sure not to overwrite changes happening while
index 97d9588..eed38a2 100644 (file)
@@ -22,4 +22,9 @@ ALL_MOBI_ZIP = 'wolnelektury_pl_mobi'
 CATALOGUE_DEFAULT_LANGUAGE = 'pol'
 PUBLISH_PLAN_FEED = 'http://redakcja.wolnelektury.pl/documents/track/editor-proofreading/?published=false'
 
-CATALOGUE_CUSTOMPDF_RATE_LIMIT = '6/m'
+# limit rate for custom PDF creation
+CATALOGUE_CUSTOMPDF_RATE_LIMIT = '1/m'
+
+# set to 'new' or 'old' to skip time-consuming test
+# for TeX morefloats library version
+LIBRARIAN_PDF_MOREFLOATS = None