From 8269a7ea9e411d37dbbb22eb0a63b788a6501a8b Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 15 Dec 2025 15:52:14 +0100 Subject: ✨ GIS API: add geo data type to QGIS importer types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/models_imports.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'ishtar_common/models_imports.py') diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 528201927..2553cde3f 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -223,13 +223,22 @@ class ImporterType(models.Model): null=True, help_text=_("For GIS file with multiple layers"), ) + gis_type = models.ForeignKey( + "ishtar_common.GeoDataType", blank=True, null=True, on_delete=models.CASCADE, + help_text=_( + "For QGIS importer type. Geographic data type used for import and export." + ) + ) pre_import_message = models.TextField( _("Pre-import form message"), blank=True, default="", max_length=500 ) ignore_errors = models.TextField( verbose_name=_("Error messages to ignore"), blank=True, null=True, - help_text=_("If an error is encountered with the following character strings, the error is not reported in " - "the error file. Each message is separated with a line break.") + help_text=_( + "If an error is encountered with the following character strings, the " + "error is not reported in the error file. Each message is separated with " + "a line break." + ) ) debug = models.BooleanField(verbose_name=_("Debug"), default=False) @@ -257,10 +266,17 @@ class ImporterType(models.Model): return f"{self.name} ({IMPORT_TYPES_DICT.get(self.type, '-').lower()})" def clean(self): - if self.type == "qgs" and not self.is_template: + if self.type != "qgs": + return + if not self.is_template: + raise ValidationError( + _("QGIS importers should at least can be exported. Check the \"Can be " + "exported\" case.") + ) + if not self.gis_type: raise ValidationError( - "QGIS importers should at least can be exported. Check the \"Can be " - "exported\" case.") + _("GIS type is mandatory for QGIS importers.") + ) def is_own(self, ishtar_user): return bool( @@ -507,7 +523,7 @@ class ImporterType(models.Model): def save(self, *args, **kwargs): if not self.slug: self.slug = create_slug(ImporterType, self.name) - return super(ImporterType, self).save(*args, **kwargs) + return super().save(*args, **kwargs) class ImporterGroup(models.Model): -- cgit v1.2.3