Commit 05ecd749 authored by ibuler's avatar ibuler

[Update] 不可以更改root节点名称

parent 6b86b8b4
......@@ -48,6 +48,18 @@ class NodeViewSet(viewsets.ModelViewSet):
serializer.validated_data["key"] = child_key
serializer.save()
def update(self, request, *args, **kwargs):
node = self.get_object()
if node.is_root():
node_value = node.value
post_value = request.data.get('value')
if node_value != post_value:
return Response(
{"msg": _("You cant update the root node name")},
status=400
)
return super().update(request, *args, **kwargs)
class NodeChildrenApi(mixins.ListModelMixin, generics.CreateAPIView):
queryset = Node.objects.all()
......
......@@ -288,7 +288,9 @@ function onRename(event, treeId, treeNode, isCancel){
APIUpdateAttr({
url: url,
body: JSON.stringify(data),
method: "PATCH"
method: "PATCH",
success_message: "{% trans 'Rename success' %}",
fail_message: "{% trans 'Rename failed, do not change the root node name' %}"
})
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment