summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-12-23 17:01:35 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-12-23 17:02:21 +0100
commit362df5dd42f41237ed1545571704a56db59e4d46 (patch)
tree4cf16ab6ede4175e6b0c2fdf34bf3217bd28972e /ishtar_common/utils.py
parent31cb2ff171160ab12e52813a5ffec2a0439711dd (diff)
downloadIshtar-362df5dd42f41237ed1545571704a56db59e4d46.tar.bz2
Ishtar-362df5dd42f41237ed1545571704a56db59e4d46.zip
Add index to containers (refs #3391) - manage multiple cached labels
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r--ishtar_common/utils.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index 44112bca3..9b3c85694 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -60,11 +60,18 @@ def cached_label_changed(sender, **kwargs):
and instance._cached_label_checked:
return
instance._cached_label_checked = True
- lbl = instance._generate_cached_label()
- if lbl != instance.cached_label:
+ cached_labels = ['cached_label']
+ if hasattr(sender, 'CACHED_LABELS'):
+ cached_labels = sender.CACHED_LABELS
+ changed = False
+ for cached_label in cached_labels:
+ lbl = getattr(instance, '_generate_' + cached_label)()
+ if lbl != getattr(instance, cached_label):
+ setattr(instance, cached_label, lbl)
+ changed = True
+ if changed:
if hasattr(instance, '_cascade_change') and instance._cascade_change:
instance.skip_history_when_saving = True
- instance.cached_label = lbl
instance.save()
if hasattr(instance, '_get_associated_cached_labels'):
for item in instance._get_associated_cached_labels():