From: Radek Czajka Date: Wed, 12 Feb 2014 10:51:25 +0000 (+0100) Subject: Test for parenthood by looking for children instead of HTML. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/b95d1183f738648f51099c1f75ace38e0c683456?ds=sidebyside Test for parenthood by looking for children instead of HTML. --- 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():