summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-06 17:02:09 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-06 17:02:09 +0100
commitfa105b35025742223d4238c8314287ad9e9f78a5 (patch)
treea23858d5894be17cb2d0caa08060c66e48994837 /ishtar_common/utils.py
parentda42af85b96513e69db706555fa6ac02b38bcaa7 (diff)
parent4c5e12584c253b3d84abcf946cb6ce1bae8fcbcb (diff)
downloadIshtar-fa105b35025742223d4238c8314287ad9e9f78a5.tar.bz2
Ishtar-fa105b35025742223d4238c8314287ad9e9f78a5.zip
Merge branch 'v0.9' into wheezy
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r--ishtar_common/utils.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index 83534d93a..f1e2e4b96 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -55,10 +55,21 @@ def get_cache(cls, extra_args=[]):
return cache_key, cache.get(cache_key)
+def force_cached_label_changed(sender, **kwargs):
+ if not kwargs.get('instance'):
+ return
+ kwargs['instance']._cached_label_checked = False
+ cached_label_changed(sender, **kwargs)
+
+
def cached_label_changed(sender, **kwargs):
if not kwargs.get('instance'):
return
instance = kwargs.get('instance')
+
+ if hasattr(instance, 'test_obj'):
+ instance.test_obj.reached(sender, **kwargs)
+
if hasattr(instance, '_cached_label_checked') \
and instance._cached_label_checked:
return
@@ -76,15 +87,22 @@ def cached_label_changed(sender, **kwargs):
if hasattr(instance, '_cascade_change') and instance._cascade_change:
instance.skip_history_when_saving = True
instance.save()
- if hasattr(instance, '_get_associated_cached_labels'):
+ updated = False
+ if hasattr(instance, '_cached_labels_bulk_update'):
+ updated = instance._cached_labels_bulk_update()
+ if not updated and hasattr(instance, '_get_associated_cached_labels'):
for item in instance._get_associated_cached_labels():
item._cascade_change = True
+ if hasattr(instance, 'test_obj'):
+ item.test_obj = instance.test_obj
cached_label_changed(item.__class__, instance=item)
SHORTIFY_STR = ugettext(" (...)")
def shortify(lbl, number=20):
+ if not lbl:
+ lbl = ''
if len(lbl) <= number:
return lbl
return lbl[:number - len(SHORTIFY_STR)] + SHORTIFY_STR