Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #4
0
    def post(self):
        """
        create a environment
        /environment/

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

        form = ServerForm(request.form, csrf_enabled=False)
        if form.validate_on_submit():
            server_new = ServerModel()
            id = server_new.add(name=form.name.data, host=form.host.data)
            if not id:
                return self.render_json(code=-1)

            return self.render_json(data=server_new.item(id))
        else:
            return self.render_json(code=-1, message=form.errors)
Beispiel #5
0
    def post(self):
        """
        create a environment
        /environment/

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

        form = ServerForm(request.form, csrf_enabled=False)
        if form.validate_on_submit():
            server_new = ServerModel()
            id = server_new.add(name=form.name.data, host=form.host.data)
            if not id:
                return self.render_json(code=-1)

            return self.render_json(data=server_new.item(id))
        else:
            return self.render_json(Code.form_error, message=form.errors)
Beispiel #6
0
    def post(self):
        """
        create a server
        /server/

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

        form = ServerForm(request.form, csrf=False)
        if form.validate_on_submit():
            server_new = ServerModel()
            data = form.form2dict()
            id = server_new.add(data)
            if not id:
                return self.render_json(code=-1)

            return self.render_json(data=server_new.item(id))
        else:
            return self.render_json(Code.form_error, message=form.errors)
Beispiel #7
0
    def post(self):
        """
        create a server
        /server/

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

        form = ServerForm(request.form, csrf=False)
        if form.validate_on_submit():
            server_new = ServerModel()
            data = form.form2dict()
            id = server_new.add(data)
            if not id:
                return self.render_json(code=-1)

            return self.render_json(data=server_new.item(id))
        else:
            return self.render_json(Code.form_error, message=form.errors)
Beispiel #8
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)