Пример #1
0
def set_timezone():
    user_id = auth_utils.get_user_id(flask.session['username'])
    timezone = flask.request.form['timezone']
    timezone = int(timezone) if timezone else None
    helpers.set_member_field(user_id, 'timezone', timezone)
    return redirect(
        flask.url_for('directory_search.view_user', user_id=user_id))
Пример #2
0
def set_email():
    username = flask.session.get('username')
    if username is None:
        flask.abort(403)

    email = flask.request.form['email']
    valid = validate_email(email) and \
        validate_matches(email, flask.request.form['email2'])
    if not valid:
        return redirect(flask.url_for('.edit_user'))

    user_id = auth_utils.get_user_id(username)
    helpers.set_member_field(user_id, 'email', email)
    return redirect(
        flask.url_for('directory_search.view_user', user_id=user_id))
Пример #3
0
def set_name():
    user_id = auth_utils.get_user_id(flask.session['username'])
    helpers.set_member_field(user_id, 'preferred_name',
                             flask.request.form['name'])
    return redirect(
        flask.url_for('directory_search.view_user', user_id=user_id))
Пример #4
0
def set_gender():
    user_id = auth_utils.get_user_id(flask.session['username'])
    helpers.set_member_field(user_id, 'gender_custom',
                             flask.request.form['gender'])
    return redirect(
        flask.url_for('directory_search.view_user', user_id=user_id))
Пример #5
0
def test_gender(client):
    user_id = helpers.get_user_id('csander')
    assert core_helpers.get_gender(user_id) == 'Male'
    core_helpers.set_member_field(user_id, 'gender_custom', 'new_gender')
    assert core_helpers.get_gender(user_id) == 'new_gender'
    assert core_helpers.get_gender(helpers.get_user_id('dqu')) == ''
Пример #6
0
def test_preferred_name(client):
    user_id = helpers.get_user_id('csander')
    assert core_helpers.get_preferred_name(user_id) == 'Cleb'
    core_helpers.set_member_field(user_id, 'preferred_name', 'Belac')
    assert core_helpers.get_preferred_name(user_id) == 'Belac'
    assert core_helpers.get_preferred_name(helpers.get_user_id('reng')) == ''