mirror of
https://github.com/ansible/awx.git
synced 2026-03-03 09:48:51 -03:30
Merge pull request #1612 from AlanCoding/token_no
Make user_capabilities False for read tokens
This commit is contained in:
@@ -341,7 +341,10 @@ class BaseAccess(object):
|
|||||||
|
|
||||||
# Actions not possible for reason unrelated to RBAC
|
# Actions not possible for reason unrelated to RBAC
|
||||||
# Cannot copy with validation errors, or update a manual group/project
|
# 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:
|
if obj.validation_errors:
|
||||||
user_capabilities[display_method] = False
|
user_capabilities[display_method] = False
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ def get_summary_fields_assert():
|
|||||||
def get_summary_fields_mock_and_run():
|
def get_summary_fields_mock_and_run():
|
||||||
def fn(serializer_class, model_obj):
|
def fn(serializer_class, model_obj):
|
||||||
serializer = serializer_class()
|
serializer = serializer_class()
|
||||||
|
serializer.show_capabilities = []
|
||||||
serializer.context['view'] = mock.Mock(kwargs={})
|
serializer.context['view'] = mock.Mock(kwargs={})
|
||||||
return serializer.get_summary_fields(model_obj)
|
return serializer.get_summary_fields(model_obj)
|
||||||
return fn
|
return fn
|
||||||
|
|||||||
Reference in New Issue
Block a user