diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/forms_common.py | 1 | ||||
| -rw-r--r-- | ishtar_common/migrations/0261_geo_reference_acquisition_date.py | 82 | ||||
| -rw-r--r-- | ishtar_common/models_common.py | 13 | ||||
| -rw-r--r-- | ishtar_common/models_imports.py | 2 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_geographic.html | 2 | 
5 files changed, 97 insertions, 3 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 96848a6ae..5b81eb005 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -3095,6 +3095,7 @@ class GISForm(forms.ModelForm, CustomForm, ManageOldType):      provider = widgets.ModelChoiceField(          model=models.GeoProviderType, label=_("Provider"), choices=[], required=False      ) +    acquisition_date = DateField(label=_("Acquisition date"), required=False)      buffer = forms.FloatField(          label=_("Buffer"),          required=False, diff --git a/ishtar_common/migrations/0261_geo_reference_acquisition_date.py b/ishtar_common/migrations/0261_geo_reference_acquisition_date.py new file mode 100644 index 000000000..8ce67d896 --- /dev/null +++ b/ishtar_common/migrations/0261_geo_reference_acquisition_date.py @@ -0,0 +1,82 @@ +# Generated by Django 2.2.24 on 2025-02-10 16:58 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + +    dependencies = [ +        ('ishtar_common', '0260_itemkey_importer_type'), +    ] + +    operations = [ +        migrations.AlterModelOptions( +            name='itemkey', +            options={'verbose_name': 'Importer - Item key', 'verbose_name_plural': 'Importer - Item keys'}, +        ), +        migrations.AddField( +            model_name='geovectordata', +            name='acquisition_date', +            field=models.DateField(blank=True, null=True), +        ), +        migrations.AlterField( +            model_name='geovectordata', +            name='source_content_type', +            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='content_type_geovectordata', to='contenttypes.ContentType'), +        ), +        migrations.AlterField( +            model_name='geovectordata', +            name='source_id', +            field=models.PositiveIntegerField(blank=True, null=True), +        ), +        migrations.AlterField( +            model_name='itemkey', +            name='group', +            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='ishtar_common.TargetKeyGroup', verbose_name='Group'), +        ), +        migrations.AlterField( +            model_name='itemkey', +            name='importer_type', +            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.ImporterType', verbose_name='Importer type'), +        ), +        migrations.AlterField( +            model_name='itemkey', +            name='ishtar_import', +            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.Import', verbose_name='Import'), +        ), +        migrations.AlterField( +            model_name='itemkey', +            name='object_id', +            field=models.PositiveIntegerField(verbose_name='Value ID'), +        ), +        migrations.AlterField( +            model_name='itemkey', +            name='user', +            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='ishtar_common.IshtarUser', verbose_name='User'), +        ), +        migrations.AlterField( +            model_name='targetkey', +            name='associated_group', +            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.TargetKeyGroup'), +        ), +        migrations.AlterField( +            model_name='targetkey', +            name='associated_import', +            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.Import'), +        ), +        migrations.AlterField( +            model_name='targetkey', +            name='associated_user', +            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='ishtar_common.IshtarUser'), +        ), +        migrations.AlterField( +            model_name='targetkey', +            name='key', +            field=models.TextField(blank=True, default='', verbose_name='Key'), +        ), +        migrations.AlterUniqueTogether( +            name='importerdefault', +            unique_together={('importer_type', 'target', 'required_fields')}, +        ), +    ] diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 8fb49c5cc..432a50839 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2355,9 +2355,10 @@ class GeoVectorData(Imported, OwnPerms):      need_update = models.BooleanField(_("Need update"), default=False)      name = models.TextField(_("Name"), default="-")      source_content_type = models.ForeignKey( -        ContentType, related_name="content_type_geovectordata", on_delete=models.CASCADE +        ContentType, related_name="content_type_geovectordata", on_delete=models.CASCADE, +        blank=True, null=True      ) -    source_id = models.PositiveIntegerField() +    source_id = models.PositiveIntegerField(blank=True, null=True)      source = GenericForeignKey("source_content_type", "source_id")      import_key = models.TextField(_("Import key"), blank=True, null=True,                                    help_text=_("Use this for update imports")) @@ -2385,6 +2386,7 @@ class GeoVectorData(Imported, OwnPerms):          verbose_name=_("Provider"),          help_text=_("Data provider"),      ) +    acquisition_date = models.DateField(blank=True, null=True)      comment = models.TextField(_("Comment"), default="", blank=True)      x = models.FloatField(_("X"), blank=True, null=True, help_text=_("User input"))      y = models.FloatField(_("Y"), blank=True, null=True, help_text=_("User input")) @@ -2911,6 +2913,13 @@ def geodata_attached_post_add(model, instance, pk_set):      item_pks = list(model.objects.filter(pk__in=pk_set).values_list("pk", flat=True))      if not item_pks:          return +    q = model.objects.filter(pk__in=pk_set).filter(source_id__isnull=True) +    if q.count(): +        content_type = ContentType.objects.get( +            app_label=instance.__class__._meta.app_label, +            model=instance.__class__.__name__.lower() +        ) +        q.update(source_id=instance.pk, source_content_type=content_type)      # use a cache to manage during geodata attach      if not hasattr(instance, "_geodata"): diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 66ff15e6d..b1af1912f 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -557,7 +557,7 @@ class ImporterDefault(models.Model):      class Meta:          verbose_name = _("Importer - Default")          verbose_name_plural = _("Importer - Defaults") -        unique_together = ("importer_type", "target") +        unique_together = ("importer_type", "target", "required_fields")      ADMIN_SECTION = _("Imports")      objects = ImporterDefaultManager() diff --git a/ishtar_common/templates/ishtar/blocks/sheet_geographic.html b/ishtar_common/templates/ishtar/blocks/sheet_geographic.html index d5f8a4d84..12846ef78 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_geographic.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_geographic.html @@ -10,6 +10,7 @@          <th>{% trans "Name" %}</th>          <th>{% trans "Origin" %}</th>          <th>{% trans "Provider" %}</th> +        <th>{% trans "Acquisition date" %}</th>          <th>{% trans "Comment" %}</th>          {% if not IS_HISTORY and permission_change_geo %}<th> </th>{% endif %}      </tr> @@ -27,6 +28,7 @@          <td>{{ geo.name }}</td>          <td>{% if geo.origin %}{{ geo.origin }}{% else %}-{% endif %}</td>          <td>{% if geo.provider %}{{ geo.provider }}{% else %}-{% endif %}</td> +        <td>{% if geo.acquisition_date %}{{ geo.acquisition_date|date:"DATE_FORMAT"|default:"-" }}{% else %}-{% endif %}</td>          <td>{% if geo.comment %}{{ geo.comment }}{% else %}-{% endif %}</td>          {% if not IS_HISTORY and permission_change_geo and output != "ODT" and output != "PDF" %}<td>          {% autoescape off %}  | 
