* src/ChooseParents.py: Disallow selecting self as a parent.

* src/SelectChild.py: Disallow selecting self as a child.


svn: r3093
This commit is contained in:
Alex Roitman 2004-04-21 04:22:37 +00:00
parent 76102265db
commit 62567532d2
3 changed files with 36 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2004-04-20 Alex Roitman <shura@alex.neuro.umn.edu>
* src/ChooseParents.py: Disallow selecting self as a parent.
2004-04-20 Jason Salaz <whatsizbucket@comcast.net>
* src/SelectChild.py: Disallow selecting self as a child.
2004-04-18 Don Allingham <dallingham@users.sourceforge.net>
* src/DbPrompter.py: support for new GTK 2.4 file chooser

View File

@ -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)

View File

@ -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)