mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 19:10:07 -03:30
Merge pull request #1612 from AlanCoding/token_no
Make user_capabilities False for read tokens
This commit is contained in:
commit
b3e15f70cb
@ -341,7 +341,10 @@ class BaseAccess(object):
|
||||
|
||||
# Actions not possible for reason unrelated to RBAC
|
||||
# Cannot copy with validation errors, or update a manual group/project
|
||||
if display_method == 'copy' and isinstance(obj, JobTemplate):
|
||||
if 'write' not in getattr(self.user, 'oauth_scopes', ['write']):
|
||||
user_capabilities[display_method] = False # Read tokens cannot take any actions
|
||||
continue
|
||||
elif display_method == 'copy' and isinstance(obj, JobTemplate):
|
||||
if obj.validation_errors:
|
||||
user_capabilities[display_method] = False
|
||||
continue
|
||||
|
||||
@ -39,6 +39,7 @@ def get_summary_fields_assert():
|
||||
def get_summary_fields_mock_and_run():
|
||||
def fn(serializer_class, model_obj):
|
||||
serializer = serializer_class()
|
||||
serializer.show_capabilities = []
|
||||
serializer.context['view'] = mock.Mock(kwargs={})
|
||||
return serializer.get_summary_fields(model_obj)
|
||||
return fn
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user