X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/e0164e6ca0588a270b77d892702e54ef62c31de2..5a605e04abaa18a80e391c5cc26c48e0125d6f3c:/apps/catalogue/views.py diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 8169ad739..2bc1f10aa 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -28,7 +28,7 @@ from django.views.generic.list_detail import object_list from catalogue import models from catalogue import forms -from catalogue.utils import split_tags, AttachmentHttpResponse, create_custom_pdf +from catalogue.utils import split_tags, AttachmentHttpResponse, async_build_pdf from pdcounter import models as pdcounter_models from pdcounter import views as pdcounter_views from suggest.forms import PublishingSuggestForm @@ -772,12 +772,10 @@ def download_custom_pdf(request, slug): form = forms.CustomPDFForm(request.GET) if form.is_valid(): cust = form.customizations - h = hash(tuple(cust)) - pdf_name = '%s-custom-%s' % (book.slug, h) - pdf_file = path.join(settings.MEDIA_ROOT, models.get_dynamic_path(None, pdf_name, ext='pdf')) - + pdf_file = models.get_customized_pdf_path(book, cust) + if not path.exists(pdf_file): - result = create_custom_pdf.delay(book.id, cust, pdf_name) + result = async_build_pdf.delay(book.id, cust, pdf_file) result.wait() return AttachmentHttpResponse(file_name=("%s.pdf" % book.slug), file_path=pdf_file, mimetype="application/pdf") else: