From 238a29bbc2c7e4325f59e66ac4cbec8bf05430f4 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 11 Aug 2025 18:25:24 +0200 Subject: ✨ templates - add slug to types (refs #6367) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/models_common.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'ishtar_common/models_common.py') diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 5a32953fe..ac49a4231 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -200,6 +200,24 @@ class GeneralType(Cached, models.Model): def history_compress(self): return self.txt_idx + def get_values(self, prefix="", no_values=False, filtr=None, **kwargs): + dct = {} + if "parent_level" in kwargs and kwargs["parent_level"] > 5: + return dct + if not prefix: # prefix is mandatory + return dct + else: + dct[prefix[:-1]] = str(self) + dct[prefix + "slug"] = self.slug if hasattr(self, "slug") else self.txt_idx + if getattr(self, "parent", None): + if "parent_level" in kwargs: + kwargs["parent_level"] += 1 + else: + kwargs["parent_level"] = 1 + dct[prefix + "parent"] = self.parent.get_values( + prefix=prefix + "parent_", no_values=no_values, filtr=filtr, **kwargs) + return dct + @classmethod def get_documentation_string(cls): """ -- cgit v1.2.3