diff options
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index f3ef8103c..ffa5323dd 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -5318,12 +5318,14 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel, @classmethod def get_query_owns(cls, ishtaruser): - Operation = cls.operations.rel.related_model - ArchaeologicalSite = cls.sites.rel.related_model - query_own_list = ( - ('operations__', Operation._get_query_owns_dicts(ishtaruser)), - ('sites__', ArchaeologicalSite._get_query_owns_dicts(ishtaruser)), - ) + query_own_list = [] + for rel_model in cls.RELATED_MODELS: + klass = getattr(cls, rel_model).rel.related_model + q_own_dct = klass._get_query_owns_dicts(ishtaruser) + if q_own_dct: + query_own_list.append( + (rel_model + "__", q_own_dct) + ) q = None for prefix, owns in query_own_list: subq = cls._construct_query_own(prefix, owns) @@ -5332,6 +5334,9 @@ class Document(BaseHistorizedItem, QRCodeItem, OwnPerms, ImageModel, q = subq else: q |= subq + q |= cls._construct_query_own('', [ + {'history_creator': ishtaruser.user_ptr} + ]) return q def get_associated_operation(self): |