From 92c4a21dbc8fa9ff9c8d10127b7afffed5341b23 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20St=C4=99pniowski?= Date: Tue, 16 Sep 2008 20:59:34 +0200 Subject: [PATCH] Fixed complex books (books with hasPart). --- apps/catalogue/models.py | 2 +- apps/catalogue/views.py | 1 + wolnelektury/media/css/master.css | 7 ++++++- wolnelektury/templates/catalogue/book_detail.html | 8 +++++--- wolnelektury/templates/catalogue/book_short.html | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index f31dbe632..2a9387300 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -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 diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index acf2ea244..f07f9abc4 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -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(), diff --git a/wolnelektury/media/css/master.css b/wolnelektury/media/css/master.css index 82d55a811..fae441765 100644 --- a/wolnelektury/media/css/master.css +++ b/wolnelektury/media/css/master.css @@ -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 = */ /* =============== */ diff --git a/wolnelektury/templates/catalogue/book_detail.html b/wolnelektury/templates/catalogue/book_detail.html index e6b5eb001..b56759645 100644 --- a/wolnelektury/templates/catalogue/book_detail.html +++ b/wolnelektury/templates/catalogue/book_detail.html @@ -54,12 +54,14 @@ - {% if book.children.all %} + {% if book_children %}

Utwory składające się na ten utwór:

- {% for book in book.children.all %} -
  • {{ book.title }}
  • +
      + {% for book in book_children %} +
    1. {{ book.short_html }}
    2. {% endfor %} +
    {% endif %} diff --git a/wolnelektury/templates/catalogue/book_short.html b/wolnelektury/templates/catalogue/book_short.html index 7f93a592b..368126db8 100644 --- a/wolnelektury/templates/catalogue/book_short.html +++ b/wolnelektury/templates/catalogue/book_short.html @@ -2,7 +2,7 @@
    Na półkę!
    - {% if book.children %} + {% if book.children.all|length %}
    {% else %}
    -- 2.20.1