def add(): form = CaseForm() if form.validate_on_submit(): case = Case(name=form.name) form.populate_obj(case) case.author = current_user case.save() flash("Add Test Case successfully") return redirect(url_for("case.view", case_id=case.id)) return render_template("case/add.html", form=form)
def add_case(): if not request.json or not 'name' in request.json: abort(400) case = Case(name=request.json['name']) #case.author = current_user user = User.query.filter_by(username=request.json['username']).first_or_404() case.author = user case.description = request.json['description'] case.save() return jsonify({'case':str(case)}),201