Exemple #1
0
    def put(self, env_id):
        """
        update environment
        /environment/<int:env_id>

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

        form = EnvironmentForm(request.form, csrf_enabled=False)
        form.set_env_id(env_id)
        if form.validate_on_submit():
            env = EnvironmentModel(id=env_id)
            ret = env.update(env_name=form.env_name.data, status=form.status.data)
            return self.render_json(data=env.item())
        else:
            return self.render_json(code=-1, message=form.errors)
Exemple #2
0
    def put(self, env_id):
        """
        update environment
        /environment/<int:env_id>

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

        form = EnvironmentForm(request.form, csrf_enabled=False)
        form.set_env_id(env_id)
        if form.validate_on_submit():
            env = EnvironmentModel(id=env_id)
            ret = env.update(env_name=form.env_name.data, status=form.status.data)
            return self.render_json(data=env.item())
        else:
            return self.render_json(code=-1, message=form.errors)
Exemple #3
0
    def post(self):
        """
        create a environment
        /environment/

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

        form = EnvironmentForm(request.form, csrf=False)
        if form.validate_on_submit():
            env_new = EnvironmentModel()
            env_id = env_new.add(env_name=form.env_name.data, space_id=self.space_id)
            if not env_id:
                return self.render_json(code=-1)
            return self.render_json(data=env_new.item())
        else:
            return self.render_error(code=Code.form_error, message=form.errors)
Exemple #4
0
    def post(self):
        """
        create a environment
        /environment/

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

        form = EnvironmentForm(request.form, csrf_enabled=False)
        if form.validate_on_submit():
            env_new = EnvironmentModel()
            # TODO space_id
            env_id = env_new.add(env_name=form.env_name.data, space_id=self.space_id)
            if not env_id:
                return self.render_json(code=-1)
            return self.render_json(data=env_new.item())
        else:
            return self.render_json(code=-1, message=form.errors)
Exemple #5
0
    def post(self):
        """
        create a environment
        /environment/

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

        form = EnvironmentForm(request.form, csrf=False)
        if form.validate_on_submit():
            env = EnvironmentModel()
            data = form.form2dict()
            env_new = env.add(data)
            if not env_new:
                return self.render_json(code=-1)
            return self.render_json(data=env_new)
        else:
            return self.render_error(code=Code.form_error, message=form.errors)
Exemple #6
0
    def post(self):
        """
        create a environment
        /environment/

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

        form = EnvironmentForm(request.form, csrf=False)
        if form.validate_on_submit():
            env = EnvironmentModel()
            data = form.form2dict()
            env_new = env.add(data)
            if not env_new:
                return self.render_json(code=-1)
            return self.render_json(data=env_new)
        else:
            return self.render_error(code=Code.form_error, message=form.errors)