mirror of
https://github.com/ansible/awx.git
synced 2026-02-04 11:08:13 -03:30
Add code that allows getting just the root groups for an inventory.
This commit is contained in:
@@ -876,6 +876,25 @@ class InventoryGroupsList(BaseSubList):
|
||||
# FIXME: verify that you can can_read permission on the inventory is required
|
||||
return base
|
||||
|
||||
class InventoryRootGroupsList(BaseSubList):
|
||||
|
||||
model = Group
|
||||
serializer_class = GroupSerializer
|
||||
permission_classes = (CustomRbac,)
|
||||
parent_model = Inventory
|
||||
relationship = 'groups'
|
||||
postable = True
|
||||
inject_primary_key_on_post_as = 'inventory'
|
||||
severable = False
|
||||
filter_fields = ('name',)
|
||||
|
||||
def _get_queryset(self):
|
||||
inventory = Inventory.objects.get(pk=self.kwargs['pk'])
|
||||
base = inventory.groups
|
||||
all_ids = base.values_list('id', flat=True)
|
||||
base.exclude(parents__id__in = all_ids)
|
||||
return base
|
||||
|
||||
class GroupsVariableDetail(VariableBaseDetail):
|
||||
|
||||
model = VariableData
|
||||
|
||||
Reference in New Issue
Block a user