X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/c82303f184e8d139817ca963c81a63e4c442f9b9..04474c1980a751d4b6ca205e47b82e6471028e7f:/apps/catalogue/templatetags/catalogue_tags.py diff --git a/apps/catalogue/templatetags/catalogue_tags.py b/apps/catalogue/templatetags/catalogue_tags.py index a20b50b76..537e3ec56 100644 --- a/apps/catalogue/templatetags/catalogue_tags.py +++ b/apps/catalogue/templatetags/catalogue_tags.py @@ -37,6 +37,23 @@ def capfirst(text): return '' + +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)) + return ' '.join(title) + + @register.simple_tag def title_from_tags(tags): def split_tags(tags): @@ -45,6 +62,9 @@ def title_from_tags(tags): result[tag.category] = tag return result + # TODO: Remove this after adding flection mechanism + return simple_title(tags) + class Flection(object): def get_case(self, name, flection): return name @@ -192,6 +212,23 @@ def latest_blog_posts(feed_url, posts_to_show=5): def tag_list(tags, choices=None): if choices is None: choices = [] + if len(tags) == 1: + one_tag = tags[0] + return locals() + + +@register.inclusion_tag('catalogue/folded_tag_list.html') +def folded_tag_list(tags, choices=None): + if choices is None: + choices = [] + some_tags_hidden = False tag_count = len(tags) + + if tag_count == 1: + one_tag = tags[0] + else: + shown_tags = [tag for tag in tags if tag.main_page] + if tag_count > len(shown_tags): + some_tags_hidden = True return locals()