From: Marek Stępniowski Date: Thu, 11 Sep 2008 16:22:00 +0000 (+0200) Subject: Further refactoring of tag lists. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/88eaa6c36bd8a5eb8fe1a1b3ad1f8aaddb258d5c?ds=sidebyside;hp=c82303f184e8d139817ca963c81a63e4c442f9b9 Further refactoring of tag lists. --- diff --git a/apps/catalogue/templatetags/catalogue_tags.py b/apps/catalogue/templatetags/catalogue_tags.py index a20b50b76..51ee86333 100644 --- a/apps/catalogue/templatetags/catalogue_tags.py +++ b/apps/catalogue/templatetags/catalogue_tags.py @@ -192,6 +192,7 @@ def latest_blog_posts(feed_url, posts_to_show=5): def tag_list(tags, choices=None): if choices is None: choices = [] - tag_count = len(tags) + if len(tags) == 1: + one_tag = tags[0] return locals() diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index f0f3e71db..56df88f99 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -73,9 +73,7 @@ def main_page(request): if request.user.is_authenticated(): shelves = models.Tag.objects.filter(category='set', user=request.user) new_set_form = forms.NewSetForm() - extra_where = '(NOT catalogue_tag.category = "set" OR catalogue_tag.user_id = %d)' % request.user.id - else: - extra_where = 'NOT catalogue_tag.category = "set"' + extra_where = 'NOT catalogue_tag.category = "set"' tags = models.Tag.objects.usage_for_model(models.Book, counts=True, extra={'where': [extra_where]}) fragment_tags = models.Tag.objects.usage_for_model(models.Fragment, counts=True, extra={'where': ['catalogue_tag.category = "theme"'] + [extra_where]}) @@ -109,10 +107,7 @@ def tagged_object_list(request, tags=''): if theme_is_set: model = models.Fragment - if request.user.is_authenticated(): - extra_where = '(NOT catalogue_tag.category = "set" OR catalogue_tag.user_id = %d)' % request.user.id - else: - extra_where = 'NOT catalogue_tag.category = "set"' + extra_where = 'NOT catalogue_tag.category = "set"' related_tags = models.Tag.objects.related_for_model(tags, model, counts=True, extra={'where': [extra_where]}) categories = split_tags(related_tags) diff --git a/wolnelektury/templates/catalogue/tagged_object_list.html b/wolnelektury/templates/catalogue/tagged_object_list.html index b842cb44a..2bf636ecc 100644 --- a/wolnelektury/templates/catalogue/tagged_object_list.html +++ b/wolnelektury/templates/catalogue/tagged_object_list.html @@ -74,55 +74,27 @@
- {% if categories.set %} -

Półki

- - {% endif %} {% if categories.author %}

Autorzy

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

Epoki

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

Rodzaje

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

Gatunki literackie

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

Motywy

- + {% tag_list categories.theme tags %} {% endif %}