Example #1
0
def user_profile_page():
    the_tz = current_user.timezone if current_user.timezone else get_default_timezone(
    )
    if current_user.social_id and current_user.social_id.startswith('phone$'):
        form = PhoneUserProfileForm(request.form, obj=current_user)
    else:
        form = UserProfileForm(request.form, obj=current_user)
    form.timezone.choices = [
        (x, x) for x in sorted([tz for tz in pytz.all_timezones])
    ]
    form.timezone.default = the_tz
    if text_type(form.timezone.data) == 'None' or text_type(
            form.timezone.data) == '':
        form.timezone.data = the_tz
    if request.method == 'POST' and form.validate():
        form.populate_obj(current_user)
        db.session.commit()
        #docassemble.webapp.daredis.clear_user_cache()
        flash(word('Your information was saved.'), 'success')
        return redirect(url_for('interview_list'))
    response = make_response(
        render_template('users/user_profile_page.html',
                        version_warning=None,
                        page_title=word('User Profile'),
                        tab_title=word('User Profile'),
                        form=form,
                        debug=debug_status()), 200)
    response.headers[
        'Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
    return response
Example #2
0
def user_profile_page():
    the_tz = (current_user.timezone
              if current_user.timezone else get_default_timezone())
    form = UserProfileForm(request.form, obj=current_user)
    form.timezone.choices = [
        (x, x) for x in sorted([tz for tz in pytz.all_timezones])
    ]
    form.timezone.default = the_tz
    if str(form.timezone.data) == 'None':
        form.timezone.data = the_tz
    if request.method == 'POST' and form.validate():
        form.populate_obj(current_user)
        db.session.commit()
        flash(word('Your information was saved.'), 'success')
        return redirect(url_for('interview_list'))
    return render_template('users/user_profile_page.html',
                           page_title=word('User Profile'),
                           tab_title=word('User Profile'),
                           form=form,
                           debug=debug_status())
Example #3
0
def user_profile_page():
    setup_translation()
    if not (app.config['SHOW_PROFILE'] or current_user.has_roles(['admin'])):
        return ('File not found', 404)
    the_tz = current_user.timezone if current_user.timezone else get_default_timezone(
    )
    if current_user.social_id and current_user.social_id.startswith('phone$'):
        form = PhoneUserProfileForm(request.form, obj=current_user)
    else:
        form = UserProfileForm(request.form, obj=current_user)
    form.timezone.choices = [
        (x, x) for x in sorted(list(zoneinfo.available_timezones()))
    ]
    form.timezone.default = the_tz
    if str(form.timezone.data) == 'None' or str(form.timezone.data) == '':
        form.timezone.data = the_tz
    if request.method == 'POST' and form.validate():
        if current_user.has_roles(['admin', 'developer']):
            form.populate_obj(current_user)
        else:
            current_user.first_name = form.first_name.data
            current_user.last_name = form.last_name.data
            if current_user.social_id and current_user.social_id.startswith(
                    'phone$'):
                current_user.email = form.email.data
        db.session.commit()
        #docassemble.webapp.daredis.clear_user_cache()
        flash(word('Your information was saved.'), 'success')
        return redirect(url_for('interview_list'))
    response = make_response(
        render_template('users/user_profile_page.html',
                        version_warning=None,
                        page_title=word('User Profile'),
                        tab_title=word('User Profile'),
                        form=form,
                        debug=debug_status()), 200)
    response.headers[
        'Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
    return response
Example #4
0
def user_profile_page():
    the_tz = current_user.timezone if current_user.timezone else get_default_timezone()
    if current_user.social_id and current_user.social_id.startswith('phone$'):
        form = PhoneUserProfileForm(request.form, obj=current_user)
    else:
        form = UserProfileForm(request.form, obj=current_user)
    form.timezone.choices = [(x, x) for x in sorted([tz for tz in pytz.all_timezones])]
    form.timezone.default = the_tz
    if text_type(form.timezone.data) == 'None' or text_type(form.timezone.data) == '':
        form.timezone.data = the_tz
    if request.method == 'POST' and form.validate():
        form.populate_obj(current_user)
        db.session.commit()
        #docassemble.webapp.daredis.clear_user_cache()
        flash(word('Your information was saved.'), 'success')
        return redirect(url_for('interview_list'))
    return render_template('users/user_profile_page.html', version_warning=None, page_title=word('User Profile'), tab_title=word('User Profile'), form=form, debug=debug_status())