Compare commits
No commits in common. "683977a00149582cfcee82c9a8c30a76455fe5a6" and "da2a1f6c6480227c9fedd7a8e5595080473fe6e9" have entirely different histories.
683977a001
...
da2a1f6c64
2 changed files with 4 additions and 19 deletions
|
@ -574,7 +574,7 @@ class ServiceInstance(ServalaModelMixin, models.Model):
|
|||
unique_together = [("name", "organization", "context")]
|
||||
rules_permissions = {
|
||||
"view": rules.is_staff | perms.is_organization_member,
|
||||
"change": rules.is_staff | perms.is_organization_admin,
|
||||
"change": rules.is_staff | perms.is_organization_member,
|
||||
"delete": rules.is_staff | perms.is_organization_admin,
|
||||
"add": rules.is_authenticated,
|
||||
}
|
||||
|
|
|
@ -13,30 +13,15 @@ def has_organization_role(user, org, roles):
|
|||
|
||||
|
||||
@rules.predicate
|
||||
def is_organization_owner(user, obj):
|
||||
if hasattr(obj, "organization"):
|
||||
org = obj.organization
|
||||
else:
|
||||
org = obj
|
||||
def is_organization_owner(user, org):
|
||||
return has_organization_role(user, org, ["owner"])
|
||||
|
||||
|
||||
@rules.predicate
|
||||
def is_organization_admin(user, obj):
|
||||
if hasattr(obj, "organization"):
|
||||
org = obj.organization
|
||||
else:
|
||||
org = obj
|
||||
def is_organization_admin(user, org):
|
||||
return has_organization_role(user, org, ["owner", "admin"])
|
||||
|
||||
|
||||
@rules.predicate
|
||||
def is_organization_member(user, obj):
|
||||
if hasattr(obj, "organization"):
|
||||
org = obj.organization
|
||||
else:
|
||||
org = obj
|
||||
def is_organization_member(user, org):
|
||||
return has_organization_role(user, org, None)
|
||||
|
||||
|
||||
rules.add_perm("core", rules.is_staff)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue