diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index e9b07c232..110e6cbc6 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2005-06-20 Alexander Roitman + * src/SelectChildpy (LikelyFilter.prepare,LikelyFilter.apply): + Handle absent birth of a parent. + * src/AddSpouse.py (LikelyFilter.prepare,LikelyFilter.apply): + Handle absent birth of a parent; correctly use gender. + 2005-06-19 Don Allingham * src/AddSpouse.py: display idle cursor, build better likely filter * src/SelectChild.py: display idle cursor diff --git a/gramps2/src/AddSpouse.py b/gramps2/src/AddSpouse.py index 201768317..f99f1d014 100644 --- a/gramps2/src/AddSpouse.py +++ b/gramps2/src/AddSpouse.py @@ -393,14 +393,19 @@ class LikelyFilter(GenericFilter.Rule): def prepare(self,db): person = db.get_person_from_handle(self.list[0]) - birth = db.get_event_from_handle(person.birth_handle) - dateobj = Date.Date(birth.date) - year = dateobj.get_year() - dateobj.set_year(year+40) - self.lower = dateobj.sortval - dateobj.set_year(year-40) - self.upper = dateobj.sortval - if self.list[0] == RelLib.Person.MALE: + if person.birth_handle: + birth = db.get_event_from_handle(person.birth_handle) + dateobj = Date.Date(birth.date) + year = dateobj.get_year() + dateobj.set_year(year+40) + self.lower = dateobj.sortval + dateobj.set_year(year-40) + self.upper = dateobj.sortval + else: + self.upper = None + self.lower = None + + if person.gender == RelLib.Person.MALE: self.gender = RelLib.Person.FEMALE else: self.gender = RelLib.Person.MALE @@ -409,7 +414,8 @@ class LikelyFilter(GenericFilter.Rule): person = db.get_person_from_handle(handle) if person.gender != self.gender: return False - if not person.birth_handle: + if not person.birth_handle or (self.upper == None and + self.lower == None): return True event = db.get_event_from_handle(person.birth_handle) return (event.date == None or event.date.sortval == 0 or diff --git a/gramps2/src/SelectChild.py b/gramps2/src/SelectChild.py index ed7ac6fc1..78a776a72 100644 --- a/gramps2/src/SelectChild.py +++ b/gramps2/src/SelectChild.py @@ -2,7 +2,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2004 Donald N. Allingham +# Copyright (C) 2000-2005 Donald N. Allingham # # 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 @@ -303,20 +303,25 @@ class SelectChild: class LikelyFilter(GenericFilter.Rule): category = _('General filters') - + def prepare(self,db): person = db.get_person_from_handle(self.list[0]) - birth = db.get_event_from_handle(person.birth_handle) - dateobj = Date.Date(birth.date) - year = dateobj.get_year() - dateobj.set_year(year+10) - self.lower = dateobj.sortval - dateobj.set_year(year+70) - self.upper = dateobj.sortval - + if person.birth_handle: + birth = db.get_event_from_handle(person.birth_handle) + dateobj = Date.Date(birth.date) + year = dateobj.get_year() + dateobj.set_year(year+10) + self.lower = dateobj.sortval + dateobj.set_year(year+70) + self.upper = dateobj.sortval + else: + self.lower = None + self.upper = None + def apply(self,db,handle): person = db.get_person_from_handle(handle) - if not person.birth_handle: + if not person.birth_handle or (self.upper == None and + self.lower == None): return True event = db.get_event_from_handle(person.birth_handle) return (event.date == None or event.date.sortval == 0 or