From: Guillaume Pellerin Date: Fri, 20 Feb 2015 19:38:41 +0000 (+0100) Subject: Add collection epub draft X-Git-Tag: 1.6a^2~19^2~9 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=e22f8a5e06e8d5dba60f9520f168b24a42f0a758;p=telemeta.git Add collection epub draft --- diff --git a/example/sandbox/settings.py b/example/sandbox/settings.py index 4f469f5a..f55d0e4d 100644 --- a/example/sandbox/settings.py +++ b/example/sandbox/settings.py @@ -149,6 +149,7 @@ INSTALLED_APPS = ( 'bootstrap_pagination', 'googletools', 'registration', + 'epub', ) TEMPLATE_CONTEXT_PROCESSORS = ( diff --git a/telemeta/models/collection.py b/telemeta/models/collection.py index e3d640c7..eb2d7a62 100644 --- a/telemeta/models/collection.py +++ b/telemeta/models/collection.py @@ -264,6 +264,20 @@ class MediaCollection(MediaResource): return metadata + def epub(self, filename): + from epub.models import EPub + e = EPub() + e.metadata.title = self.title + # e.metadata.add_creator(self.metadata_author) + e.metadata.description = self.description + e.metadata.publisher = self.publisher + e.metadata.language = 'fr-FR' + for item in self.items.all(): + e.add_article(item.title, item.comment) + e.generate_epub(filename) + + + class MediaCollectionRelated(MediaRelated): "Collection related media"