From eb030fbecd62326b61e8669c34dbae9cb4770cfe Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 13 Jun 2024 12:48:56 +0200 Subject: 🐛 fix JSON date field modification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/models_common.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'ishtar_common') diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 6abe515d6..6d3270db4 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -1090,7 +1090,18 @@ class FullSearch(models.Model): continue elif json_field.value_type == "D": # only index year - self._update_search_number_field(search_vectors, data.year) + if hasattr(data, "year"): + self._update_search_number_field(search_vectors, data.year) + else: + y = None + for d in data.split("-"): + if len(d) == 4: # should be the year + try: + y = int(d) + except ValueError: + y = None + if y: + self._update_search_number_field(search_vectors, y) continue datas = [data] if json_field.value_type == "MC": -- cgit v1.2.3