diff options
Diffstat (limited to 'ishtar_common/utils.py')
| -rw-r--r-- | ishtar_common/utils.py | 19 | 
1 files changed, 12 insertions, 7 deletions
| 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 | 
