* 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:
parent
88874cd212
commit
478f90b8e8
@ -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>
|
2005-07-28 Alex Roitman <shura@gramps-project.org>
|
||||||
* src/plugins/WebPage.py (WebReportOptions.set_new_options):
|
* src/plugins/WebPage.py (WebReportOptions.set_new_options):
|
||||||
Define help dictionary to document options.
|
Define help dictionary to document options.
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
import sets
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -46,6 +47,7 @@ import ReportUtils
|
|||||||
import Utils
|
import Utils
|
||||||
import NameDisplay
|
import NameDisplay
|
||||||
import const
|
import const
|
||||||
|
import QuestionDialog
|
||||||
|
|
||||||
sex = ( _("female"), _("male"), _("unknown"))
|
sex = ( _("female"), _("male"), _("unknown"))
|
||||||
|
|
||||||
@ -79,13 +81,27 @@ class Compare:
|
|||||||
help_display('gramps-manual','adv-merge-people')
|
help_display('gramps-manual','adv-merge-people')
|
||||||
|
|
||||||
def merge(self,obj):
|
def merge(self,obj):
|
||||||
if self.glade.get_widget('select1').get_active():
|
|
||||||
merge = MergePeople(self.db,self.p1,self.p2)
|
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:
|
else:
|
||||||
merge = MergePeople(self.db,self.p2,self.p1)
|
if self.glade.get_widget('select1').get_active():
|
||||||
self.top.destroy()
|
merge = MergePeople(self.db,self.p1,self.p2)
|
||||||
merge.merge()
|
else:
|
||||||
self.update()
|
merge = MergePeople(self.db,self.p2,self.p1)
|
||||||
|
self.top.destroy()
|
||||||
|
merge.merge()
|
||||||
|
self.update()
|
||||||
|
|
||||||
def add(self, tobj, tag, text):
|
def add(self, tobj, tag, text):
|
||||||
text += "\n"
|
text += "\n"
|
||||||
@ -213,6 +229,23 @@ class Compare:
|
|||||||
return ""
|
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
|
# Merge People UI
|
||||||
@ -238,12 +271,26 @@ class MergePeopleUI:
|
|||||||
ret = top.run()
|
ret = top.run()
|
||||||
|
|
||||||
if ret == gtk.RESPONSE_OK:
|
if ret == gtk.RESPONSE_OK:
|
||||||
if p1.get_active():
|
|
||||||
merge = MergePeople(db,person1,person2)
|
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:
|
else:
|
||||||
merge = MergePeople(db,person2,person1)
|
if p1.get_active():
|
||||||
merge.merge()
|
merge = MergePeople(db,person1,person2)
|
||||||
update()
|
else:
|
||||||
|
merge = MergePeople(db,person2,person1)
|
||||||
|
merge.merge()
|
||||||
|
update()
|
||||||
top.destroy()
|
top.destroy()
|
||||||
|
|
||||||
def help(self,obj):
|
def help(self,obj):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user