diff options
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 |
commit | 314e8ac660877752acf0a353e2833e4b0c500ccb (patch) | |
tree | 7ccc9e40dfa66e0e0e2da40a75f9af0ef4df0c2f /ishtar_common/models_common.py | |
parent | 42e058c40b07672d20d680bb9c79c06d8c88a8bc (diff) | |
download | Ishtar-314e8ac660877752acf0a353e2833e4b0c500ccb.tar.bz2 Ishtar-314e8ac660877752acf0a353e2833e4b0c500ccb.zip |
Geodata: manage m2m signal town association
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r-- | ishtar_common/models_common.py | 17 |
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", |