summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-12-15 15:52:14 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-12-15 15:52:14 +0100
commit8269a7ea9e411d37dbbb22eb0a63b788a6501a8b (patch)
treef8982a0177494b574e7ba24c3957e1105c7f5477
parentbc8e0188e65f40dbb37311c9291476c7689db51a (diff)
downloadIshtar-8269a7ea9e411d37dbbb22eb0a63b788a6501a8b.tar.bz2
Ishtar-8269a7ea9e411d37dbbb22eb0a63b788a6501a8b.zip
✨ GIS API: add geo data type to QGIS importer types
-rw-r--r--ishtar_common/migrations/0273_importertype_gis_type.py19
-rw-r--r--ishtar_common/models_imports.py28
2 files changed, 41 insertions, 6 deletions
diff --git a/ishtar_common/migrations/0273_importertype_gis_type.py b/ishtar_common/migrations/0273_importertype_gis_type.py
new file mode 100644
index 000000000..3438b76b9
--- /dev/null
+++ b/ishtar_common/migrations/0273_importertype_gis_type.py
@@ -0,0 +1,19 @@
+# Generated by Django 4.2.19 on 2025-12-15 10:25
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ishtar_common', '0272_ishtarsiteprofile_dating_external_id'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='importertype',
+ name='gis_type',
+ field=models.ForeignKey(blank=True, help_text='For QGIS importer type. Geographic data type used for import and export.', null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.geodatatype'),
+ ),
+ ]
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):