mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
AC-286. Added potential_children resource for groups.
This commit is contained in:
@@ -507,6 +507,7 @@ class GroupSerializer(BaseSerializerWithVariables):
|
|||||||
res.update(dict(
|
res.update(dict(
|
||||||
variable_data = reverse('main:group_variable_data', args=(obj.pk,)),
|
variable_data = reverse('main:group_variable_data', args=(obj.pk,)),
|
||||||
hosts = reverse('main:group_hosts_list', args=(obj.pk,)),
|
hosts = reverse('main:group_hosts_list', args=(obj.pk,)),
|
||||||
|
potential_children = reverse('main:group_potential_children_list', args=(obj.pk,)),
|
||||||
children = reverse('main:group_children_list', args=(obj.pk,)),
|
children = reverse('main:group_children_list', args=(obj.pk,)),
|
||||||
all_hosts = reverse('main:group_all_hosts_list', args=(obj.pk,)),
|
all_hosts = reverse('main:group_all_hosts_list', args=(obj.pk,)),
|
||||||
inventory = reverse('main:inventory_detail', args=(obj.inventory.pk,)),
|
inventory = reverse('main:inventory_detail', args=(obj.inventory.pk,)),
|
||||||
|
|||||||
9
awx/main/templates/main/group_potential_children_list.md
Normal file
9
awx/main/templates/main/group_potential_children_list.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# List Potential Child Groups for this {{ parent_model_verbose_name|title }}:
|
||||||
|
|
||||||
|
Make a GET request to this resource to retrieve a list of
|
||||||
|
{{ model_verbose_name_plural }} available to be added as children of the
|
||||||
|
current {{ parent_model_verbose_name }}.
|
||||||
|
|
||||||
|
{% include "main/_list_common.md" %}
|
||||||
|
|
||||||
|
{% include "main/_new_in_awx.md" %}
|
||||||
@@ -84,6 +84,7 @@ group_urls = patterns('awx.main.views',
|
|||||||
url(r'^(?P<pk>[0-9]+)/variable_data/$', 'group_variable_data'),
|
url(r'^(?P<pk>[0-9]+)/variable_data/$', 'group_variable_data'),
|
||||||
url(r'^(?P<pk>[0-9]+)/job_events/$', 'group_job_events_list'),
|
url(r'^(?P<pk>[0-9]+)/job_events/$', 'group_job_events_list'),
|
||||||
url(r'^(?P<pk>[0-9]+)/job_host_summaries/$', 'group_job_host_summaries_list'),
|
url(r'^(?P<pk>[0-9]+)/job_host_summaries/$', 'group_job_host_summaries_list'),
|
||||||
|
url(r'^(?P<pk>[0-9]+)/potential_children/$', 'group_potential_children_list'),
|
||||||
)
|
)
|
||||||
|
|
||||||
inventory_source_urls = patterns('awx.main.views',
|
inventory_source_urls = patterns('awx.main.views',
|
||||||
|
|||||||
@@ -540,6 +540,22 @@ class GroupChildrenList(SubListCreateAPIView):
|
|||||||
|
|
||||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||||
|
|
||||||
|
class GroupPotentialChildrenList(SubListAPIView):
|
||||||
|
|
||||||
|
model = Group
|
||||||
|
serializer_class = GroupSerializer
|
||||||
|
parent_model = Group
|
||||||
|
new_in_14 = True
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
parent = self.get_parent_object()
|
||||||
|
self.check_parent_access(parent)
|
||||||
|
qs = self.request.user.get_queryset(self.model)
|
||||||
|
except_pks = set([parent.pk])
|
||||||
|
except_pks.update(parent.all_parents.values_list('pk', flat=True))
|
||||||
|
except_pks.update(parent.all_children.values_list('pk', flat=True))
|
||||||
|
return qs.exclude(pk__in=except_pks)
|
||||||
|
|
||||||
class GroupHostsList(SubListCreateAPIView):
|
class GroupHostsList(SubListCreateAPIView):
|
||||||
''' the list of hosts directly below a group '''
|
''' the list of hosts directly below a group '''
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user