Make kind read-only for PUT/PATCH, use isinstance in Host Manager, update field fasly check

This commit is contained in:
Wayne Witzel III
2017-05-02 13:00:17 -04:00
parent bdb13ecd71
commit af35838aff
3 changed files with 15 additions and 5 deletions

View File

@@ -1686,6 +1686,15 @@ class InventoryDetail(RetrieveUpdateDestroyAPIView):
model = Inventory
serializer_class = InventoryDetailSerializer
def update(self, request, *args, **kwargs):
obj = self.get_object()
kind = self.request.data.get('kind') or kwargs.get('kind')
# Do not allow changes to an Inventory kind.
if kind is not None and obj.kind != kind:
return self.http_method_not_allowed(request, *args, **kwargs)
return super(InventoryDetail, self).update(request, *args, **kwargs)
def destroy(self, request, *args, **kwargs):
with ignore_inventory_computed_fields():
with ignore_inventory_group_removal():