From 579648a017f598deea3d2ff8d8cbf6de25d420ba Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Thu, 26 Mar 2020 11:56:01 -0400 Subject: [PATCH] Identify user-only organization roles Organization participation roles (admin, member) can't be assigned to a team. Add a field to the object roles so the ui can know not to display them for team role selection. --- awx/api/serializers.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index bb488d368a..5a4e22cc3e 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1280,6 +1280,14 @@ class OrganizationSerializer(BaseSerializer): 'job_templates': 0, 'admins': 0, 'projects': 0} else: summary_dict['related_field_counts'] = counts_dict[obj.id] + + # Organization participation roles (admin, member) can't be assigned + # to a team. This provides a hint to the ui so it can know to not + # display these roles for team role selection. + for key in ('admin_role', 'member_role',): + if key in summary_dict.get('object_roles', {}): + summary_dict['object_roles'][key]['user_only'] = True + return summary_dict def validate(self, attrs):