Beispiel #1
0
def profile():
    user = User.query.filter(User.id == current_user.id).first()
    form = ProfileForm()
    # form.set_languages_choice()

    if request.method == 'POST':
        if form.validate():
            # update user

            if form.password.data and \
                form.password.data == form.password_conf.data:
                user.set_password(form.password.data)

            form.populate_obj(user)
            db.session.commit()

            flash('User successfully updated', 'success')
            return redirect(url_for('user_bp.profile'))
        else:
            flash('User update failed', 'danger')
            return render_template(
                'profile.html',
                user=user,
                form=form,
                humanitarian_id_auth_uri=conf.HUMANITARIAN_ID_AUTH_URI,
                humanitarian_id_app_uri=conf.HUMANITARIAN_ID_APP_URI)

    if request.method == 'GET':
        form = ProfileForm(obj=user)
        return render_template(
            'profile.html',
            user=user,
            form=form,
            humanitarian_id_auth_uri=conf.HUMANITARIAN_ID_AUTH_URI,
            humanitarian_id_app_uri=conf.HUMANITARIAN_ID_APP_URI)
Beispiel #2
0
def profile():
    user = User.query.filter(User.id == current_user.id).first()
    form = ProfileForm()
    form.set_languages_choice()

    if request.method == 'POST':
        if form.validate():
            # update user
            form.populate_obj(user)

            if form.password.data and \
                form.password.data == form.password_conf.data:
                user.set_password(form.password.data)

            db.session.commit()

            flash('User successfully updated', 'success')
            return redirect(url_for('user_bp.profile'))
        else:
            return render_template('profile.html', user=user, form=form)

    if request.method == 'GET':
        form = ProfileForm(obj=user)
        form.set_languages_choice()
        return render_template('profile.html', user=user, form=form)
Beispiel #3
0
def profile():
    user = User.query.filter(User.id==current_user.id).first()
    form = ProfileForm()
    # form.set_languages_choice()

    if request.method == 'POST':
        if form.validate():
            # update user

            if form.password.data and \
                form.password.data == form.password_conf.data:
                user.set_password(form.password.data)

            form.populate_obj(user)
            db.session.commit()

            flash('User successfully updated', 'success')
            return redirect(url_for('user_bp.profile'))
        else:
            flash('User update failed', 'danger')
            return render_template(
                    'profile.html', user=user, form=form,
                    humanitarian_id_auth_uri=conf.HUMANITARIAN_ID_AUTH_URI,
                    humanitarian_id_app_uri=conf.HUMANITARIAN_ID_APP_URI)

    if request.method == 'GET':
        form = ProfileForm(obj=user)
        return render_template(
                'profile.html', user=user, form=form,
                humanitarian_id_auth_uri=conf.HUMANITARIAN_ID_AUTH_URI,
                humanitarian_id_app_uri=conf.HUMANITARIAN_ID_APP_URI)
Beispiel #4
0
def form():
    user = User.query.filter(User.id == current_user.id).first()
    form = ProfileForm(obj=user)
    form.populate_obj(current_user)
    action = "Edit user"
    head_titles = [action]
    head_titles.append(user.login)
    return render_template('edit_user.html', action=action,
                           head_titles=head_titles,
                           form=form, user=user)
Beispiel #5
0
def process_form():
    form = ProfileForm()

    if not form.validate():
        return render_template('edit_user.html', form=form)

    user = User.query.filter(User.id == current_user.id).first()
    form.populate_obj(user)
    if form.password.data:
        user.pwdhash = generate_password_hash(form.password.data)
    db.session.commit()
    flash('User {} successfully updated.'.
                format(form.login.data), 'success')
    return redirect(url_for('admin_bp.form_user', user_id=user.id))