cover = EbookField('cover', _('cover'),
upload_to=book_upload_path('jpg'), null=True, blank=True)
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']
ebook_formats = constants.EBOOK_FORMATS
formats = ebook_formats + ['html', 'xml']
+ 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(), "")
+
if self.has_media(type_):
if type_ in Book.formats:
return getattr(self, "%s_file" % type_)
if self.has_media(type_):
if type_ in Book.formats:
return getattr(self, "%s_file" % type_)
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()
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 related_info(self):
"""Keeps info about related objects (tags, media) in cache field."""
if self._related_info is not None:
def related_info(self):
"""Keeps info about related objects (tags, media) in cache field."""
if self._related_info is not None:
rel_info = book.related_info()
names = [(related_tag_name(tag), Tag.create_url('author', tag['slug']))
for tag in rel_info['tags'].get('author', ())]
rel_info = book.related_info()
names = [(related_tag_name(tag), Tag.create_url('author', tag['slug']))
for tag in rel_info['tags'].get('author', ())]
if 'parents' in rel_info:
books = [(name, Book.create_url(slug))
for name, slug in rel_info['parents']]
if 'parents' in rel_info:
books = [(name, Book.create_url(slug))
for name, slug in rel_info['parents']]
# eliminate descendants
l_tags = Tag.objects.filter(category='book',
slug__in=[book.book_tag_slug() for book in parents.iterator()])
# eliminate descendants
l_tags = Tag.objects.filter(category='book',
slug__in=[book.book_tag_slug() for book in parents.iterator()])
'title', 'parent', 'slug')
if filter:
books = books.filter(filter).distinct()
'title', 'parent', 'slug')
if filter:
books = books.filter(filter).distinct()