mirror of
https://github.com/ansible/awx.git
synced 2026-03-17 00:47:29 -02:30
Various validations for const. inv. serialization
- prevent constructed inventory host,group,inventory_source creation - disable deleting constructed inventory hosts - remove the ability to add constructed inventory sources - remove ability to add constructed inventories to constructed inventories - block updates to constructed source type - added tests for group/host/source creation
This commit is contained in:
@@ -115,6 +115,15 @@ class InventoryInputInventoriesList(SubListAttachDetachAPIView):
|
||||
parent_model = Inventory
|
||||
relationship = 'input_inventories'
|
||||
|
||||
# Specifically overriding the post method on this view to disallow constructed inventories as input inventories
|
||||
def post(self, request, *args, **kwargs):
|
||||
obj = Inventory.objects.get(id=request.data.get('id'))
|
||||
if obj.kind == 'constructed':
|
||||
return Response(
|
||||
dict(error=_('You cannot add a constructed inventory to another constructed inventory.')), status=status.HTTP_405_METHOD_NOT_ALLOWED
|
||||
)
|
||||
return super(InventoryInputInventoriesList, self).post(request, *args, **kwargs)
|
||||
|
||||
|
||||
class InventoryActivityStreamList(SubListAPIView):
|
||||
model = ActivityStream
|
||||
|
||||
Reference in New Issue
Block a user