def change_author(author_id): if not session.get("logged"): abort(401) if request.method != "POST": author = db_handler.get_author(author_id) form = form_handler.AddAuthorForm(name = author.name) else: form = form_handler.AddAuthorForm(request.form) if form.validate(): if db_handler.change_author(author_id, form.name.data): flash("Changes author ({0}) save successfully".format(form.name.data)) return redirect(url_for('index')) else: for field in form: for error in field.errors: flash(error) return render_template("change_author.html", form=form, id = author_id)
def change_author(author_id): if not session.get("logged"): abort(401) if request.method != "POST": author = db_handler.get_author(author_id) form = form_handler.AddAuthorForm(name=author.name) else: form = form_handler.AddAuthorForm(request.form) if form.validate(): if db_handler.change_author(author_id, form.name.data): flash("Changes author ({0}) save successfully".format( form.name.data)) return redirect(url_for('index')) else: for field in form: for error in field.errors: flash(error) return render_template("change_author.html", form=form, id=author_id)