diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-02-27 15:23:50 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-04-16 16:42:33 +0200 |
commit | 81696e2c35a2f94e7a4461eaf635fa006370ce6b (patch) | |
tree | 01c309a9be8ae8a64c67fdba0433ae2ea5d4b45a /archaeological_finds/models_finds.py | |
parent | cf09c147bce926102d995b51278d2d533ec3c888 (diff) | |
download | Ishtar-81696e2c35a2f94e7a4461eaf635fa006370ce6b.tar.bz2 Ishtar-81696e2c35a2f94e7a4461eaf635fa006370ce6b.zip |
🐛 Fix consultation permissions on the contents of a container (#5767)
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 c65e2cbbe..d22d43ae3 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -2922,33 +2922,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 ): @@ -3534,6 +3538,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) |