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

svn: r17819
This commit is contained in:
Michiel Nauta 2011-06-20 15:26:19 +00:00
parent 0fa4b5a5ad
commit f7aea3022d

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