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
This commit is contained in:
parent
135acff4e8
commit
c61e79be76
@ -2,6 +2,7 @@
|
|||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2002-2006 Donald N. Allingham
|
# Copyright (C) 2002-2006 Donald N. Allingham
|
||||||
|
# Copyright (C) 2019 Matthias Kemmer
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -33,8 +34,11 @@ _ = glocale.translation.gettext
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from .. import Rule
|
from .. import Rule
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
# "People with children"
|
# "People with children"
|
||||||
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class HaveChildren(Rule):
|
class HaveChildren(Rule):
|
||||||
"""People with children"""
|
"""People with children"""
|
||||||
@ -43,7 +47,9 @@ class HaveChildren(Rule):
|
|||||||
description = _("Matches people who have children")
|
description = _("Matches people who have children")
|
||||||
category = _('Family filters')
|
category = _('Family filters')
|
||||||
|
|
||||||
def apply(self,db,person):
|
def apply(self, db, person):
|
||||||
for family_handle in person.get_family_handle_list():
|
for family_handle in person.get_family_handle_list():
|
||||||
family = db.get_family_from_handle(family_handle)
|
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
|
||||||
|
@ -575,7 +575,7 @@ class BaseTest(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
rule = HaveChildren([])
|
rule = HaveChildren([])
|
||||||
# too many to list out to test explicitly
|
# 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):
|
def test_incompletenames(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user