* src/MergePeople.py: prevent attempts to merge a person and his/her

spouse, prevent merging of child and parent.


svn: r4975
This commit is contained in:
Don Allingham 2005-07-29 04:27:14 +00:00
parent 88874cd212
commit 478f90b8e8
2 changed files with 62 additions and 11 deletions

View File

@ -1,3 +1,7 @@
2005-07-28 Don Allingham <don@gramps-project.org>
* src/MergePeople.py: prevent attempts to merge a person and his/her
spouse, prevent merging of child and parent.
2005-07-28 Alex Roitman <shura@gramps-project.org>
* src/plugins/WebPage.py (WebReportOptions.set_new_options):
Define help dictionary to document options.

View File

@ -26,6 +26,7 @@
#
#-------------------------------------------------------------------------
from gettext import gettext as _
import sets
#-------------------------------------------------------------------------
#
@ -46,6 +47,7 @@ import ReportUtils
import Utils
import NameDisplay
import const
import QuestionDialog
sex = ( _("female"), _("male"), _("unknown"))
@ -79,6 +81,20 @@ class Compare:
help_display('gramps-manual','adv-merge-people')
def merge(self,obj):
if check_for_spouse(self.p1,self.p2):
QuestionDialog.ErrorDialog(
_("Cannot merge people"),
_("Spouses cannot be merged. To merge these people, "
"you must first break the relationship between the "
"two people."))
elif check_for_child(self.p1,self.p2):
QuestionDialog.ErrorDialog(
_("Cannot merge people"),
_("A parent and child cannot be merged. To merge these "
"people, you must first break the relationship between "
"the two people."))
else:
if self.glade.get_widget('select1').get_active():
merge = MergePeople(self.db,self.p1,self.p2)
else:
@ -213,6 +229,23 @@ class Compare:
return ""
def check_for_spouse(p1, p2):
f1 = sets.Set(p1.get_family_handle_list())
f2 = sets.Set(p2.get_family_handle_list())
return len(f1.intersection(f2)) != 0
def check_for_child(p1, p2):
fs1 = sets.Set(p1.get_family_handle_list())
fp1 = sets.Set(map(lambda x: x[0], p1.get_parent_family_handle_list()))
fs2 = sets.Set(p2.get_family_handle_list())
fp2 = sets.Set(map(lambda x: x[0], p2.get_parent_family_handle_list()))
return len(fs1.intersection(fp2)) != 0 or len(fs2.intersection(fp1))
#-------------------------------------------------------------------------
#
# Merge People UI
@ -238,6 +271,20 @@ class MergePeopleUI:
ret = top.run()
if ret == gtk.RESPONSE_OK:
if check_for_spouse(person1,person2):
QuestionDialog.ErrorDialog(
_("Cannot merge people"),
_("Spouses cannot be merged. To merge these people, "
"you must first break the relationship between the "
"two people."))
elif check_for_child(person1,person2):
QuestionDialog.ErrorDialog(
_("Cannot merge people"),
_("A parent and child cannot be merged. To merge these "
"people, you must first break the relationship between "
"the two people."))
else:
if p1.get_active():
merge = MergePeople(db,person1,person2)
else: