prettier player window,
[wolnelektury.git] / apps / catalogue / templatetags / catalogue_tags.py
index e8bc138..14ed64d 100644 (file)
@@ -148,6 +148,17 @@ def book_tree(book_list, books_by_parent):
     else:
         return ''
 
+@register.simple_tag
+def audiobook_tree(book_list, books_by_parent):
+    text = "".join("<li><a class='open-player' href='%s'>%s</a>%s</li>" % (
+        reverse("book_player", args=[book.slug]), book.title, audiobook_tree(books_by_parent.get(book, ()), books_by_parent)
+        ) for book in book_list)
+
+    if text:
+        return "<ol>%s</ol>" % text
+    else:
+        return ''
+
 @register.simple_tag
 def book_tree_texml(book_list, books_by_parent, depth=1):
     return "".join("""
@@ -350,7 +361,6 @@ def related_books(book, limit=6, random=1):
     cache_key = "catalogue.related_books.%d.%d" % (book.id, limit - random)
     related = cache.get(cache_key)
     if related is None:
-        print 'not in cache'
         related = list(Book.objects.filter(
             common_slug=book.common_slug).exclude(pk=book.pk)[:limit])
         limit -= len(related)