Fixed complex books (books with hasPart).
authorMarek Stępniowski <marek@stepniowski.com>
Tue, 16 Sep 2008 18:59:34 +0000 (20:59 +0200)
committerMarek Stępniowski <marek@stepniowski.com>
Tue, 16 Sep 2008 18:59:34 +0000 (20:59 +0200)
apps/catalogue/models.py
apps/catalogue/views.py
wolnelektury/media/css/master.css
wolnelektury/templates/catalogue/book_detail.html
wolnelektury/templates/catalogue/book_short.html

index f31dbe6..2a93873 100644 (file)
@@ -166,7 +166,7 @@ class Book(models.Model):
         book.tags = book_tags
         
         if hasattr(book_info, 'parts'):
-            for part_url, n in enumerate(book_info.parts):
+            for n, part_url in enumerate(book_info.parts):
                 base, slug = part_url.rsplit('/', 1)
                 child_book = Book.objects.get(slug=slug)
                 child_book.parent = book
index acf2ea2..f07f9ab 100644 (file)
@@ -130,6 +130,7 @@ def book_detail(request, slug):
     book = get_object_or_404(models.Book, slug=slug)
     tags = list(book.tags.filter(~Q(category='set')))
     categories = split_tags(tags)
+    book_children = book.children.all().order_by('parent_number')
     
     form = forms.SearchForm()
     return render_to_response('catalogue/book_detail.html', locals(),
index 82d55a8..fae4417 100644 (file)
@@ -383,13 +383,18 @@ div.shown-tags p {
     margin-left: 3.5em;
 }
 
-.book-thumbnail {
+.book-thumbnail, .book-parent-thumbnail {
     background: transparent url(/media/img/book.png) no-repeat 0 0;
     width: 3em;
     height: 3em;
     float: left;
 }
 
+.book-parent-thumbnail {
+    background: transparent url(/media/img/book-parent.png) no-repeat 0 0;
+}
+
+
 /* =============== */
 /* = Simple form = */
 /* =============== */
index e6b5eb0..b567596 100644 (file)
             </ul>
         </div>
     
-        {% if book.children.all %}
+        {% if book_children %}
         <div id="book-children">
             <h2>Utwory składające się na ten utwór:</h2>
-            {% for book in book.children.all %}
-                <li><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></li>
+            <ol>
+            {% for book in book_children %}
+                <li>{{ book.short_html }}</li>
             {% endfor %}
+            </ol>
         </div>
         {% endif %}
     
index 7f93a59..368126d 100644 (file)
@@ -2,7 +2,7 @@
     <div class="change-sets">
         <a href="{% url catalogue.views.book_sets book.slug %}" class="jqm-trigger">Na półkę!</a>
     </div>
-    {% if book.children %}
+    {% if book.children.all|length %}
         <div class="book-parent-thumbnail"></div>
     {% else %}
         <div class="book-thumbnail"></div>