Fixes #309: breadcrumbs to parent books
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 13 Aug 2010 08:41:58 +0000 (10:41 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 13 Aug 2010 08:41:58 +0000 (10:41 +0200)
apps/catalogue/views.py
wolnelektury/templates/catalogue/book_detail.html

index e7df9bc..617d19f 100644 (file)
@@ -214,6 +214,13 @@ def book_detail(request, slug):
     tags = list(book.tags.filter(~Q(category='set')))
     categories = split_tags(tags)
     book_children = book.children.all().order_by('parent_number')
+    
+    _book = book
+    parents = []
+    while _book.parent:
+        parents.append(_book.parent)
+        _book = _book.parent
+    parents = reversed(parents)
 
     theme_counter = book.theme_counter
     book_themes = models.Tag.objects.filter(pk__in=theme_counter.keys())
index b9faea6..cb5dee0 100644 (file)
     </form>
 
     <div id="books-list">
+        {% if parents %}
+            <div id='breadcrumbs'>
+                {% for parent in parents %}
+                    <a href="{{ parent.get_absolute_url }}">{{ parent }}</a>
+                    {% if not forloop.last %}&#187;{% endif %}
+                {% endfor %}
+            </div>
+        {% endif %}
+
         {% if extra_info.license %}
         <p>{% trans "Work is licensed under " %} <a href="{{ extra_info.license }}">{{ extra_info.license_description }}</a>.</p>
         {% endif %}