From: Marek Stępniowski Date: Tue, 16 Sep 2008 18:59:34 +0000 (+0200) Subject: Fixed complex books (books with hasPart). X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/92c4a21dbc8fa9ff9c8d10127b7afffed5341b23 Fixed complex books (books with hasPart). --- 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 %}