def display_edit(algorithm_id):
algorithm = Algorithm.query.filter_by(id=algorithm_id).first()
form = CreateAlgorithmForm(request.form)
if request.method == 'POST' and form.validate():
name = form.name.data
code = form.code.data
current_app.logger.info('Edit a algorithm %s.', (name))
algorithm.name = name
algorithm.code = code
try:
db.session.commit()
flash('Algorithm successfully edited.')
return redirect(url_for('setting.display_index'))
except exc.SQLAlchemyError as e:
flash('Algorithm was not edited.')
current_app.logger.error(e)
form.name.data = algorithm.name
form.code.data = algorithm.code
return render_template("setting_edit_algorithm.html", form=form)
评论列表
文章目录