From: Radek Czajka Date: Thu, 22 Mar 2012 16:35:20 +0000 (+0100) Subject: custom pdf in dirs X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/4bdb838df1fa9fa020acbb1cd53cc42341c45546?ds=inline;hp=--cc custom pdf in dirs --- 4bdb838df1fa9fa020acbb1cd53cc42341c45546 diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index 722539ade..f3b7b467e 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -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 diff --git a/wolnelektury/settings/custom.py b/wolnelektury/settings/custom.py index 97d958802..eed38a2bc 100644 --- a/wolnelektury/settings/custom.py +++ b/wolnelektury/settings/custom.py @@ -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