mirror of
https://github.com/ansible/awx.git
synced 2026-03-21 10:57:36 -02:30
adds related roles for InventoryScript
This commit is contained in:
@@ -1261,6 +1261,9 @@ class CustomInventoryScriptSerializer(BaseSerializer):
|
|||||||
|
|
||||||
def get_related(self, obj):
|
def get_related(self, obj):
|
||||||
res = super(CustomInventoryScriptSerializer, self).get_related(obj)
|
res = super(CustomInventoryScriptSerializer, self).get_related(obj)
|
||||||
|
res.update(dict(
|
||||||
|
roles = reverse('api:inventory_script_roles_list', args=(obj.pk,)),
|
||||||
|
))
|
||||||
|
|
||||||
if obj.organization:
|
if obj.organization:
|
||||||
res['organization'] = reverse('api:organization_detail', args=(obj.organization.pk,))
|
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',
|
inventory_script_urls = patterns('awx.api.views',
|
||||||
url(r'^$', 'inventory_script_list'),
|
url(r'^$', 'inventory_script_list'),
|
||||||
url(r'^(?P<pk>[0-9]+)/$', 'inventory_script_detail'),
|
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',
|
credential_urls = patterns('awx.api.views',
|
||||||
|
|||||||
@@ -1424,6 +1424,18 @@ class InventoryScriptDetail(RetrieveUpdateDestroyAPIView):
|
|||||||
inv_src.save()
|
inv_src.save()
|
||||||
return super(InventoryScriptDetail, self).destroy(request, *args, **kwargs)
|
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):
|
class InventoryList(ListCreateAPIView):
|
||||||
|
|
||||||
model = Inventory
|
model = Inventory
|
||||||
|
|||||||
Reference in New Issue
Block a user