From b95d1183f738648f51099c1f75ace38e0c683456 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 12 Feb 2014 11:51:25 +0100 Subject: [PATCH] Test for parenthood by looking for children instead of HTML. --- apps/catalogue/models/book.py | 2 +- apps/reporting/templatetags/reporting_stats.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py index f85cfceca..83bc040c6 100644 --- a/apps/catalogue/models/book.py +++ b/apps/catalogue/models/book.py @@ -545,7 +545,7 @@ class Book(models.Model): """ # 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()]) diff --git a/apps/reporting/templatetags/reporting_stats.py b/apps/reporting/templatetags/reporting_stats.py index 6f20c087c..ee9a7bf74 100755 --- a/apps/reporting/templatetags/reporting_stats.py +++ b/apps/reporting/templatetags/reporting_stats.py @@ -50,11 +50,11 @@ def count_books_all(): @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(): - return Book.objects.filter(html_file='').count() + return Book.objects.exclude(children=None).count() @register_counter def count_books_root(): -- 2.20.1