* src/AddSpouse.py (select_spouse_clicked): Prevent adding oneself

and oneself's parents as a spouse; When aborting, do not close dialog.
* src/RelLib.py (BaseObject): Add base data class, to support
capabilites common to all gramps objects; (matches_string,
matches_regexp): Add methods for searching textual objects;
(Person,Family,Event,Place,Source,MediaRef,LdsOrd,Attribute,Address,
Name,Location,Note,Url,Witness,SourceRef): Add methods for determining
textual objects and children with textual objects.


svn: r4182
This commit is contained in:
Alex Roitman
2005-03-15 05:23:12 +00:00
parent 00ed8a7693
commit d2e476e956
3 changed files with 397 additions and 12 deletions

View File

@ -243,6 +243,21 @@ class AddSpouse:
spouse = self.db.get_person_from_handle(idlist[0])
spouse_id = spouse.get_handle()
# don't do anything if adding self
if spouse_id == self.person.get_handle():
ErrorDialog(_("Error adding a spouse"),
_("A person cannot be linked as his/her spouse"))
return
# don't do anything if adding a parent
for (family_handle,frel,mrel) in self.person.get_parent_family_handle_list():
family = self.db.get_family_from_handle(family_handle)
if spouse_id in [family.get_mother_handle(),family.get_father_handle()]:
ErrorDialog(_("Error adding a spouse"),
_("A person cannot be linked as his/her "
"child's spouse"))
return
# don't do anything if the marriage already exists
for f in self.person.get_family_handle_list():
fam = self.db.get_family_from_handle(f)
@ -251,12 +266,11 @@ class AddSpouse:
(fam.get_mother_handle(),fam.get_father_handle()):
ErrorDialog(_("Error adding a spouse"),
_("The spouse is already present in this family"))
Utils.destroy_passed_object(obj)
return
if spouse_id in fam.get_child_handle_list():
ErrorDialog(_("Error adding a spouse"),
_("A person cannot be linked as his/her own parent"))
Utils.destroy_passed_object(obj)
_("A person cannot be linked as his/her "
"parent's spouse"))
return
trans = self.db.transaction_begin()