Make rules compatible with instance checks
All checks were successful
Tests / test (push) Successful in 26s
All checks were successful
Tests / test (push) Successful in 26s
This commit is contained in:
parent
5feabda513
commit
0bd895c486
1 changed files with 16 additions and 3 deletions
|
@ -13,17 +13,30 @@ def has_organization_role(user, org, roles):
|
||||||
|
|
||||||
|
|
||||||
@rules.predicate
|
@rules.predicate
|
||||||
def is_organization_owner(user, org):
|
def is_organization_owner(user, obj):
|
||||||
|
if hasattr(obj, "organization"):
|
||||||
|
org = obj.organization
|
||||||
|
else:
|
||||||
|
org = obj
|
||||||
return has_organization_role(user, org, ["owner"])
|
return has_organization_role(user, org, ["owner"])
|
||||||
|
|
||||||
|
|
||||||
@rules.predicate
|
@rules.predicate
|
||||||
def is_organization_admin(user, org):
|
def is_organization_admin(user, obj):
|
||||||
|
if hasattr(obj, "organization"):
|
||||||
|
org = obj.organization
|
||||||
|
else:
|
||||||
|
org = obj
|
||||||
return has_organization_role(user, org, ["owner", "admin"])
|
return has_organization_role(user, org, ["owner", "admin"])
|
||||||
|
|
||||||
|
|
||||||
@rules.predicate
|
@rules.predicate
|
||||||
def is_organization_member(user, org):
|
def is_organization_member(user, obj):
|
||||||
|
if hasattr(obj, "organization"):
|
||||||
|
org = obj.organization
|
||||||
|
else:
|
||||||
|
org = obj
|
||||||
return has_organization_role(user, org, None)
|
return has_organization_role(user, org, None)
|
||||||
|
|
||||||
|
|
||||||
rules.add_perm("core", rules.is_staff)
|
rules.add_perm("core", rules.is_staff)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue