minimal allauth support
[wolnelektury.git] / apps / catalogue / templatetags / catalogue_tags.py
index e8bc138..e9b1610 100644 (file)
@@ -45,6 +45,10 @@ def capfirst(text):
     except IndexError:
         return ''
 
+@register.filter
+def build_absolute_uri(uri, request):
+    return request.build_absolute_uri(uri)
+
 
 @register.simple_tag
 def html_title_from_tags(tags):
@@ -148,6 +152,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 +365,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)