cover = EbookField('cover', _('cover'),
upload_to=book_upload_path('jpg'), null=True, blank=True)
+ # Cleaner version of cover for thumbs
+ cover_thumb = EbookField('cover_thumb', _('cover thumbnail'),
+ upload_to=book_upload_path('th.jpg'), null=True, blank=True)
ebook_formats = constants.EBOOK_FORMATS
formats = ebook_formats + ['html', 'xml']
def name(self):
return self.title
+ def language_code(self):
+ return constants.LANGUAGES_3TO2.get(self.language, self.language)
+
+ def language_name(self):
+ return dict(settings.LANGUAGES).get(self.language_code(), "")
+
def book_tag_slug(self):
return ('l-' + self.slug)[:120]
tasks.fix_tree_tags.delay(book)
if 'cover' not in dont_build:
book.cover.build_delay()
+ book.cover_thumb.build_delay()
# No saves behind this point.
if not self.cover_info(inherit=False):
if 'cover' not in app_settings.DONT_BUILD:
self.cover.build_delay()
+ self.cover_thumb.build_delay()
for format_ in constants.EBOOK_FORMATS_WITH_COVERS:
if format_ not in app_settings.DONT_BUILD:
getattr(self, '%s_file' % format_).build_delay()
for child in self.children.all():
child.parent_cover_changed()
+ def other_versions(self):
+ """Find other versions (i.e. in other languages) of the book."""
+ return type(self).objects.filter(common_slug=self.common_slug).exclude(pk=self.pk)
+
def related_info(self):
"""Keeps info about related objects (tags, media) in cache field."""
if self._related_info is not None: