Home Person setting does not convey in a Merge (#1187)
* Home Person setting does not convey in a Merge Fixes #012235 * better pylint score
This commit is contained in:
parent
5ad5f08a2b
commit
1d72f4b23d
@ -31,8 +31,8 @@ Provide merge capabilities for persons.
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from ..db import DbTxn
|
from ..db import DbTxn
|
||||||
from ..const import GRAMPS_LOCALE as glocale
|
from ..const import GRAMPS_LOCALE as glocale
|
||||||
_ = glocale.translation.sgettext
|
|
||||||
from ..errors import MergeError
|
from ..errors import MergeError
|
||||||
|
_ = glocale.translation.sgettext
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -49,11 +49,12 @@ class MergePersonQuery:
|
|||||||
self.titanic = titanic
|
self.titanic = titanic
|
||||||
if self.check_for_spouse(self.phoenix, self.titanic):
|
if self.check_for_spouse(self.phoenix, self.titanic):
|
||||||
raise MergeError(_("Spouses cannot be merged. To merge these "
|
raise MergeError(_("Spouses cannot be merged. To merge these "
|
||||||
"people, you must first break the relationship between them."))
|
"people, you must first break the relationship"
|
||||||
|
" between them."))
|
||||||
if self.check_for_child(self.phoenix, self.titanic):
|
if self.check_for_child(self.phoenix, self.titanic):
|
||||||
raise MergeError(_("A parent and child cannot be merged. To merge "
|
raise MergeError(_("A parent and child cannot be merged. To merge "
|
||||||
"these people, you must first break the relationship between "
|
"these people, you must first break the relatio"
|
||||||
"them."))
|
"nship between them."))
|
||||||
|
|
||||||
def check_for_spouse(self, person1, person2):
|
def check_for_spouse(self, person1, person2):
|
||||||
"""Return if person1 and person2 are spouses of eachother."""
|
"""Return if person1 and person2 are spouses of eachother."""
|
||||||
@ -80,12 +81,12 @@ class MergePersonQuery:
|
|||||||
main_family.merge(family)
|
main_family.merge(family)
|
||||||
for childref in family.get_child_ref_list():
|
for childref in family.get_child_ref_list():
|
||||||
child = self.database.get_person_from_handle(
|
child = self.database.get_person_from_handle(
|
||||||
childref.get_reference_handle())
|
childref.get_reference_handle())
|
||||||
if main_family_handle in child.parent_family_list:
|
if main_family_handle in child.parent_family_list:
|
||||||
child.remove_handle_references('Family', [family_handle])
|
child.remove_handle_references('Family', [family_handle])
|
||||||
else:
|
else:
|
||||||
child.replace_handle_reference('Family', family_handle,
|
child.replace_handle_reference('Family', family_handle,
|
||||||
main_family_handle)
|
main_family_handle)
|
||||||
self.database.commit_person(child, trans)
|
self.database.commit_person(child, trans)
|
||||||
if self.phoenix:
|
if self.phoenix:
|
||||||
self.phoenix.remove_family_handle(family_handle)
|
self.phoenix.remove_family_handle(family_handle)
|
||||||
@ -143,7 +144,8 @@ class MergePersonQuery:
|
|||||||
for family_handle in self.phoenix.get_parent_family_handle_list():
|
for family_handle in self.phoenix.get_parent_family_handle_list():
|
||||||
family = self.database.get_family_from_handle(family_handle)
|
family = self.database.get_family_from_handle(family_handle)
|
||||||
if family.has_handle_reference('Person', old_handle):
|
if family.has_handle_reference('Person', old_handle):
|
||||||
family.replace_handle_reference('Person', old_handle,new_handle)
|
family.replace_handle_reference('Person', old_handle,
|
||||||
|
new_handle)
|
||||||
self.database.commit_family(family, trans)
|
self.database.commit_family(family, trans)
|
||||||
|
|
||||||
family_merge_guard = False
|
family_merge_guard = False
|
||||||
@ -182,7 +184,10 @@ class MergePersonQuery:
|
|||||||
self.database.commit_family(family, trans)
|
self.database.commit_family(family, trans)
|
||||||
parent_list.append(parents)
|
parent_list.append(parents)
|
||||||
|
|
||||||
if self.database.get_default_handle() == old_handle:
|
hp_hdl = self.database.get_default_handle()
|
||||||
self.database.set_default_person_handle(None)
|
if (hp_hdl in (self.phoenix.get_handle(), self.titanic.get_handle())
|
||||||
|
and hp_hdl != self.phoenix.get_handle()):
|
||||||
|
self.database.set_default_person_handle(self.phoenix.get_handle())
|
||||||
|
|
||||||
self.database.remove_person(old_handle, trans)
|
self.database.remove_person(old_handle, trans)
|
||||||
return family_merge_ok
|
return family_merge_ok
|
||||||
|
Loading…
Reference in New Issue
Block a user