def edit(result_id): result = Result.query.get_or_404(result_id) #result.permissions.edit.test(403) form = ResultForm(obj=result) if form.validate_on_submit(): form.populate_obj(result) result.save() flash(u"你的条目已更新", "successfully") return redirect(url_for("result.view", result_id=result_id)) return render_template("result/edit_result.html", result=result, form=form)
def add(): form = ResultForm() form.case.choices = [(c.id, c.name) for c in Case.query.all()] if form.validate_on_submit(): result = Result() form.populate_obj(result) result.case = Case.query.filter(Case.id==form.case.data).first_or_404() result.author = current_user result.save() flash("Add Test Result successfully") return redirect(url_for("result.view", result_id=result.id)) return render_template("result/add.html", form=form)
def add(): form = ResultForm() form.case.choices = [(c.id, c.name) for c in Case.query.all()] if form.validate_on_submit(): result = Result() form.populate_obj(result) result.case = Case.query.filter( Case.id == form.case.data).first_or_404() result.author = current_user result.save() flash("Add Test Result successfully") return redirect(url_for("result.view", result_id=result.id)) return render_template("result/add.html", form=form)