def new_bug(): ''' Create new bug ''' form = BugForm() if form.validate_on_submit(): my_bug = Bug() form.populate_obj(my_bug) db.session.add(my_bug) try: db.session.commit() # User info flash('Bug created correctly', 'success') return redirect(url_for('bugs')) except: db.session.rollback() flash('Error generating bug.', 'danger') return render_template('web/new_bug.html', form=form,users=[])
def edit_bug(id): ''' Edit contact :param id: Id from bug ''' my_bug = Bug.query.filter_by(id=id).first() form = BugForm(obj=my_bug) if form.validate_on_submit(): try: # Update contact form.populate_obj(my_bug) db.session.add(my_bug) db.session.commit() # User info flash('Saved successfully', 'success') except: db.session.rollback() flash('Error update contact.', 'danger') return render_template('web/edit_bug.html', form=form)