diff options
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r-- | ishtar_common/models_common.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index adf1c1516..0c763965b 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2626,15 +2626,10 @@ def geodata_attached_remove(model, instance, pk_set=None, clear=False): return # use a cache to manage during geodata attach - if not hasattr(instance, "_geodata"): - instance._geodata = [] if instance.main_geodata_id in item_pks: instance.main_geodata_id = None instance.skip_history_when_saving = True instance._no_move = True - if not hasattr(instance, "_geodata"): - instance._geodata = [] - instance._geodata += [pk for pk in item_pks if pk not in instance._geodata] instance.save() # for all sub item verify that the geo items are present @@ -2658,6 +2653,9 @@ def geodata_attached_remove(model, instance, pk_set=None, clear=False): def geodata_attached_changed(sender, **kwargs): # manage main geoitem and cascade association + profile = get_current_profile() + if not profile.mapping: + return instance = kwargs.get("instance", None) model = kwargs.get("model", None) pk_set = kwargs.get("pk_set", None) @@ -2711,15 +2709,14 @@ class GeographicItem(models.Model): using=using, update_fields=update_fields, ) - if not hasattr(self, "_geodata"): # use a cache to manage during geodata attach - self._geodata = [] if self.main_geodata and not self.geodata.filter(pk=self.main_geodata.pk) and\ self.main_geodata.pk not in self._geodata: self.geodata.add(self.main_geodata) - self._geodata.append(self.main_geodata.pk) elif not self.main_geodata and self.geodata.count(): # arbitrary associate the first to geodata self.main_geodata = self.geodata.order_by("pk").all()[0] + self.skip_history_when_saving = True + self._no_move = True self.save() @property |