ImportCSV: allow person, family, and marriage to reference places with place_id columns

This commit is contained in:
Doug Blank 2015-08-07 09:56:06 -04:00
parent 7481e7d462
commit 482c2ae5b8

View File

@ -163,6 +163,9 @@ class CSVParser(object):
"note": ("Note", _("Note"), "note", _("note")),
"birthplace": ("Birthplace", "Birth place", _("Birth place"),
"birthplace", "birth_place", "birth place", _("birth place")),
"birthplace_id": ("Birthplaceid", "Birth place id", _("Birth place id"),
"birthplaceid", "birth_place_id", "birth place id", _("birth place id"),
"birthplace_id"),
"birthdate": ("Birthdate", "Birth date", _("Birth date"),
"birthdate", "birth_date", "birth date", _("birth date")),
"birthsource": ("Birthsource", "Birth source", _("Birth source"),
@ -171,6 +174,10 @@ class CSVParser(object):
"baptismplace": ("Baptismplace", "Baptism place",
_("Baptism place"), "baptismplace", "baptism place",
_("baptism place")),
"baptismplace_id": ("Baptismplaceid", "Baptism place id",
_("Baptism place id"), "baptismplaceid", "baptism place id",
_("baptism place id"), "baptism_place_id",
"baptismplace_id"),
"baptismdate": ("Baptismdate", "Baptism date", _("Baptism date"),
"baptismdate", "baptism date", _("baptism date")),
"baptismsource": ("Baptismsource", "Baptism source",
@ -178,6 +185,9 @@ class CSVParser(object):
_("baptism source")),
"burialplace": ("Burialplace", "Burial place", _("Burial place"),
"burialplace", "burial place", _("burial place")),
"burialplace_id": ("Burialplaceid", "Burial place id", _("Burial place id"),
"burialplaceid", "burial place id", _("burial place id"),
"burial_place_id", "burialplace_id"),
"burialdate": ("Burialdate", "Burial date", _("Burial date"),
"burialdate", "burial date", _("burial date")),
"burialsource": ("Burialsource", "Burial source",
@ -185,6 +195,9 @@ class CSVParser(object):
_("burial source")),
"deathplace": ("Deathplace", "Death place", _("Death place"),
"deathplace", "death_place", "death place", _("death place")),
"deathplace_id": ("Deathplaceid", "Death place id", _("Death place id"),
"deathplaceid", "death_place_id", "death place id", _("death place id"),
"death_place_id", "deathplace_id"),
"deathdate": ("Deathdate", "Death date", _("Death date"),
"deathdate", "death_date", "death date", _("death date")),
"deathsource": ("Deathsource", "Death source", _("Death source"),
@ -208,6 +221,7 @@ class CSVParser(object):
"marriage": ("Marriage", _("Marriage"), "marriage", _("marriage")),
"date": ("Date", _("Date"), "date", _("date")),
"place": ("Place", _("Place"), "place", _("place")),
"place_id": ("Placeid", "place id", "Place id", "place_id", "placeid"),
"name": ("Name", _("Name"), "name", _("name")),
"type": ("Type", _("Type"), "type", _("type")),
"latitude": ("Latitude", _("latitude"), "latitude", _("latitude")),
@ -386,10 +400,12 @@ class CSVParser(object):
def _parse_marriage(self, line_number, row, col):
"Parse the content of a Marriage,Husband,Wife line."
marriage_ref = rd(line_number, row, col, "marriage")
import pdb; pdb.set_trace()
husband = rd(line_number, row, col, "husband")
wife = rd(line_number, row, col, "wife")
marriagedate = rd(line_number, row, col, "date")
marriageplace = rd(line_number, row, col, "place")
marriageplace_id = rd(line_number, row, col, "place_id")
marriagesource = rd(line_number, row, col, "source")
note = rd(line_number, row, col, "note")
wife = self.lookup("person", wife)
@ -415,9 +431,14 @@ class CSVParser(object):
if marriagesource:
# add, if new
new, marriagesource = self.get_or_create_source(marriagesource)
if marriageplace and marriageplace_id:
raise Error("Error in marriage: can't have a place and place_id")
if marriageplace:
# add, if new
new, marriageplace = self.get_or_create_place(marriageplace)
elif marriageplace_id:
# better exist already, locally or in database:
marriageplace = self.lookup("place", marriageplace_id)
if marriagedate:
marriagedate = _dp.parse(marriagedate)
if marriagedate or marriageplace or marriagesource or note:
@ -546,15 +567,19 @@ class CSVParser(object):
source = rd(line_number, row, col, "source")
note = rd(line_number, row, col, "note")
birthplace = rd(line_number, row, col, "birthplace")
birthplace_id = rd(line_number, row, col, "birthplace_id")
birthdate = rd(line_number, row, col, "birthdate")
birthsource = rd(line_number, row, col, "birthsource")
baptismplace = rd(line_number, row, col, "baptismplace")
baptismplace_id = rd(line_number, row, col, "baptismplace_id")
baptismdate = rd(line_number, row, col, "baptismdate")
baptismsource = rd(line_number, row, col, "baptismsource")
burialplace = rd(line_number, row, col, "burialplace")
burialplace_id = rd(line_number, row, col, "burialplace_id")
burialdate = rd(line_number, row, col, "burialdate")
burialsource = rd(line_number, row, col, "burialsource")
deathplace = rd(line_number, row, col, "deathplace")
deathplace_id = rd(line_number, row, col, "deathplace_id")
deathdate = rd(line_number, row, col, "deathdate")
deathsource = rd(line_number, row, col, "deathsource")
deathcause = rd(line_number, row, col, "deathcause")
@ -640,8 +665,13 @@ class CSVParser(object):
# Birth:
if birthdate is not None:
birthdate = _dp.parse(birthdate)
if birthplace and birthplace_id:
raise Error("Error in person: can't have a birthplace and birthplace_id")
if birthplace is not None:
new, birthplace = self.get_or_create_place(birthplace)
elif birthplace_id:
# better exist already, locally or in database:
birthplace = self.lookup("place", birthplace_id)
if birthsource is not None:
new, birthsource = self.get_or_create_source(birthsource)
if birthdate or birthplace or birthsource:
@ -657,8 +687,13 @@ class CSVParser(object):
# Baptism:
if baptismdate is not None:
baptismdate = _dp.parse(baptismdate)
if baptismplace and baptismplace_id:
raise Error("Error in person: can't have a baptismplace and baptismplace_id")
if baptismplace is not None:
new, baptismplace = self.get_or_create_place(baptismplace)
elif baptismplace_id:
# better exist already, locally or in database:
baptismplace = self.lookup("place", baptismplace_id)
if baptismsource is not None:
new, baptismsource = self.get_or_create_source(baptismsource)
if baptismdate or baptismplace or baptismsource:
@ -675,8 +710,13 @@ class CSVParser(object):
# Death:
if deathdate is not None:
deathdate = _dp.parse(deathdate)
if deathplace and deathplace_id:
raise Error("Error in person: can't have a deathplace and deathplace_id")
if deathplace is not None:
new, deathplace = self.get_or_create_place(deathplace)
elif deathplace_id:
# better exist already, locally or in database:
deathplace = self.lookup("place", deathplace_id)
if deathsource is not None:
new, deathsource = self.get_or_create_source(deathsource)
if deathdate or deathplace or deathsource or deathcause:
@ -695,8 +735,13 @@ class CSVParser(object):
# Burial:
if burialdate is not None:
burialdate = _dp.parse(burialdate)
if burialplace and burialplace_id:
raise Error("Error in person: can't have a burialplace and burialplace_id")
if burialplace is not None:
new, burialplace = self.get_or_create_place(burialplace)
elif burialplace_id:
# better exist already, locally or in database:
burialplace = self.lookup("place", burialplace_id)
if burialsource is not None:
new, burialsource = self.get_or_create_source(burialsource)
if burialdate or burialplace or burialsource: