diff options
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r-- | ishtar_common/models_common.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 57c75d45d..ce31cb974 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -206,6 +206,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): """ |