summaryrefslogtreecommitdiff
path: root/ishtar_common/models_common.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r--ishtar_common/models_common.py13
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"):