Test for parenthood by looking for children instead of HTML.
authorRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Wed, 12 Feb 2014 10:51:25 +0000 (11:51 +0100)
committerRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Wed, 12 Feb 2014 10:51:25 +0000 (11:51 +0100)
apps/catalogue/models/book.py
apps/reporting/templatetags/reporting_stats.py

index f85cfce..83bc040 100644 (file)
@@ -545,7 +545,7 @@ class Book(models.Model):
         """
         # get relevant books and their tags
         objects = cls.tagged.with_all(tags)
         """
         # get relevant books and their tags
         objects = cls.tagged.with_all(tags)
-        parents = objects.filter(html_file='').only('slug')
+        parents = objects.exclude(children=None).only('slug')
         # eliminate descendants
         l_tags = Tag.objects.filter(category='book',
             slug__in=[book.book_tag_slug() for book in parents.iterator()])
         # eliminate descendants
         l_tags = Tag.objects.filter(category='book',
             slug__in=[book.book_tag_slug() for book in parents.iterator()])
index 6f20c08..ee9a7bf 100755 (executable)
@@ -50,11 +50,11 @@ def count_books_all():
 
 @register_counter
 def count_books():
 
 @register_counter
 def count_books():
-    return Book.objects.exclude(html_file='').count()
+    return Book.objects.filter(children=None).count()
 
 @register_counter
 def count_books_parent():
 
 @register_counter
 def count_books_parent():
-    return Book.objects.filter(html_file='').count()
+    return Book.objects.exclude(children=None).count()
 
 @register_counter
 def count_books_root():
 
 @register_counter
 def count_books_root():