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:
Serge Noiraud 2021-05-06 17:14:26 +02:00 committed by GitHub
parent 5ad5f08a2b
commit 1d72f4b23d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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."""
@ -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