From 55f311f240402612feb72766925131e585040833 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 23 Feb 2022 10:57:48 +0100 Subject: Geodata redesign: fix operation migration --- ishtar_common/utils.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'ishtar_common/utils.py') 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 -- cgit v1.2.3