mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 19:30:39 -03:30
adds related roles for InventoryScript
This commit is contained in:
parent
84aa762135
commit
cce7af3d19
@ -1261,6 +1261,9 @@ class CustomInventoryScriptSerializer(BaseSerializer):
|
||||
|
||||
def get_related(self, obj):
|
||||
res = super(CustomInventoryScriptSerializer, self).get_related(obj)
|
||||
res.update(dict(
|
||||
roles = reverse('api:inventory_script_roles_list', args=(obj.pk,)),
|
||||
))
|
||||
|
||||
if obj.organization:
|
||||
res['organization'] = reverse('api:organization_detail', args=(obj.organization.pk,))
|
||||
|
||||
@ -155,6 +155,7 @@ inventory_update_urls = patterns('awx.api.views',
|
||||
inventory_script_urls = patterns('awx.api.views',
|
||||
url(r'^$', 'inventory_script_list'),
|
||||
url(r'^(?P<pk>[0-9]+)/$', 'inventory_script_detail'),
|
||||
url(r'^(?P<pk>[0-9]+)/roles/$', 'inventory_script_roles_list'),
|
||||
)
|
||||
|
||||
credential_urls = patterns('awx.api.views',
|
||||
|
||||
@ -1424,6 +1424,18 @@ class InventoryScriptDetail(RetrieveUpdateDestroyAPIView):
|
||||
inv_src.save()
|
||||
return super(InventoryScriptDetail, self).destroy(request, *args, **kwargs)
|
||||
|
||||
class InventoryScriptRolesList(SubListAPIView):
|
||||
|
||||
model = Role
|
||||
serializer_class = RoleSerializer
|
||||
parent_model = CustomInventoryScript
|
||||
new_in_300 = True
|
||||
|
||||
def get_queryset(self):
|
||||
po = self.get_parent_object()
|
||||
content_type = ContentType.objects.get_for_model(self.parent_model)
|
||||
return Role.objects.filter(content_type=content_type, object_id=po.pk).all()
|
||||
|
||||
class InventoryList(ListCreateAPIView):
|
||||
|
||||
model = Inventory
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user