5027: After export to XML and Import into new DB all surnames become primary

svn: r17818
This commit is contained in:
Michiel Nauta 2011-06-20 15:25:28 +00:00
parent e2e399799c
commit 902fa56b26

View File

@ -1554,7 +1554,7 @@ class GrampsParser(UpdateCallback):
def start_surname(self, attrs):
self.surname = gen.lib.Surname()
self.surname.set_prefix(attrs.get("prefix", ""))
self.surname.set_primary(bool(attrs.get("prim", 1)))
self.surname.set_primary(attrs.get("prim", "1") == "1")
self.surname.set_connector(attrs.get("connector", ""))
origin_type = attrs.get("derivation", "")
self.surname.origintype.set_from_xml_str(origin_type)
@ -2621,8 +2621,11 @@ class GrampsParser(UpdateCallback):
self.surname = None
def stop_surname(self, tag):
"""Add surname to name, validating only one primary."""
if self.name:
self.surname.set_surname(tag)
if any(sname.get_primary() for sname in self.name.get_surname_list()):
self.surname.set_primary(False)
self.name.add_surname(self.surname)
self.surname = None