summaryrefslogtreecommitdiff
path: root/ishtar_common/data_importer.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-05 17:24:58 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:23:20 +0100
commit06d5d3417077f5860e35625f5245b75e3a8c40d8 (patch)
tree315a7df8d3ed620a40fe4d74fe4b37fbf9437617 /ishtar_common/data_importer.py
parent24ca8234083c3fedef4747f669634a100e6872d9 (diff)
downloadIshtar-06d5d3417077f5860e35625f5245b75e3a8c40d8.tar.bz2
Ishtar-06d5d3417077f5860e35625f5245b75e3a8c40d8.zip
Imports: manage defaults with "__"
Diffstat (limited to 'ishtar_common/data_importer.py')
-rw-r--r--ishtar_common/data_importer.py14
1 files changed, 10 insertions, 4 deletions
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)