예제 #1
0
def index():
    form = OptionForm()
    if form.validate_on_submit():
        Option.set('office_number', form.office_number.data)
        Option.set('office_name', form.office_name.data)
        try:
            db.session.commit()
            flash('設定を反映しました', 'success')
            return redirect(url_for('index'))
        except Exception as e:
            db.session.rollback()
            flash('設定反映時にエラーが発生しました "{}"'.format(e), 'danger')
    else:
        form.office_number.data = Option.get('office_number', '')
        form.office_name.data = Option.get('office_name', '')
    return render_template('options/edit.pug', form=form)
예제 #2
0
def index():
    form = OptionForm()
    if form.validate_on_submit():
        Option.set('office_number', form.office_number.data)
        Option.set('office_name', form.office_name.data)
        try:
            db.session.commit()
            flash('Option saved successfully.', 'success')
            return redirect(url_for('index'))
        except:
            db.session.rollback()
            flash('Error update option!', 'danger')
    else:
        form.office_number.data = Option.get('office_number', '')
        form.office_name.data = Option.get('office_name', '')
    return render_template('options/edit.pug', form=form)
예제 #3
0
파일: options.py 프로젝트: abtoc/ofpp-app
def index():
    form = OptionForm()
    if form.validate_on_submit():
        Option.set('office_number', form.office_number.data)
        Option.set('office_name', form.office_name.data)
        try:
            db.session.commit()
            flash('設定を反映しました', 'success')
            return redirect(url_for('index'))
        except Exception as e:
            db.session.rollback()
            flash('設定反映時にエラーが出ました {}'.format(e), 'danger')
            from traceback import format_exc
            print(format_exc)
    elif request.method == 'GET':
        form.office_number.data = Option.get('office_number')
        form.office_name.data = Option.get('office_name')
    return render_template('options/edit.pug', form=form)