diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-10-23 18:51:15 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-02-19 14:43:48 +0100 |
commit | 6f59b9e36a0971b3deb44562062a878eb26beedf (patch) | |
tree | e22db164f77fc0ba6e30a539350bb5a37f36f5a6 /ishtar_common/utils.py | |
parent | be063a7032971db7c00a160595e69e1e67dd2c9f (diff) | |
download | Ishtar-6f59b9e36a0971b3deb44562062a878eb26beedf.tar.bz2 Ishtar-6f59b9e36a0971b3deb44562062a878eb26beedf.zip |
✨ permissions refactoring: generate permissions, adapt permissions checks
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 8de745874..09c470823 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -395,7 +395,8 @@ class OwnPerms: """ Check if the current object is owned by the user """ - print("ishtar_common/utils.py - 370 - DELETE") + print("ishtar_common/utils.py - 377 - DELETE") + raise IshtarUser = apps.get_model("ishtar_common", "IshtarUser") if isinstance(user, IshtarUser): ishtaruser = user @@ -467,13 +468,18 @@ class OwnPerms: values=None, get_short_menu_class=False, menu_filtr=None, + no_auth_check=False, + query=False ): """ Get Own items """ + return_query = query + query = None if not replace_query: replace_query = {} - if hasattr(user, "is_authenticated") and not user.is_authenticated: + if hasattr(user, "is_authenticated") and not user.is_authenticated \ + and not no_auth_check: returned = cls.objects.filter(pk__isnull=True) if values: returned = [] @@ -502,6 +508,10 @@ class OwnPerms: if values: returned = [] return returned + if return_query: + if query: + return query + return replace_query if query: q = cls.objects.filter(query) else: # replace_query |