Fix CSV import for multiple place enclosed by on multiple imports (#869)

Fixes #11259
This commit is contained in:
Paul Culley 2019-08-21 12:06:44 -05:00 committed by GitHub
parent ba6254ca3f
commit ee5f2fa600
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -877,13 +877,17 @@ class CSVParser:
if place_enclosed_by_id is not None: if place_enclosed_by_id is not None:
place_enclosed_by = self.lookup("place", place_enclosed_by_id) place_enclosed_by = self.lookup("place", place_enclosed_by_id)
if place_enclosed_by is None: if place_enclosed_by is None:
raise Exception("cannot enclose %s in %s as it doesn't exist" % (place.gramps_id, place_enclosed_by_id)) raise Exception("cannot enclose %s in %s as it doesn't exist" %
if not place_enclosed_by.handle in place.placeref_list: (place.gramps_id, place_enclosed_by_id))
for placeref in place.placeref_list:
if place_enclosed_by.handle == placeref.ref:
break
else:
placeref = PlaceRef() placeref = PlaceRef()
placeref.ref = place_enclosed_by.handle placeref.ref = place_enclosed_by.handle
if place_date:
placeref.date = _dp.parse(place_date)
place.placeref_list.append(placeref) place.placeref_list.append(placeref)
if place_date:
placeref.date = _dp.parse(place_date)
######################################################### #########################################################
self.db.commit_place(place, self.trans) self.db.commit_place(place, self.trans)