Move Request-specific auth checks into requests.authorization
This commit is contained in:
@@ -17,28 +17,6 @@ class Authorization(object):
|
||||
def is_in_workspace(cls, user, workspace):
|
||||
return user in workspace.users
|
||||
|
||||
@classmethod
|
||||
def can_view_request(cls, user, request):
|
||||
if (
|
||||
Permissions.REVIEW_AND_APPROVE_JEDI_WORKSPACE_REQUEST
|
||||
in user.atat_permissions
|
||||
):
|
||||
return True
|
||||
elif request.creator == user:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def check_can_approve_request(cls, user):
|
||||
if (
|
||||
Permissions.REVIEW_AND_APPROVE_JEDI_WORKSPACE_REQUEST
|
||||
in user.atat_permissions
|
||||
):
|
||||
return True
|
||||
else:
|
||||
raise UnauthorizedError(user, "cannot review and approve requests")
|
||||
|
||||
@classmethod
|
||||
def check_workspace_permission(cls, user, workspace, permission, message):
|
||||
if not Authorization.has_workspace_permission(user, workspace, permission):
|
||||
|
Reference in New Issue
Block a user