From: Marek Stępniowski Date: Wed, 3 Sep 2008 22:49:28 +0000 (+0200) Subject: Added inclusion tag for book. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/f7bf1b53894f95a4c27d3063c70ce798f39a6d3b Added inclusion tag for book. --- diff --git a/catalogue/templatetags/catalogue_tags.py b/catalogue/templatetags/catalogue_tags.py index 3c75801a7..d3a25ad93 100644 --- a/catalogue/templatetags/catalogue_tags.py +++ b/catalogue/templatetags/catalogue_tags.py @@ -4,6 +4,7 @@ from django.template import Node, Variable from django.utils.encoding import smart_str from django.core.urlresolvers import reverse from django.contrib.auth.forms import UserCreationForm, AuthenticationForm +from django.db.models import Q register = template.Library() @@ -116,6 +117,22 @@ def breadcrumbs(tags, search_form=True): return context +@register.inclusion_tag('catalogue/_book.html') +def book(book): + tags = book.tags.filter(~Q(category__in=('set', 'theme'))) + tags = [u'%s' % (tag.get_absolute_url(), tag.name) for tag in tags] + + formats = [] + if book.html_file: + formats.append(u'Czytaj online' % book.html_file.url) + if book.pdf_file: + formats.append(u'Plik PDF' % book.pdf_file.url) + if book.odt_file: + formats.append(u'Plik ODT' % book.odt_file.url) + + return {'book': book, 'tags': tags, 'formats': formats} + + @register.tag def catalogue_url(parser, token): bits = token.split_contents() diff --git a/templates/catalogue/_book.html b/templates/catalogue/_book.html index 7666b61fe..08cb12c5e 100644 --- a/templates/catalogue/_book.html +++ b/templates/catalogue/_book.html @@ -7,24 +7,7 @@

{{ book.title }}

-

Formaty: - Czytaj online - {% if book.pdf_file %} - Pobierz plik PDF - {% endif %} - {% if book.odt_file %} - ODT - {% endif %} - {% if book.html_file %} - Pobierz plik HTML - {% endif %} -

-

Utwór w kategoriach: - {% for tag in book.tags %} - {% ifnotequal tag.category "set" %} - {{ tag }}{% if not forloop.last %},{% endif %} - {% endifnotequal %} - {% endfor %} -

+

Formaty: {{ formats|join:", "|safe }}

+

Utwór w kategoriach: {{ tags|join:", "|safe }}

\ No newline at end of file