From: Marek Stępniowski Date: Thu, 11 Sep 2008 16:09:16 +0000 (+0200) Subject: Refactored tag lists to template tag. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/c82303f184e8d139817ca963c81a63e4c442f9b9?ds=inline;hp=-c Refactored tag lists to template tag. --- c82303f184e8d139817ca963c81a63e4c442f9b9 diff --git a/apps/catalogue/forms.py b/apps/catalogue/forms.py index 523b1d636..72aa08533 100644 --- a/apps/catalogue/forms.py +++ b/apps/catalogue/forms.py @@ -42,7 +42,7 @@ class NewSetForm(forms.Form): def __init__(self, *args, **kwargs): super(NewSetForm, self).__init__(*args, **kwargs) - self.fields['name'].widget.attrs['title'] = u'nazwa nowej półki' + self.fields['name'].widget.attrs['title'] = u'nazwa półki' def save(self, user, commit=True): name = self.cleaned_data['name'] diff --git a/apps/catalogue/templatetags/catalogue_tags.py b/apps/catalogue/templatetags/catalogue_tags.py index 8cce80de5..a20b50b76 100644 --- a/apps/catalogue/templatetags/catalogue_tags.py +++ b/apps/catalogue/templatetags/catalogue_tags.py @@ -187,3 +187,11 @@ def latest_blog_posts(feed_url, posts_to_show=5): }) return {'posts': posts} + +@register.inclusion_tag('catalogue/tag_list.html') +def tag_list(tags, choices=None): + if choices is None: + choices = [] + tag_count = len(tags) + return locals() + diff --git a/wolnelektury/templates/catalogue/book_sets.html b/wolnelektury/templates/catalogue/book_sets.html index c7394186a..0765c8bfb 100644 --- a/wolnelektury/templates/catalogue/book_sets.html +++ b/wolnelektury/templates/catalogue/book_sets.html @@ -1,11 +1,11 @@ -

Półki zawierające utwór {{ book.title }}

+

Wrzuć lekturę na półki

{% if not user.tag_set.count %}

Nie posiadasz żadnych półek. Jeśli chcesz, możesz utworzyć nową półkę poniżej.

{% else %}
  1. {{ form.set_ids }}
  2. -
  3. +
{% endif %} diff --git a/wolnelektury/templates/catalogue/main_page.html b/wolnelektury/templates/catalogue/main_page.html index 6af8d69d8..5cd85891a 100644 --- a/wolnelektury/templates/catalogue/main_page.html +++ b/wolnelektury/templates/catalogue/main_page.html @@ -29,11 +29,11 @@
    -
  1. {{ new_set_form.name }}
  2. +
  3. {{ new_set_form.name }}
{% else %} -

Stwórz własny zestaw lektur!

+

Stwórz własny zestaw lektur! Możesz się nim później podzielić z innymi, przesyłając im link do Twojej półki.

Aby zarządzać swoimi półkami musisz się .

{% endif %} @@ -41,48 +41,28 @@
{% if categories.author %}

Autorzy

- + {% tag_list categories.author %} {% endif %} {% if categories.epoch %}

Epoki

- + {% tag_list categories.epoch %} {% endif %} {% if categories.kind %}

Rodzaje

- + {% tag_list categories.kind %} {% endif %} {% if categories.genre %}

Gatunki literackie

- + {% tag_list categories.genre %} {% endif %}
- {% if categories.theme %} + {% if fragment_tags %}

Motywy

- + {% tag_list fragment_tags %} {% endif %}