Ejemplo n.º 1
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)
Ejemplo n.º 2
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)
Ejemplo n.º 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 = 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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
    def put(self, env_id):
        """
        update environment
        /environment/<int:env_id>

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

        form = EnvironmentForm(request.form, csrf=False)
        form.set_env_id(env_id)
        if form.validate_on_submit():
            env = EnvironmentModel(id=env_id)

            data = form.form2dict()
            env_new = env.add(data)

            ret = env.update(env_name=form.env_name.data, status=form.status.data)
            return self.render_json(data=env.item())
        else:
            return self.render_error(code=Code.form_error, message=form.errors)
Ejemplo n.º 6
0
 def test_add(self):
     env_new = EnvironmentModel()
     env_id = env_new.add(env_name=u'开发环境')
Ejemplo n.º 7
0
 def test_add(self):
     env_new = EnvironmentModel()
     env_id = env_new.add(env_name=u'开发环境', space_id=1)