Tag clouds: Hiding "uncategorized" category if no uncategorized tags exist
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 9 May 2013 13:36:20 +0000 (15:36 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 9 May 2013 13:36:20 +0000 (15:36 +0200)
questions/templates/questions/question_list.html
questions/views.py

index f279208..ccf2ad7 100755 (executable)
@@ -32,7 +32,9 @@ doświadczenie doradcze w tej tematyce.</p>
     <h2>Filtruj pytania</h2>
     Wybierz kategorię tematów:
     <div id="questions-categories">
+    {% if has_uncategorized_tags %}
     <a href="#" {% if tag and not tag.category %}class="selected"{% endif %} data-category-id="0">bez kategorii</a>
+    {% endif %}
     {% for category in tag_categories %}
             <a href="#" style="font-size: {{category.cloud_size}}em;" {% if tag.category == category %}class="selected"{% endif %} data-category-id="{{category.id}}">{{category}}</a>
     {% endfor %}
index 076a2e0..f35f5fe 100644 (file)
@@ -65,5 +65,6 @@ class QuestionListView(ListView):
                 category_click_count = uncategorized_tags_click_count
             tag.cloud_size = get_cloud_size(tag.click_count, category_click_count)
             context['tag_lists'].setdefault(tag.category.id if tag.category else 0, []).append(tag)
+        context['has_uncategorized_tags'] = 0 in context['tag_lists']
         
         return context