X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/c4b4a64757ba65018dc24334cb44a12ad2a4316a..9deab73593038a6b11d39f65e3a81c41fc2b13f9:/apps/catalogue/templatetags/catalogue_tags.py?ds=inline diff --git a/apps/catalogue/templatetags/catalogue_tags.py b/apps/catalogue/templatetags/catalogue_tags.py index 36a015ae6..6560730f2 100644 --- a/apps/catalogue/templatetags/catalogue_tags.py +++ b/apps/catalogue/templatetags/catalogue_tags.py @@ -12,6 +12,7 @@ from django.core.urlresolvers import reverse from django.contrib.auth.forms import UserCreationForm, AuthenticationForm from django.db.models import Q from django.conf import settings +from django.utils.translation import ugettext as _ register = template.Library() @@ -46,37 +47,15 @@ def capfirst(text): def simple_title(tags): - mapping = { - 'author': u'Autor', - 'theme': u'motyw', - 'epoch': u'epoka', - 'genre': u'gatunek', - 'kind': u'rodzaj', - 'set': u'póÅka', - } - title = [] for tag in tags: - title.append("%s: %s" % (mapping[tag.category], tag.name)) + title.append("%s: %s" % (_(tag.category), tag.name)) return capfirst(', '.join(title)) @register.simple_tag def book_title(book, html_links=False): - names = list(book.tags.filter(category='author')) - - books = [] - while book: - books.append(book) - book = book.parent - names.extend(reversed(books)) - - if html_links: - names = ['%s' % (tag.get_absolute_url(), tag.name) for tag in names] - else: - names = [tag.name for tag in names] - - return ', '.join(names) + return book.pretty_title(html_links) @register.simple_tag @@ -148,6 +127,18 @@ def title_from_tags(tags): return capfirst(title) +@register.simple_tag +def book_tree(book_list, books_by_parent): + text = "".join("