def post_create_kit(): form = CreateForm(csrf_enabled=False) form.init() form.process(request.form) kit_file = request.files["kit_file"] if form.validate(): json = { "request": { "substance": { "kit_name": form.kit_name.data, "author_id": form.author_id.data, "category_id": form.category_id.data, "tags": unicode(form.tags.data).split(","), "description": form.description.data, "kit_file": kit_file, } } } req = json.get("request") ret = KitFacade.create(req).get("response") if ret and ret.get("result") == const.RESPONSE_RESULT_SUCCESSFUL: return redirect("/admin/author/update/" + form.author_id.data) else: form.errors["exceptions"] = [ret.get("message")] return render_template("kit/create.html", form=form)
def get_create_kit(): author_id = request.values["author_id"] form = CreateForm(csrf_enabled=False) form.init() form.author_id.data = author_id return render_template("kit/create.html", form=form)