Change org admin role access for inventory scripts

Previously a super user was required to create and administer custom
inventory scripts.   Since these are tied to organizations this commit
extends orgadmin admininstration abilities to custom scripts within
their organization
This commit is contained in:
Matthew Jones
2016-06-22 13:58:14 -04:00
parent 87f1f6f8e6
commit 0fda36116a
2 changed files with 10 additions and 0 deletions

View File

@@ -1506,6 +1506,12 @@ class CustomInventoryScriptAccess(BaseAccess):
return self.model.objects.distinct().all()
return self.model.accessible_objects(self.user, 'read_role').all()
@check_superuser
def can_add(self, data):
org_pk = get_pk_from_dict(data, 'organization')
org = get_object_or_400(Organization, pk=org_pk)
return self.user in org.admin_role
@check_superuser
def can_admin(self, obj):
return self.user in obj.admin_role