From 06d5d3417077f5860e35625f5245b75e3a8c40d8 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 5 Dec 2022 17:24:58 +0100 Subject: Imports: manage defaults with "__" --- ishtar_common/data_importer.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'ishtar_common/data_importer.py') diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index 5b3509b3e..8d99889fc 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -1389,17 +1389,21 @@ class Importer(object): default_srs = profile.srs if profile.srs else None if "geodata" in data: - geodata = self._defaults.get(("geodata",), {}) + geodata = copy.deepcopy(self._defaults.get(("geodata",), {})) geodata.update(data.pop("geodata")) if default_srs and not [ - 1 for k in geodata if k.startswith("spatial_reference_system")]: + 1 for k in geodata if k.startswith("spatial_reference_system") and + geodata[k] + ]: geodata["spatial_reference_system"] = default_srs if "main_geodata" in data: - main_geodata = self._defaults.get(("main_geodata",), {}) + main_geodata = copy.deepcopy(self._defaults.get(("main_geodata",), {})) main_geodata.update(data.pop("main_geodata")) if default_srs and not [ - 1 for k in main_geodata if k.startswith("spatial_reference_system")]: + 1 for k in main_geodata if k.startswith("spatial_reference_system") + and main_geodata[k] + ]: main_geodata["spatial_reference_system"] = default_srs obj, created = self.get_object(self.OBJECT_CLS, data, idx_line=idx_line) if self.simulate: @@ -1516,6 +1520,8 @@ class Importer(object): new_data = data.copy() if "defaults" in data: default = new_data.pop("defaults") + else: + default = {} q = through_cls.objects.filter(**new_data) if q.count(): t_obj = through_cls.objects.get(**new_data) -- cgit v1.2.3