From 226bc1e62a3fec5df009d3f4bc349303167b289f Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 12 Apr 2021 17:53:27 +0200 Subject: CSV export: manage __count - fix get localisations --- CHANGES.md | 6 ++++++ archaeological_warehouse/models.py | 18 +++++++++--------- ishtar_common/version.py | 4 ++-- ishtar_common/views_item.py | 6 +++++- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ecb9a3bb3..61c29da6d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,12 @@ Ishtar changelog ================ +v3.1.10 - 2021-04-12 +-------------------- + +### Features ### +- CSV export: manage "count" - shift get_localisation + v3.1.9 - 2021-04-12 ------------------- diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 6347104bc..b4bf8c5ea 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -1367,39 +1367,39 @@ class Container( @property def localisation_1(self): - return self.get_localisation(0) + return self.get_localisation(1) @property def localisation_2(self): - return self.get_localisation(1) + return self.get_localisation(2) @property def localisation_3(self): - return self.get_localisation(2) + return self.get_localisation(3) @property def localisation_4(self): - return self.get_localisation(3) + return self.get_localisation(4) @property def localisation_5(self): - return self.get_localisation(4) + return self.get_localisation(5) @property def localisation_6(self): - return self.get_localisation(5) + return self.get_localisation(6) @property def localisation_7(self): - return self.get_localisation(6) + return self.get_localisation(7) @property def localisation_8(self): - return self.get_localisation(7) + return self.get_localisation(8) @property def localisation_9(self): - return self.get_localisation(8) + return self.get_localisation(9) def set_localisation(self, place, value, static=False, return_errors=False): """ diff --git a/ishtar_common/version.py b/ishtar_common/version.py index 786cae0aa..120c379b3 100644 --- a/ishtar_common/version.py +++ b/ishtar_common/version.py @@ -1,5 +1,5 @@ -# 3.1.9 -VERSION = (3, 1, 9) +# 3.1.10 +VERSION = (3, 1, 10) def get_version(): diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 9c20f7e2c..3787e7d19 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -1369,10 +1369,14 @@ def _get_data_from_query_old( splitted_k += ky.split("__") else: splitted_k.append(ky) + if splitted_k[-1] == "count": + splitted_k = splitted_k[:-2] + [splitted_k[-2] + "__count"] for ky in splitted_k: new_vals = [] for val in vals: - if hasattr(val, "all"): # manage related objects + if ky.endswith("__count"): + new_vals += [getattr(val, ky[:-len("__count")]).count()] + elif hasattr(val, "all"): # manage related objects val = list(val.all()) for v in val: v = getattr(v, ky) -- cgit v1.2.3