diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-04-22 14:22:42 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-12 08:43:31 +0200 | 
| commit | 9a63b07c1270f47c0409bf463a4197570fef530c (patch) | |
| tree | 6c8f02fce5a0f73da11c4f415261af424c2ebe9a /ishtar_common/models.py | |
| parent | abd0cb791ab4e0ca35136c65ae3ec6def1539f15 (diff) | |
| download | Ishtar-9a63b07c1270f47c0409bf463a4197570fef530c.tar.bz2 Ishtar-9a63b07c1270f47c0409bf463a4197570fef530c.zip | |
Refactoring of query owns (refs #4060)
Diffstat (limited to 'ishtar_common/models.py')
| -rw-r--r-- | ishtar_common/models.py | 28 | 
1 files changed, 28 insertions, 0 deletions
| diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 2ebe07961..c14635a51 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -364,6 +364,34 @@ class OwnPerms(object):                  items = [(i, cls.get_short_menu_class(i.pk)) for i in items]          return items +    @classmethod +    def _get_query_owns_dicts(cls, ishtaruser): +        """ +        List of query own dict to construct the query. +        Each dict are join with an AND operator, each dict key, values are +        joined with OR operator +        """ +        return [] + +    @classmethod +    def _construct_query_own(cls, prefix, dct_list): +        q = None +        for subquery_dict in dct_list: +            subquery = None +            for k in subquery_dict: +                subsubquery = Q(**{prefix + k: subquery_dict[k]}) +                if subquery: +                    subquery |= subsubquery +                else: +                    subquery = subsubquery +            if not subquery: +                continue +            if q: +                q &= subquery +            else: +                q = subquery +        return q +  class Cached(object):      slug_field = 'txt_idx' | 
