diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-11-04 17:48:38 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:23:19 +0100 |
commit | 2d99266012a4cb76896c094a786d9aaec74a1f29 (patch) | |
tree | 4d98f8e5f5fdf2e826b89cf85ec4450c382ad471 | |
parent | 14ef831ec67d44825df52347a091bf93244eb743 (diff) | |
download | Ishtar-2d99266012a4cb76896c094a786d9aaec74a1f29.tar.bz2 Ishtar-2d99266012a4cb76896c094a786d9aaec74a1f29.zip |
Geodata: display first item associated as a name when no name is provided
-rw-r--r-- | CHANGES.md | 6 | ||||
-rw-r--r-- | ishtar_common/models_common.py | 10 |
2 files changed, 14 insertions, 2 deletions
diff --git a/CHANGES.md b/CHANGES.md index fa1448a4a..87d8e869b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,16 +3,18 @@ title: Ishtar changelog date: 2022-10-17 --- +### Features ### +- Geodata: display first item associated as a name when no name is provided ### Bug fix ### -- Geodata import: +- Geodata import: fix total number evaluation on imports v4.0.24 - 2022-10-27 -------------------- ### Bug fix ### -- Geodata import: fix total number evaluation on imports +- Geodata save: transactions to limit deadlocks v4.0.23 - 2022-10-26 diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 779af635b..dc35cade2 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2210,6 +2210,16 @@ class GeoVectorData(Imported, OwnPerms): def __str__(self): name = self.name + if not name or name == "-": + for related_model in self.RELATED_MODELS: + q = getattr(self, related_model) + cached_label_key = "cached_label" + if getattr(q.model, "GEO_LABEL", None): + cached_label_key = q.model.GEO_LABEL + if q.count(): # arbitrary return the first item + name = str(q.values_list(cached_label_key, flat=True).all()[0]) + break + if self.data_type: name += f" ({str(self.data_type).lower()})" return name |