Skip to content

Commit

Permalink
Change OrganizationSerializer to show and set default_environment
Browse files Browse the repository at this point in the history
  • Loading branch information
jbradberry committed Jul 6, 2020
1 parent a640585 commit e8f8c4e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion awx/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'insights_credential_id',),
'host': DEFAULT_SUMMARY_FIELDS,
'group': DEFAULT_SUMMARY_FIELDS,
'default_environment': ('id', 'organization_id', 'image', 'description'),
'project': DEFAULT_SUMMARY_FIELDS + ('status', 'scm_type'),
'source_project': DEFAULT_SUMMARY_FIELDS + ('status', 'scm_type'),
'project_update': DEFAULT_SUMMARY_FIELDS + ('status', 'failed',),
Expand Down Expand Up @@ -1246,7 +1247,7 @@ class OrganizationSerializer(BaseSerializer):

class Meta:
model = Organization
fields = ('*', 'max_hosts', 'custom_virtualenv',)
fields = ('*', 'max_hosts', 'custom_virtualenv', 'default_environment',)

def get_related(self, obj):
res = super(OrganizationSerializer, self).get_related(obj)
Expand All @@ -1270,6 +1271,9 @@ def get_related(self, obj):
access_list = self.reverse('api:organization_access_list', kwargs={'pk': obj.pk}),
instance_groups = self.reverse('api:organization_instance_groups_list', kwargs={'pk': obj.pk}),
))
if obj.default_environment:
res['default_environment'] = self.reverse('api:execution_environment_detail',
kwargs={'pk': obj.default_environment_id})
return res

def get_summary_fields(self, obj):
Expand Down

0 comments on commit e8f8c4e

Please sign in to comment.