def account(): form = UpdateAccountForm() if form.validate_on_submit(): current_user.first_name = form.first_name.data current_user.last_name = form.last_name.data current_user.email = form.email.data db.session.commit() return redirect(url_for('account')) elif request.method =='GET': form.first_name = current_user.first_name form.last_name = current_user.last_name form.email = current_user.email return render_template('account.html', title='Account', form=form)
def account(): """Using the UpdateAccountForm this pulls data from the Users table and applys this to the fields on screen. This data can then be changed and updated.""" form = UpdateAccountForm() if form.validate_on_submit(): current_user.first_name = form.first_name.data current_user.last_name = form.last_name.data current_user.email = form.email.data db.session.commit() return redirect(url_for('account')) elif request.method == 'GET': form.first_name = current_user.first_name form.last_name = current_user.last_name form.email = current_user.email return render_template('account.html', title='Account Page', form=form)