def create(): form = PersonForm() if form.validate_on_submit(): person = Person() person.populate_form(form) person.id = None person.staff = True db.session.add(person) try: db.session.commit() flash('職員の追加ができました', 'success') return redirect(url_for('staffs.index')) except Exception as e: db.session.rollback() flash('職員追加時にエラーが発生しました "{}"'.format(e), 'danger') return render_template('staffs/edit.pug', form=form)
def create(): form = PersonForm() if form.validate_on_submit(): person = Person() person.populate_form(form) db.session.add(person) try: db.session.commit() flash('Person created correctly.', 'success') return redirect(url_for('persons.index')) except IntegrityError: db.session.rollback() flash('同一IDMが指定された可能性が有ります', 'danger') except Exception as e: db.session.rollback() flash('Error generating person! {}'.format(e.message), 'danger') return render_template('persons/create.pug', form=form)