diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/models_common.py | 17 | ||||
| -rw-r--r-- | ishtar_common/tests.py | 13 | 
2 files changed, 26 insertions, 4 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 0c763965b..a7dc8464e 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2930,6 +2930,23 @@ def town_child_changed(sender, **kwargs):  m2m_changed.connect(town_child_changed, sender=Town.children.through) +def geotown_attached_changed(sender, **kwargs): +    # manage associated geoitem +    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) +    action = kwargs.get("action", None) +    if not instance or not model or not hasattr(instance, "post_save_geo"): +        return + +    instance._post_save_geo_ok = False +    if action in ("post_add", "post_remove", "post_clear"): +        instance.post_save_geo(save=True) + +  class Address(BaseHistorizedItem):      FIELDS = (          "address", diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index cfd3544dd..7671f2fe4 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -3518,9 +3518,6 @@ class GeoVectorTest(TestCase):          self.assertEqual(town.main_geodata, geo_vector_town)          self.operation.towns.add(town) -        self._reinit_objects() -        # save need to be forced... keep it? -        self.operation.save()          self._reinit_objects()          self.assertEqual(self.operation.geodata.count(), 1) @@ -3530,7 +3527,15 @@ class GeoVectorTest(TestCase):          self.assertEqual(self.base_find.geodata.count(), 1)          self.assertEqual(self.base_find.main_geodata, geo_vector_town) -        # test town remove +        self.operation.towns.remove(town) + +        self._reinit_objects() +        self.assertIsNone(self.operation.main_geodata) +        self.assertEqual(self.operation.geodata.count(), 0) +        self.assertIsNone(self.context_record.main_geodata) +        self.assertEqual(self.context_record.geodata.count(), 0) +        self.assertIsNone(self.base_find.main_geodata) +        self.assertEqual(self.base_find.geodata.count(), 0)  class NewItems(TestCase):  | 
