summaryrefslogtreecommitdiff
path: root/ishtar_common/models_common.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-11-02 18:19:03 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-07-08 09:58:49 +0200
commit1878345992d0272c146cbeec2e62f3ed24907f1e (patch)
tree37336a463b9a68d957fa30ce721ca9452826b7b7 /ishtar_common/models_common.py
parent98ed6a871b21d8f80af5d386a1b59288bd862830 (diff)
downloadIshtar-1878345992d0272c146cbeec2e62f3ed24907f1e.tar.bz2
Ishtar-1878345992d0272c146cbeec2e62f3ed24907f1e.zip
JSON types: multi valued choices
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r--ishtar_common/models_common.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py
index e67b78d67..b1c291bee 100644
--- a/ishtar_common/models_common.py
+++ b/ishtar_common/models_common.py
@@ -1077,12 +1077,22 @@ class JsonData(models.Model, CachedGen):
q = cls.objects.filter(data__has_key=key[len("data__") :]).values_list(
"data", flat=True
)
+ multi = False
for value in q.all():
for k in splitted_key:
value = value[k]
- choices.add(value)
- choices = [("", "")] + [(v, v) for v in sorted(list(choices))]
- cache.set(cache_key, choices, settings.CACHE_SMALLTIMEOUT)
+ if isinstance(value, list):
+ multi = True
+ for v in value:
+ if v:
+ choices.add(v)
+ else:
+ choices.add(value)
+ c = []
+ if not multi:
+ c = [("", "")]
+ c += [(v, v) for v in sorted(list(choices))]
+ cache.set(cache_key, c, settings.CACHE_SMALLTIMEOUT)
return choices