def display_new_algorithm():
form = CreateAlgorithmForm(request.form)
if request.method == 'POST' and form.validate():
name = form.name.data
code = form.code.data
current_app.logger.info('Adding a new algorithm %s.', (name))
algorithm = Algorithm(name, current_user.id, code=code)
try:
db.session.add(algorithm)
db.session.commit()
flash('Algorithm successfully created.')
return redirect(url_for('setting.display_index'))
except exc.SQLAlchemyError as e:
flash('Algorithm was not created.')
current_app.logger.error(e)
return render_template('setting_new_algorithm.html', form=form)
评论列表
文章目录