mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 08:18:43 -03:30
Make sure that validation of managed EEs makes sense
- missing fields in a patch request should be ignored - compare the organization pks, if present
This commit is contained in:
committed by
Shane McDonald
parent
9992bf03b0
commit
d5deedc822
@@ -710,8 +710,12 @@ class ExecutionEnvironmentDetail(RetrieveUpdateDestroyAPIView):
|
|||||||
fields_to_check = ['name', 'description', 'organization', 'image', 'credential']
|
fields_to_check = ['name', 'description', 'organization', 'image', 'credential']
|
||||||
if instance.managed and request.user.can_access(models.ExecutionEnvironment, 'change', instance):
|
if instance.managed and request.user.can_access(models.ExecutionEnvironment, 'change', instance):
|
||||||
for field in fields_to_check:
|
for field in fields_to_check:
|
||||||
|
if kwargs.get('partial') and field not in request.data:
|
||||||
|
continue
|
||||||
left = getattr(instance, field, None)
|
left = getattr(instance, field, None)
|
||||||
right = request.data.get(field, None)
|
if hasattr(left, 'id'):
|
||||||
|
left = left.id
|
||||||
|
right = request.data.get(field)
|
||||||
if left != right:
|
if left != right:
|
||||||
raise PermissionDenied(_("Only the 'pull' field can be edited for managed execution environments."))
|
raise PermissionDenied(_("Only the 'pull' field can be edited for managed execution environments."))
|
||||||
return super().update(request, *args, **kwargs)
|
return super().update(request, *args, **kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user