X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/c661073dd0969caa9a47a225f3d3fae767295c3d..3c949051e5f0d93dde78fa5f101584e6766f6022:/apps/catalogue/tasks.py?ds=sidebyside diff --git a/apps/catalogue/tasks.py b/apps/catalogue/tasks.py index cf6178939..f1d8a9005 100644 --- a/apps/catalogue/tasks.py +++ b/apps/catalogue/tasks.py @@ -18,6 +18,11 @@ def touch_tag(tag): type(tag).objects.filter(pk=tag.pk).update(**update_dict) +@task(ignore_result=True) +def fix_tree_tags(book): + book.fix_tree_tags() + + @task def index_book(book_id, book_info=None): from catalogue.models import Book @@ -98,7 +103,7 @@ def build_fb2(book_id, *args, **kwargs): remove_zip(settings.ALL_FB2_ZIP) -@task(rate_limit=settings.CATALOGUE_CUSTOMPDF_RATE_LIMIT) +@task(ignore_result=True, rate_limit=settings.CATALOGUE_CUSTOMPDF_RATE_LIMIT) def build_custom_pdf(book_id, customizations, file_name): """Builds a custom PDF file.""" from django.core.files import File @@ -111,3 +116,20 @@ def build_custom_pdf(book_id, customizations, file_name): customizations=customizations, morefloats=settings.LIBRARIAN_PDF_MOREFLOATS) DefaultStorage().save(file_name, File(open(pdf.get_filename()))) + + +@task(ignore_result=True) +def build_cover(book_id): + """(Re)builds the cover image.""" + from StringIO import StringIO + from django.core.files.base import ContentFile + from librarian.cover import WLCover + from catalogue.models import Book + + book = Book.objects.get(pk=book_id) + book_info = book.wldocument().book_info + cover = WLCover(book_info).image() + imgstr = StringIO() + cover.save(imgstr, 'png') + book.cover.save(None, ContentFile(imgstr.getvalue()), save=False) + Book.objects.filter(pk=book_id).update(cover=book.cover)