mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
make user_capabilities False for read tokens
This commit is contained in:
parent
1a542c5e06
commit
4f1f578fde
@ -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…
Reference in New Issue
Block a user