bugfix: list all objects, not just those with description
[wolnelektury.git] / src / catalogue / views.py
index 71b1de3..297339e 100644 (file)
@@ -193,7 +193,8 @@ def tagged_object_list(request, tags='', gallery=False):
                         'sort_key_author', 'title')
                 else:
                     objects = all_books.order_by('sort_key_author', 'title')
-            related_book_tags = get_top_level_related_tags(tags)
+                # WTF: was outside if, overwriting value assigned if shelf_is_set
+                related_book_tags = get_top_level_related_tags(tags)
 
             fragments = models.Fragment.objects.filter(book__in=all_books)
 
@@ -711,10 +712,12 @@ def tag_catalogue(request, category):
     else:
         tags = list(get_top_level_related_tags((), categories=(category,)))
 
-    if len(tags) > 3:
-        best = random.sample(tags, 3)
+    described_tags = [tag for tag in tags if tag.description]
+
+    if len(described_tags) > 4:
+        best = random.sample(described_tags, 4)
     else:
-        best = tags
+        best = described_tags
 
     return render(request, 'catalogue/tag_catalogue.html', {
         'tags': tags,