diff options
Diffstat (limited to 'archaeological_finds/models_finds.py')
-rw-r--r-- | archaeological_finds/models_finds.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 680c954ee..e331c90a3 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -2921,33 +2921,37 @@ class Find( return new @classmethod - def get_query_owns(cls, ishtaruser): + def _get_query_owns(cls, ishtaruser, prefix=""): q = ( cls._construct_query_own( - "container__location__", Warehouse._get_query_owns_dicts(ishtaruser) + f"{prefix}container__location__", Warehouse._get_query_owns_dicts(ishtaruser) ) | cls._construct_query_own( - "container__responsible__", Warehouse._get_query_owns_dicts(ishtaruser) + f"{prefix}container__responsible__", Warehouse._get_query_owns_dicts(ishtaruser) ) | cls._construct_query_own( - "base_finds__context_record__operation__", + f"{prefix}base_finds__context_record__operation__", Operation._get_query_owns_dicts(ishtaruser), ) | cls._construct_query_own( - "basket__", + f"{prefix}basket__", [{"shared_with": ishtaruser, "shared_write_with": ishtaruser}], ) | cls._construct_query_own( "", [ - {"history_creator": ishtaruser.user_ptr}, - {"base_finds__context_record__operation__end_date__isnull": True}, + {f"{prefix}history_creator": ishtaruser.user_ptr}, + {f"{prefix}base_finds__context_record__operation__end_date__isnull": True}, ], ) ) return q @classmethod + def get_query_owns(cls, ishtaruser): + return cls._get_query_owns(ishtaruser) + + @classmethod def get_owns( cls, user, menu_filtr=None, limit=None, values=None, get_short_menu_class=None ): @@ -3533,6 +3537,10 @@ class FindInsideContainer(models.Model): managed = False db_table = "find_inside_container" + @classmethod + def get_query_owns(cls, ishtaruser): + return Find._get_query_owns(ishtaruser, prefix="find__") + for attr in Find.HISTORICAL_M2M: m2m_changed.connect(m2m_historization_changed, sender=getattr(Find, attr).through) |