-def download_custom_pdf(request, slug, method='GET'):
- book = get_object_or_404(models.Book, slug=slug)
-
- if request.method == method:
- form = forms.CustomPDFForm(method == 'GET' and request.GET or request.POST)
- if form.is_valid():
- cust = form.customizations
- pdf_file = get_customized_pdf_path(book, cust)
-
- url = WaitedFile.order(pdf_file,
- lambda p: build_custom_pdf.delay(book.id, cust, p),
- book.pretty_title()
- )
- return redirect(url)
- else:
- raise Http404(_('Incorrect customization options for PDF'))
- else:
- raise Http404(_('Bad method'))
-
-