+ @staticmethod
+ def zip_epub():
+ books = Book.objects.all()
+
+ paths = filter(lambda x: x is not None,
+ map(lambda b: b.epub_file and b.epub_file.path or None, books))
+ result = create_zip_task.delay(paths, settings.ALL_EPUB_ZIP)
+ return settings.MEDIA_URL + result.wait()
+
+ @staticmethod
+ def zip_pdf():
+ books = Book.objects.all()
+
+ paths = filter(lambda x: x is not None,
+ map(lambda b: b.pdf_file and b.pdf_file.path or None, books))
+ result = create_zip_task.delay(paths, settings.ALL_PDF_ZIP)
+ return settings.MEDIA_URL + result.wait()
+
+ def zip_audiobooks(self):
+ bm = BookMedia.objects.filter(book=self)
+ paths = map(lambda bm: bm.file.path, bm)
+ result = create_zip_task.delay(paths, self.slug)
+
+ return settings.MEDIA_URL + result.wait()
+
+ def clean_zip_files(self):
+ remove_zip(self.slug)
+ remove_zip(settings.ALL_EPUB_ZIP)
+ remove_zip(settings.ALL_PDF_ZIP)