From 59162682c07a2c045191511143f5b3d585206105 Mon Sep 17 00:00:00 2001 From: Martin Hawlisch Date: Thu, 25 Aug 2005 21:05:44 +0000 Subject: [PATCH] * src/SelectChild.py (on_save_child_clicke): Dont add the same person multiple times as child * src/gramps_main.py (delete_person_response): Purge empty family after the last child of a single-spouse family was deleted. svn: r5125 --- gramps2/ChangeLog | 6 ++++++ gramps2/src/SelectChild.py | 10 +++++++++- gramps2/src/gramps_main.py | 19 +++++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 1de248697..0c5afd047 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2005-08-25 Martin Hawlisch + * src/SelectChild.py (on_save_child_clicke): Dont add the same person + multiple times as child + * src/gramps_main.py (delete_person_response): Purge empty family + after the last child of a single-spouse family was deleted. + 2005-08-24 Don Allingham * src/ImgManip.py: convert to png instead of jpeg * src/ReadGedcom.py: try to catch bad secondary index error. diff --git a/gramps2/src/SelectChild.py b/gramps2/src/SelectChild.py index 1d71a55c1..a32eda186 100644 --- a/gramps2/src/SelectChild.py +++ b/gramps2/src/SelectChild.py @@ -206,7 +206,15 @@ class SelectChild: else: self.family.set_mother_handle(self.person.get_handle()) self.db.commit_family(self.family,trans) - + + # check that selected child is not already a child in family + if handle in self.family.get_child_handle_list(): + ErrorDialog(_("Error selecting a child"), + _("The person is already linked as child"), + self.top) + return + + # check that selected child is not already a spouse in family if handle in (self.family.get_father_handle(),self.family.get_mother_handle()): ErrorDialog(_("Error selecting a child"), _("A person cannot be linked as his/her own child"), diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index 4830a6ff6..8dd827f9f 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -1527,10 +1527,25 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): self.db.commit_family(family,trans) for (family_handle,mrel,frel) in self.active_person.get_parent_family_handle_list(): - if family_handle: - family = self.db.get_family_from_handle(family_handle) + family = self.db.get_family_from_handle(family_handle) + if family: family.remove_child_handle(self.active_person.get_handle()) self.db.commit_family(family,trans) + + # Purge empty family + if len(family.get_child_handle_list()) == 0: + if not family.get_father_handle(): + mother = self.db.get_person_from_handle( family.get_mother_handle()) + if mother: + mother.remove_family_handle( family_handle) + self.db.commit_person( mother,trans) + self.db.remove_family(family_handle,trans) + if not family.get_mother_handle(): + father = self.db.get_person_from_handle( family.get_father_handle()) + if father: + father.remove_family_handle( family_handle) + self.db.commit_person( father,trans) + self.db.remove_family(family_handle,trans) handle = self.active_person.get_handle()