diff options
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/data_importer.py | 5 | ||||
-rw-r--r-- | ishtar_common/models_common.py | 1 | ||||
-rw-r--r-- | ishtar_common/utils.py | 19 |
3 files changed, 16 insertions, 9 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index 796a75699..673bcdde7 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -1048,8 +1048,9 @@ class Importer(object): for func, context, value in self._item_post_processing: context["import_object"] = self.import_instance try: - returned = getattr(item, func)(context, value) - if returned: + f = getattr(item, func) + returned = f(context, value) + if returned and not getattr(f, "_no_repost_save", False): if not isinstance(returned, Iterable): returned = [returned] for rel in returned: diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 15ce429d4..a8e377209 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -3386,6 +3386,7 @@ class MainItem(ShortMenuItem, SerializeItem): self.no_post_process() self._post_saved_geo = False post_save_geo(self.__class__, instance=self, created=False) + return False def external_id_changed(self): self.no_post_process() diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 1757612ef..c6c14422c 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -23,6 +23,7 @@ import datetime from functools import wraps from itertools import chain from inspect import currentframe, getframeinfo +import logging import hashlib from importlib import import_module import io @@ -85,6 +86,7 @@ else: ) _ = ugettext_lazy +logger = logging.getLogger(__name__) def dict_to_tuple(dct): @@ -559,6 +561,7 @@ def _cached_label_changed(sender, **kwargs): if not force_update and getattr(instance, "_cached_label_checked", False): return + logger.debug(f"[ishtar] ishtar_common.utils._cached_label_changed - {instance.__class__.__name__} - {instance.pk} - {instance}") if hasattr(instance, "refresh_cache"): instance.refresh_cache() @@ -587,8 +590,8 @@ def _cached_label_changed(sender, **kwargs): if hasattr(instance, "_cascade_change") and instance._cascade_change: instance.skip_history_when_saving = True instance.__class__.objects.filter(pk=instance.pk).update(**dict(changed)) - if (getattr(instance, "FORCE_CASCADE_UPDATE", False) or changed - or not cached_labels) and hasattr(instance, "cascade_update"): + if ((getattr(instance, "check_cascade_update", False) and instance.check_cascade_update()) + or changed or not cached_labels) and hasattr(instance, "cascade_update"): instance.cascade_update() updated = False if force_update or hasattr(instance, "update_search_vector"): @@ -603,6 +606,7 @@ def _cached_label_changed(sender, **kwargs): if hasattr(instance, "test_obj"): item.test_obj = instance.test_obj cached_label_changed(item.__class__, instance=item) + cache_key, __ = get_cache(sender, ["cached_label_changed", instance.pk]) cache.set(cache_key, None, settings.CACHE_TASK_TIMEOUT) if cached_labels: @@ -800,9 +804,10 @@ def _post_save_geodata(sender, **kwargs): modified = False if getattr(instance, "post_save_geo", False): - instance.post_save_geo(save=False) - modified = True + # TODO: geovectordata -> no post_save_geo: delete? + modified = instance.post_save_geo(save=False) + logger.debug(f"[ishtar] ishtar_common.utils._post_save_geodata - {instance.__class__.__name__} - {instance.pk} - {instance}") # managed cached coordinates cached_x, cached_y, cached_z = None, None, None @@ -830,7 +835,7 @@ def _post_save_geodata(sender, **kwargs): instance._no_move = True instance.skip_history_when_saving = True instance.save() - cache_key, __ = get_cache(sender, ("post_save_geo", instance.pk)) + cache_key, __ = get_cache(sender, ("post_save_geodata", instance.pk)) cache.set(cache_key, None, settings.CACHE_TASK_TIMEOUT) return @@ -858,12 +863,12 @@ def _post_save_geo(sender, **kwargs): if getattr(instance, "_post_saved_geo", False): return + logger.debug(f"[ishtar] ishtar_common.utils._post_save_geo - {instance.__class__.__name__} - {instance.pk} - {instance}") instance._post_saved_geo = True modified = False if getattr(instance, "post_save_geo", False): - instance.post_save_geo(save=False) - modified = True + modified = instance.post_save_geo(save=False) if hasattr(instance, "need_update") and instance.need_update: instance.need_update = False |