From 97efd6f8bb4ea3bb1655d27f0eff160b34ac530f Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 9 Jun 2022 17:23:11 +0200 Subject: JSON fields: fix multi-value choices fields --- CHANGES-DEV.md | 3 ++- ishtar_common/models_common.py | 2 +- ishtar_common/widgets.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES-DEV.md b/CHANGES-DEV.md index e7d2a1cd5..7636d4112 100644 --- a/CHANGES-DEV.md +++ b/CHANGES-DEV.md @@ -1,6 +1,6 @@ --- title: Ishtar changelog -date: 2022-05-17 +date: 2022-06-09 --- Ishtar develop changelog v3.2 @@ -45,4 +45,5 @@ Ishtar develop changelog v3.2 - Many to one treatment: fix attribute conservation - Sheet: silently fails when missing graph relations image is missing - Import delete: do not crash when no SLUG is available for an attached item +- JSON fields: fix multi-value choices fields diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index ecbabcf7a..aae79c4fe 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -1097,7 +1097,7 @@ class JsonData(models.Model, CachedGen): c = [("", "")] c += [(v, v) for v in sorted(list(choices))] cache.set(cache_key, c, settings.CACHE_SMALLTIMEOUT) - return choices + return c class FixAssociated: diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 1f5a169ba..4852f4ceb 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -140,7 +140,7 @@ class Select2DynamicBase(Select2Media): value = value[0] values = value for va in values: - if va not in [key for key, va in choices]: + if va not in [key for key, v in choices]: choices.insert(1, (va, va)) self.choices = choices klass = attrs and attrs.get("class") or "" -- cgit v1.2.3