def account(): form = ProfileForm(request.form) if request.method == 'GET': form.populateForm(current_user) if request.method == 'POST' and form.validate(): current_user.first_name = form.first_name.data current_user.email = form.email.data current_user.phone = form.phone.data current_user.show_whats = form.show_whats.data current_user.can_email = form.can_email.data db.session.commit() flash('Conta atualizada', 'success') return redirect(url_for('index')) return render_template('account.html', form=form)