From 62567532d25d3d60f2ca8119119c3b25dad2dd87 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 21 Apr 2004 04:22:37 +0000 Subject: [PATCH] * src/ChooseParents.py: Disallow selecting self as a parent. * src/SelectChild.py: Disallow selecting self as a child. svn: r3093 --- gramps2/ChangeLog | 6 ++++++ gramps2/src/ChooseParents.py | 27 ++++++++++++++++++++++----- gramps2/src/SelectChild.py | 9 ++++++++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 8026b1d04..b39212b10 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2004-04-20 Alex Roitman + * src/ChooseParents.py: Disallow selecting self as a parent. + +2004-04-20 Jason Salaz + * src/SelectChild.py: Disallow selecting self as a child. + 2004-04-18 Don Allingham * src/DbPrompter.py: support for new GTK 2.4 file chooser diff --git a/gramps2/src/ChooseParents.py b/gramps2/src/ChooseParents.py index 19d773cac..eb58865cd 100644 --- a/gramps2/src/ChooseParents.py +++ b/gramps2/src/ChooseParents.py @@ -55,6 +55,7 @@ import const import Utils import GrampsCfg import PeopleModel +from QuestionDialog import ErrorDialog #------------------------------------------------------------------------- # @@ -472,7 +473,7 @@ class ChooseParents: def save_parents_clicked(self,obj): """ - Called with the OK button nis pressed. Saves the selected people as parents + Called with the OK button is pressed. Saves the selected people as parents of the main perosn. """ try: @@ -489,26 +490,42 @@ class ChooseParents: if self.mother and not self.father: if self.mother.get_gender() == RelLib.Person.male: self.father = self.mother + father_id = self.father.get_id() self.mother = None - self.family = self.find_family(self.father.get_id(),self.mother.get_id()) + mother_id = None + else: + mother_id = self.mother.get_id() + father_id = None elif self.father and not self.mother: if self.father.get_gender() == RelLib.Person.female: self.mother = self.father self.father = None - self.family = self.find_family(self.father.get_id(),self.mother.get_id()) + mother_id = self.mother.get_id() + father_id = None + else: + father_id = self.father.get_id() + mother_id = None elif self.mother.get_gender() != self.father.get_gender(): if self.type == "Partners": self.type = "Unknown" if self.father.get_gender() == RelLib.Person.female: self.father, self.mother = self.mother, self.father - self.family = self.find_family(self.father.get_id(),self.mother.get_id()) + father_id = self.father.get_id() + mother_id = self.mother.get_id() else: self.type = "Partners" - self.family = self.find_family(self.father.get_id(),self.mother.get_id()) + father_id = self.father.get_id() + mother_id = self.mother.get_id() + self.family = self.find_family(father_id,mother_id) else: self.family = None if self.family: + if self.person.get_id() in (father_id,mother_id): + ErrorDialog(_("Error selecting a child"), + _("A person cannot be linked as his/her own parent"), + self.top) + return self.family.add_child_id(self.person.get_id()) self.family.set_relationship(self.type) self.change_family_type(self.family,mother_rel,father_rel) diff --git a/gramps2/src/SelectChild.py b/gramps2/src/SelectChild.py index b5eca42a2..d7b2b1d4e 100644 --- a/gramps2/src/SelectChild.py +++ b/gramps2/src/SelectChild.py @@ -47,6 +47,7 @@ import Utils import PeopleModel import GrampsCfg from RelLib import Person +from QuestionDialog import ErrorDialog #------------------------------------------------------------------------- # @@ -300,10 +301,16 @@ class SelectChild: select_child.add_parent_family_id(self.family.get_id(),mrel,frel) + if id in (self.family.get_father_id(),self.family.get_mother_id()): + ErrorDialog(_("Error selecting a child"), + _("A person cannot be linked as his/her own child"), + self.top) + return + trans = self.db.start_transaction() self.db.commit_person(select_child,trans) self.db.add_transaction(trans) - + self.redraw(self.family) self.close(obj)