summaryrefslogtreecommitdiff
path: root/ishtar_common/models_common.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-10-11 10:19:58 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:23:18 +0100
commite9193d8d29e9b18e0d553302f3e94053021fc622 (patch)
tree7ccc9e40dfa66e0e0e2da40a75f9af0ef4df0c2f /ishtar_common/models_common.py
parent58f281c8d31f939f07ed0f2d34799f476750fbb6 (diff)
downloadIshtar-e9193d8d29e9b18e0d553302f3e94053021fc622.tar.bz2
Ishtar-e9193d8d29e9b18e0d553302f3e94053021fc622.zip
Geodata: manage m2m signal town association
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r--ishtar_common/models_common.py17
1 files changed, 17 insertions, 0 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",