summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r--ishtar_common/utils.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index 2ce8a5f9b..7c7e6a6a5 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -555,9 +555,11 @@ def _cached_label_changed(sender, **kwargs):
instance.refresh_cache()
instance._cached_label_checked = True
- cached_labels = ["cached_label"]
+ cached_labels = []
if hasattr(instance, "CACHED_LABELS"):
cached_labels = instance.CACHED_LABELS
+ if hasattr(instance, "cached_label") and "cached_label" not in cached_labels:
+ cached_labels.append("cached_label")
changed = []
for cached_label in cached_labels:
gen_func = "_generate_" + cached_label
@@ -1929,7 +1931,7 @@ def _update_gen_id_dct(item, dct, initial_key, fkey=None, filters=None):
if not fkey:
fkey = initial_key[:]
if fkey.startswith("settings__"):
- dct[fkey] = getattr(settings, fkey[len("settings__") :]) or ""
+ dct[fkey] = getattr(settings, fkey[len("settings__"):]) or ""
return
obj = item
for k in fkey.split("__"):
@@ -1965,11 +1967,13 @@ def get_generated_id(key, item):
if not hasattr(profile, key):
return
formula = getattr(profile, key)
+ if not formula:
+ return ""
dct = {}
# jinja2 style
if "{{" in formula or "{%" in formula:
- # naive parse - only simple jija2 is managed
+ # naive parse - only simple jinja2 is managed
key_list = []
for key in PARSE_JINJA.findall(formula):
key = key.strip().split("|")[0]
@@ -1986,7 +1990,7 @@ def get_generated_id(key, item):
new_keys = []
for key in key_list:
if key.startswith("not "):
- key = key[len("not ") :].strip()
+ key = key[len("not "):].strip()
key = key.split(".")[0]
if " % " in key:
keys = key.split(" % ")[1]