diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-02-23 10:57:48 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:21:00 +0100 |
commit | 55f311f240402612feb72766925131e585040833 (patch) | |
tree | bd23b4e1c01800deabf75dfd1a82b532ea150da1 /ishtar_common/utils.py | |
parent | ef1d582c2e55bd12a5d2169ecb445b280f0afe9c (diff) | |
download | Ishtar-55f311f240402612feb72766925131e585040833.tar.bz2 Ishtar-55f311f240402612feb72766925131e585040833.zip |
Geodata redesign: fix operation migration
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 53727b6d3..fc302166b 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -846,6 +846,30 @@ def _post_save_geo(sender, **kwargs): if not instance: return + if getattr(instance, "_post_saved_geo", False): + return + + instance._post_saved_geo = True + + modified = False + if getattr(instance, "post_save_geo", False): + instance.post_save_geo(save=False) + modified = True + + if hasattr(instance, "need_update") and instance.need_update: + instance.need_update = False + modified = True + + if modified: + instance.skip_history_when_saving = True + instance._post_saved_geo = True + instance._cached_label_checked = False + instance.save() + if hasattr(instance, "cascade_update"): + instance.cascade_update() + cache_key, __ = get_cache(sender, ["post_save_geo", instance.pk]) + cache.set(cache_key, None, settings.CACHE_TASK_TIMEOUT) + return # TODO to delete |