From c61e79be76cd7cce77fa2627c7935a8abd125598 Mon Sep 17 00:00:00 2001 From: Mattkmmr <49940207+Mattkmmr@users.noreply.github.com> Date: Mon, 10 Jun 2019 02:43:26 +0200 Subject: [PATCH] Fix '_havechildren.py' person filter (#819) * Fix '_havechildren.py' person filter Check all families of a person for children and not only the first family * Update 'person_rule_test.py' and '_havechildren.py' Correct number for persons who have children is 905 --- gramps/gen/filters/rules/person/_havechildren.py | 10 ++++++++-- gramps/gen/filters/rules/test/person_rules_test.py | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gramps/gen/filters/rules/person/_havechildren.py b/gramps/gen/filters/rules/person/_havechildren.py index 4c91ceb2a..24b823cfd 100644 --- a/gramps/gen/filters/rules/person/_havechildren.py +++ b/gramps/gen/filters/rules/person/_havechildren.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2002-2006 Donald N. Allingham +# Copyright (C) 2019 Matthias Kemmer # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -33,8 +34,11 @@ _ = glocale.translation.gettext #------------------------------------------------------------------------- from .. import Rule + #------------------------------------------------------------------------- +# # "People with children" +# #------------------------------------------------------------------------- class HaveChildren(Rule): """People with children""" @@ -43,7 +47,9 @@ class HaveChildren(Rule): description = _("Matches people who have children") category = _('Family filters') - def apply(self,db,person): + def apply(self, db, person): for family_handle in person.get_family_handle_list(): family = db.get_family_from_handle(family_handle) - return (family is not None) and len(family.get_child_ref_list()) > 0 + if family is not None and family.get_child_ref_list(): + return True + return False diff --git a/gramps/gen/filters/rules/test/person_rules_test.py b/gramps/gen/filters/rules/test/person_rules_test.py index e758f3123..e7997b025 100644 --- a/gramps/gen/filters/rules/test/person_rules_test.py +++ b/gramps/gen/filters/rules/test/person_rules_test.py @@ -575,7 +575,7 @@ class BaseTest(unittest.TestCase): """ rule = HaveChildren([]) # too many to list out to test explicitly - self.assertEqual(len(self.filter_with_rule(rule)), 901) + self.assertEqual(len(self.filter_with_rule(rule)), 905) def test_incompletenames(self): """