diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-11-03 21:50:47 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-11-16 17:04:41 +0100 |
commit | 3e4a009c4be2d85d4443d59706ddf4ee9671b204 (patch) | |
tree | f9c6779750004098917b04b1c4837971b649be3e | |
parent | 09ffeeb464e53eb37a005c92c0af54af25a59561 (diff) | |
download | Ishtar-3e4a009c4be2d85d4443d59706ddf4ee9671b204.tar.bz2 Ishtar-3e4a009c4be2d85d4443d59706ddf4ee9671b204.zip |
JSON types: multi valued choices - fix search index and last panel
-rw-r--r-- | CHANGES-DEV.md | 12 | ||||
-rw-r--r-- | ishtar_common/models_common.py | 14 | ||||
-rw-r--r-- | ishtar_common/wizards.py | 7 |
3 files changed, 25 insertions, 8 deletions
diff --git a/CHANGES-DEV.md b/CHANGES-DEV.md index 2607374c9..5d983f6c6 100644 --- a/CHANGES-DEV.md +++ b/CHANGES-DEV.md @@ -2,9 +2,17 @@ Ishtar changelog ================ ### Features ### -- Context record: bulk update relation - type -- Context record: change field order - JSON types: multi valued choices +- Forms: + - context record: change field order +- Admin: available/unavailable action +- Bulk action: + - site: remains, cultural attributions, collaborators, + - operation: collaborators + - find: conservation commentary + - context record: town, relation - type +- Search: + - document: operation year, operation type ### Bugs ### - Search: fix url for person and organization diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index dc078000e..372890f22 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -970,11 +970,15 @@ class FullSearch(models.Model): # only index year self._update_search_number_field(search_vectors, data.year) continue - for lang in ("simple", settings.ISHTAR_SEARCH_LANGUAGE): - with connection.cursor() as cursor: - cursor.execute("SELECT to_tsvector(%s, %s)", [lang, data]) - row = cursor.fetchone() - search_vectors.append(row[0]) + datas = [data] + if json_field.value_type == "MC": + datas = data + for d in datas: + for lang in ("simple", settings.ISHTAR_SEARCH_LANGUAGE): + with connection.cursor() as cursor: + cursor.execute("SELECT to_tsvector(%s, %s)", [lang, d]) + row = cursor.fetchone() + search_vectors.append(row[0]) new_search_vector = merge_tsvectors(search_vectors) changed = old_search != new_search_vector self.search_vector = new_search_vector diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 2b0a47a72..47839b58e 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -463,7 +463,6 @@ class Wizard(IshtarWizard): else: value = _("No") elif key in associated_models: - values = [] if type(value) in (tuple, list): values = value elif "," in str(value): @@ -479,6 +478,12 @@ class Wizard(IshtarWizard): value = str(item) rendered_values.append(value) value = " ; ".join(rendered_values) + if key.startswith("data__"): + if isinstance(value, list): + value = ", ".join(value) + if value.startswith("[") and value.endswith("]"): + value = " ; ".join( + [v.strip()[1:-1] for v in value[1:-1].split(",")]) current_form_data.append((lbl, value, "")) if is_formset: |