if self.has_media(type_):
if type_ in Book.formats:
return getattr(self, "%s_file" % type_)
- else:
+ else:
return self.media.filter(type=type_)
else:
return None
def get_ogg(self):
return self.get_media("ogg")
def get_daisy(self):
- return self.get_media("daisy")
+ return self.get_media("daisy")
def reset_short_html(self):
if self.id is None:
for fragm in self.fragments.all().iterator():
fragm.reset_short_html()
- try:
+ try:
author = self.tags.filter(category='author')[0].sort_key
except IndexError:
author = u''
if 'cover' not in dont_build:
book.cover.build_delay()
book.cover_thumb.build_delay()
-
+
# No saves behind this point.
if has_own_text:
rel_info = book.related_info()
names = [(related_tag_name(tag), Tag.create_url('author', tag['slug']))
for tag in rel_info['tags'].get('author', ())]
- import logging
- logging.info("%s, %s" % (book.slug, unicode(rel_info['tags'].get('author', ()))))
if 'parents' in rel_info:
books = [(name, Book.create_url(slug))
for name, slug in rel_info['parents']]
"""
# get relevant books and their tags
objects = cls.tagged.with_all(tags)
- parents = objects.filter(html_file='').only('slug')
+ parents = objects.exclude(children=None).only('slug')
# 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()
-
+
book_ids = set(b['pk'] for b in books.values("pk").iterator())
for book in books.iterator():
parent = book.parent_id
for tag in Tag.objects.filter(category='author').iterator():
books_by_author[tag] = []
- for book in books_by_parent.get(None,()):
+ for book in books_by_parent.get(None, ()):
authors = list(book.tags.filter(category='author'))
if authors:
for author in authors: