Exemplo n.º 1
0
def profile():
    '''
    Profile
    '''
    form = ProfileForm()
    if request.method == 'POST' and form.validate_on_submit():
        if form.last_name.data:
            current_user.last_name = form.last_name.data
        if form.first_name.data:
            current_user.first_name = form.first_name.data
        if form.phone:
            current_user.phone = form.phone.data
        if form.email:
            current_user.email = form.email.data
        DB.session.commit()
        return redirect(url_for('index'))
    else:
        form.email.data = current_user.email
        form.first_name.data = current_user.first_name
        form.last_name.data = current_user.last_name
        form.phone.data = current_user.phone
    return render_template('profile.html', form=form)