from glob import glob
import re
from os import path
+from waiter.settings import WAITER_ROOT
import search
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
"""
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):
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
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