diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-11-14 18:48:17 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-11-14 18:48:17 +0100 |
commit | 18469769e8fd2bf008c88faae4fc7592d265c446 (patch) | |
tree | 2ef203dc263b62e3cf02afb7d4797041e1102441 | |
parent | c565d396c657abb2a9baa0b72dcbea67e3ddf69b (diff) | |
download | Ishtar-18469769e8fd2bf008c88faae4fc7592d265c446.tar.bz2 Ishtar-18469769e8fd2bf008c88faae4fc7592d265c446.zip |
Fix missing cached label
-rw-r--r-- | ishtar_common/management/commands/fix_missing_cached_labels.py | 7 | ||||
-rw-r--r-- | ishtar_common/utils.py | 5 |
2 files changed, 8 insertions, 4 deletions
diff --git a/ishtar_common/management/commands/fix_missing_cached_labels.py b/ishtar_common/management/commands/fix_missing_cached_labels.py index 5b71bb899..368d98fae 100644 --- a/ishtar_common/management/commands/fix_missing_cached_labels.py +++ b/ishtar_common/management/commands/fix_missing_cached_labels.py @@ -63,10 +63,10 @@ class Command(BaseCommand): if k.startswith('_generate_') or k == "search_vector"]): continue - q = model.objects if hasattr(model, "CACHED_LABELS") and model.CACHED_LABELS: cached_keys = model.CACHED_LABELS - elif hasattr(model, "cached_label"): + elif hasattr(model, "cached_label") \ + and "Basket" not in model.__name__: cached_keys = ["cached_label"] else: continue @@ -78,13 +78,14 @@ class Command(BaseCommand): query = subquery else: query |= subquery - q = q.filter(query) + q = model.objects.filter(query) msg = u"-> processing {}: ".format(model._meta.verbose_name) ln = q.count() for idx, obj_id in enumerate(q.values('pk').all()): obj = model.objects.get(pk=obj_id['pk']) obj.skip_history_when_saving = True obj._no_move = True + obj._no_geo_check = True cmsg = u"\r{} {}/{}".format(msg, idx + 1, ln) if not quiet: sys.stdout.write(cmsg) diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index df92208e9..d446a381a 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -678,9 +678,12 @@ def post_save_geo(sender, **kwargs): # return # cache.set(cache_key, True, settings.CACHE_TASK_TIMEOUT) + instance = kwargs.get('instance') + if hasattr(instance, "_no_geo_check") and instance._no_geo_check: + return if not settings.USE_BACKGROUND_TASK: return _post_save_geo(sender, **kwargs) - sender, kwargs = serialize_args_for_tasks(sender, kwargs.get('instance'), + sender, kwargs = serialize_args_for_tasks(sender, instance, kwargs, EXTRA_KWARGS_TRIGGER) return _post_save_geo.delay(sender, **kwargs) |