Exemple #1
0
def build_pdf(book_id):
    """(Re)builds the pdf file for a book."""
    from django.core.files import File
    from catalogue.models import Book
    from catalogue.utils import remove_zip
    from waiter.utils import clear_cache

    pdf = Book.objects.get(pk=book_id).wldocument().as_pdf(
            morefloats=settings.LIBRARIAN_PDF_MOREFLOATS)

    # Save the file in new instance. Building PDF takes time and we don't want
    # to overwrite any interim changes.
    book = Book.objects.get(id=book_id)
    book.pdf_file.save('%s.pdf' % book.slug,
             File(open(pdf.get_filename())))

    # Remove cached downloadables
    remove_zip(settings.ALL_PDF_ZIP)
    clear_cache(book.slug)
Exemple #2
0
 def build(self, fieldfile):
     BuildEbook.build(self, fieldfile)
     clear_cache(fieldfile.instance.slug)
Exemple #3
0
def clear_custom_pdf(book):
    """
    Returns a list of paths to generated customized pdf of a book
    """
    from waiter.utils import clear_cache
    clear_cache('book/%s' % book.slug)
Exemple #4
0
def clear_custom_pdf(book):
    """
    Returns a list of paths to generated customized pdf of a book
    """
    from waiter.utils import clear_cache
    clear_cache('book/%s' % book.slug)
Exemple #5
0
 def build(self, fieldfile):
     BuildEbook.build(self, fieldfile)
     clear_cache(fieldfile.instance.slug)