Example #1
0
def update_profile():
    """User profile update."""
    form = UserUpdateProfileForm()
    form.user_name.data = flask_login.current_user.name
    if form.validate_on_submit():
        set_user_by_instance(db.session,
                             user=flask_login.current_user,
                             lastname=form.lastname.data,
                             firstname=form.firstname.data,
                             email=form.email.data,
                             linkedin_url=form.linkedin_url.data,
                             twitter_url=form.twitter_url.data,
                             facebook_url=form.facebook_url.data,
                             google_url=form.google_url.data,
                             github_url=form.github_url.data,
                             website_url=form.website_url.data,
                             is_want_news=form.is_want_news.data)
        # send_register_request_mail(user)
        return redirect(url_for('ramp.problems'))
    form.lastname.data = flask_login.current_user.lastname
    form.firstname.data = flask_login.current_user.firstname
    form.email.data = flask_login.current_user.email
    form.linkedin_url.data = flask_login.current_user.linkedin_url
    form.twitter_url.data = flask_login.current_user.twitter_url
    form.facebook_url.data = flask_login.current_user.facebook_url
    form.google_url.data = flask_login.current_user.google_url
    form.github_url.data = flask_login.current_user.github_url
    form.website_url.data = flask_login.current_user.website_url
    form.bio.data = flask_login.current_user.bio
    form.is_want_news.data = flask_login.current_user.is_want_news
    return render_template('update_profile.html', form=form)
Example #2
0
def test_set_user_by_instance(session_scope_function):
    add_user(session_scope_function, name='test_user', password='******',
             lastname='lastname', firstname='firstname',
             email='*****@*****.**', access_level='asked')
    add_user(session_scope_function, name='test_user_2',
             password='******', lastname='lastname',
             firstname='firstname', email='*****@*****.**',
             access_level='asked')
    user = get_user_by_name(session_scope_function, 'test_user')
    set_user_by_instance(session_scope_function, user, lastname='a',
                         firstname='b', email='c', linkedin_url='d',
                         twitter_url='e', facebook_url='f', google_url='g',
                         github_url='h', website_url='i', bio='j',
                         is_want_news=False)
    user = get_user_by_name(session_scope_function, 'test_user')
    assert user.lastname == 'a'
    assert user.firstname == 'b'
    assert user.email == 'c'
    assert user.linkedin_url == 'd'
    assert user.twitter_url == 'e'
    assert user.facebook_url == 'f'
    assert user.google_url == 'g'
    assert user.github_url == 'h'
    assert user.website_url == 'i'
    assert user.bio == 'j'
    assert user.is_want_news is False