diff options
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 828a03da3..4e5259001 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -325,8 +325,6 @@ def force_cached_label_changed(sender, **kwargs): def serialize_args_for_tasks(sender, instance, kwargs, extra_kwargs=None): - if 'signal' in kwargs: - kwargs.pop('signal') if 'instance' in kwargs: kwargs['instance'] = kwargs["instance"].pk sender = (sender._meta.app_label, sender._meta.object_name) @@ -334,6 +332,13 @@ def serialize_args_for_tasks(sender, instance, kwargs, extra_kwargs=None): for kw in extra_kwargs: if getattr(instance, kw, None): kwargs[kw] = getattr(instance, kw) + for k in list(kwargs.keys()): + if k in ["model", "signal", + "_cached_labels_bulk_update"] or kwargs[k] is None: + kwargs.pop(k) + continue + if isinstance(kwargs[k], set): + kwargs[k] = list(kwargs[k]) return sender, kwargs @@ -404,8 +409,8 @@ def _cached_label_changed(sender, **kwargs): instance._cached_label_checked = True cached_labels = ['cached_label'] - if hasattr(sender, 'CACHED_LABELS'): - cached_labels = sender.CACHED_LABELS + if hasattr(instance, 'CACHED_LABELS'): + cached_labels = instance.CACHED_LABELS changed = [] for cached_label in cached_labels: lbl = getattr(instance, '_generate_' + cached_label)() @@ -415,7 +420,8 @@ def _cached_label_changed(sender, **kwargs): instance._search_updated = False if hasattr(instance, '_cascade_change') and instance._cascade_change: instance.skip_history_when_saving = True - sender.objects.filter(pk=instance.pk).update(**dict(changed)) + instance.__class__.objects.filter(pk=instance.pk).update( + **dict(changed)) updated = False if force_update or hasattr(instance, 'update_search_vector'): updated = instance.update_search_vector() |