mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 19:35:02 -02:30
Prevent ee from being assigned to a new organization
- ee organization can be changed to null (less restrictive) - if organization is null, cannot be assigned to org (more restrictive) - if org is assigned, it cannot be set to a different org
This commit is contained in:
@@ -1412,6 +1412,14 @@ class ExecutionEnvironmentSerializer(BaseSerializer):
|
|||||||
res['credential'] = self.reverse('api:credential_detail', kwargs={'pk': obj.credential.pk})
|
res['credential'] = self.reverse('api:credential_detail', kwargs={'pk': obj.credential.pk})
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def validate(self, attrs):
|
||||||
|
# prevent changing organization of ee. Unsetting (change to null) is allowed
|
||||||
|
if self.instance:
|
||||||
|
org = attrs.get('organization', None)
|
||||||
|
if org and org.pk != self.instance.organization_id:
|
||||||
|
raise serializers.ValidationError({"organization": _("Cannot change the organization of an execution environment")})
|
||||||
|
return super(ExecutionEnvironmentSerializer, self).validate(attrs)
|
||||||
|
|
||||||
|
|
||||||
class ProjectSerializer(UnifiedJobTemplateSerializer, ProjectOptionsSerializer):
|
class ProjectSerializer(UnifiedJobTemplateSerializer, ProjectOptionsSerializer):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user