From 4466c5c765dccd23b545c3d1c31449d52a2208cb Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 11 Feb 2025 11:07:51 +0100 Subject: ✨ import GIS: do not create GIS item if the main item is already GIS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/data_importer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index 04782a56e..e222fa0f3 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -1338,7 +1338,9 @@ class Importer(object): obj.save() self._add_to_post_save(obj.__class__, obj.pk, idx_line) - if self.TYPE == "gis": + GeoVectorData = apps.get_model("ishtar_common", "GeoVectorData") + if self.TYPE == "gis" and not isinstance(obj, GeoVectorData): + # create GIS data and attach to the created object if the object is not GIS if not obj and not self.c_errors: self.c_errors = True self.errors.append( @@ -1349,7 +1351,6 @@ class Importer(object): ) ) return - content_type = ContentType.objects.get( app_label=obj.__class__._meta.app_label, model=obj.__class__.__name__.lower() @@ -1358,7 +1359,6 @@ class Importer(object): "source_id": obj.pk, "source_content_type": content_type, }) - GeoVectorData = apps.get_model("ishtar_common", "GeoVectorData") item = None created = False if "import_key" in geodata: -- cgit v1.2.3