diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-01-17 11:57:14 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-01-17 12:04:42 +0100 |
commit | f8b284fb878e64589168d29db9defc20b9af6c83 (patch) | |
tree | d54d2a8ad53efdc63f799df320909fbbcbb61183 | |
parent | 12732abd84d03d4472ee5f52688f776d98ad29ec (diff) | |
download | Ishtar-f8b284fb878e64589168d29db9defc20b9af6c83.tar.bz2 Ishtar-f8b284fb878e64589168d29db9defc20b9af6c83.zip |
🩹 document table: fix line duplication for authors (refs #5709)
-rw-r--r-- | ishtar_common/models.py | 1 | ||||
-rw-r--r-- | ishtar_common/views_item.py | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 6d644cb63..b011e541f 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -4240,6 +4240,7 @@ class Document( ] SERIALIZATION_FILES = ["image", "thumbnail", "associated_file"] SERIALIZE_PROPERTIES = ["external_id", "images_number"] + SELECT_GROUP_BY = True # v4.0 patch title = models.TextField(_("Title"), blank=True, default="") associated_file = models.FileField( diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index d80de34c7..c6110d930 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -2559,6 +2559,19 @@ def get_item( elif "name" in res: res["value"] = res.pop("name") rows.append(res) + # v4.0 patch + if getattr(model, "SELECT_GROUP_BY", False): + new_rows = OrderedDict() + for row in rows: + idx = row["id"] + if idx in new_rows: + for key in row: + if row[key] == new_rows[idx][key]: + continue + new_rows[idx][key] += " ; " + row[key] + else: + new_rows[idx] = row + rows = [row for __, row in new_rows.items()] if full == "shortcut": data = json.dumps(rows) else: |