summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-04-11 12:41:37 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-04-11 12:51:19 +0200
commit5a298f37a4f87396d5fdd275c23b6589db84c06e (patch)
treeb3d504376bb1faabd45b648f27cd43291ec29206 /ishtar_common/utils.py
parentc112274abba0f8d3bdbf7e00305fdcac12c5f066 (diff)
downloadIshtar-5a298f37a4f87396d5fdd275c23b6589db84c06e.tar.bz2
Ishtar-5a298f37a4f87396d5fdd275c23b6589db84c06e.zip
🐛 custom form: fix custom fields (classic ou JSON) management
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r--ishtar_common/utils.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index cf58216a4..23495c2ec 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -799,6 +799,20 @@ def update_data(data, new_data, merge=False):
res[k] = new_data[k]
return res
+def generate_dict_from_data_string(key: str, value: str) -> dict:
+ """
+ "data__key1__key2", value -> {"key1": {"key2": value}}
+ """
+ full_dct = dct = {}
+
+ keys = key[len("data__"):].split("__")
+ for k in keys[:-1]: # do not get the last key
+ dct[k] = {}
+ dct = dct[k]
+ dct[keys[-1]] = value
+
+ return full_dct
+
def generate_dict_from_list(lst: list, value) -> dict:
"""