mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Push one fix idea for multiple forms
This commit is contained in:
parent
755f5f3137
commit
61545ed4ec
@ -1,9 +1,9 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import (PasswordField, StringField, SubmitField,
|
||||
ValidationError, BooleanField)
|
||||
from wtforms.validators import DataRequired, EqualTo, Length, Email
|
||||
from wtforms.validators import DataRequired, EqualTo, Email
|
||||
from ..models import User
|
||||
import logging
|
||||
|
||||
|
||||
class ChangePasswordForm(FlaskForm):
|
||||
"""
|
||||
|
@ -45,14 +45,24 @@ def profile_change_password():
|
||||
@login_required
|
||||
def profile_edit_user_info():
|
||||
edit_user_info_form = EditProfileForm(user=current_user)
|
||||
if not edit_user_info_form.validate_on_submit():
|
||||
abort(400)
|
||||
current_user.email = edit_user_info_form.email.data
|
||||
db.session.add(current_user._get_current_object())
|
||||
db.session.commit()
|
||||
flash('Your email has been updated.')
|
||||
if edit_user_info_form.validate_on_submit():
|
||||
current_user.email = edit_user_info_form.email.data
|
||||
db.session.add(current_user._get_current_object())
|
||||
db.session.commit()
|
||||
flash('Your email has been updated.')
|
||||
else:
|
||||
logger.warning('Form: {}'.format(edit_user_info_form.errors))
|
||||
return render_template('profile/index.html.j2',
|
||||
change_password_form=ChangePasswordForm(),
|
||||
edit_user_info_form=edit_user_info_form,
|
||||
edit_user_settings_form=EditUserSettingsForm(),
|
||||
title='Profile')
|
||||
edit_user_info_form.email.data = current_user.email
|
||||
return redirect(url_for('profile.index'))
|
||||
return render_template('profile/index.html.j2',
|
||||
change_password_form=ChangePasswordForm(),
|
||||
edit_user_info_form=EditProfileForm(user=current_user),
|
||||
edit_user_settings_form=EditUserSettingsForm(),
|
||||
title='Profile')
|
||||
|
||||
|
||||
@profile.route('/edit_user_settings', methods=['POST'])
|
||||
|
Loading…
Reference in New Issue
Block a user