adds related roles for InventoryScript

This commit is contained in:
Wayne Witzel III
2016-05-18 14:21:30 -04:00
parent 84aa762135
commit cce7af3d19
3 changed files with 16 additions and 0 deletions

View File

@@ -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