示例#1
0
    def put(self, id):
        """
        update environment
        /environment/<int:id>

        :return:
        """
        super(ServerAPI, self).put()

        form = ServerForm(request.form, csrf_enabled=False)
        form.set_id(id)
        if form.validate_on_submit():
            server = ServerModel(id=id)
            ret = server.update(name=form.name.data, host=form.host.data)
            return self.render_json(data=server.item())
        else:
            return self.render_error(code=Code.form_error, message=form.errors)
示例#2
0
    def put(self, id):
        """
        update environment
        /environment/<int:id>

        :return:
        """
        super(ServerAPI, self).put()


        form = ServerForm(request.form, csrf_enabled=False)
        form.set_id(id)
        if form.validate_on_submit():
            server = ServerModel(id=id)
            ret = server.update(name=form.name.data, host=form.host.data)
            return self.render_json(data=server.item())
        else:
            return self.render_json(code=-1, message=form.errors)
示例#3
0
    def put(self, id):
        """
        update server
        /server/<int:id>

        :return:
        """
        super(ServerAPI, self).put()

        form = ServerForm(request.form, csrf=False)
        form.set_id(id)
        if form.validate_on_submit():
            server = ServerModel().get_by_id(id)
            data = form.form2dict()
            ret = server.update(data)
            return self.render_json(data=server.item())
        else:
            return self.render_error(code=Code.form_error, message=form.errors)
示例#4
0
    def put(self, id):
        """
        update server
        /server/<int:id>

        :return:
        """
        super(ServerAPI, self).put()

        form = ServerForm(request.form, csrf=False)
        form.set_id(id)
        if form.validate_on_submit():
            server = ServerModel().get_by_id(id)
            data = form.form2dict()
            ret = server.update(data)
            return self.render_json(data=server.item())
        else:
            return self.render_error(code=Code.form_error, message=form.errors)