diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-02-10 16:25:35 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-02-19 14:45:57 +0100 |
commit | d306ba05c44f9010551ecf74efe4d4334b7e44b1 (patch) | |
tree | 89b22c92e2ef0385f7c1ada67fc84c151bbd3f04 /ishtar_common/models_common.py | |
parent | 3e3efb3d6736e417f0b6cf650153840761ee9baf (diff) | |
download | Ishtar-d306ba05c44f9010551ecf74efe4d4334b7e44b1.tar.bz2 Ishtar-d306ba05c44f9010551ecf74efe4d4334b7e44b1.zip |
🗃️ add acquisition date to geo items - remove mandatory link to geovectordata
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r-- | ishtar_common/models_common.py | 13 |
1 files changed, 11 insertions, 2 deletions
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"): |