diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2015-04-12 21:57:20 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2015-04-12 21:57:20 +0200 |
commit | 38bf1d1ab57df154ba4de31b2c7e85a972a5289e (patch) | |
tree | 5e155a5721bff91639bc930eb4c46e1da6302376 /pyaggr3g470r/views/views.py | |
parent | Typo. (diff) | |
download | newspipe-38bf1d1ab57df154ba4de31b2c7e85a972a5289e.tar.gz newspipe-38bf1d1ab57df154ba4de31b2c7e85a972a5289e.tar.bz2 newspipe-38bf1d1ab57df154ba4de31b2c7e85a972a5289e.zip |
Fixed a bug when creating a new user via the dashboard. An other little improvement for the main menu.
Diffstat (limited to 'pyaggr3g470r/views/views.py')
-rw-r--r-- | pyaggr3g470r/views/views.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py index b71fcbcc..577ae59d 100644 --- a/pyaggr3g470r/views/views.py +++ b/pyaggr3g470r/views/views.py @@ -49,8 +49,9 @@ import conf from pyaggr3g470r import utils, notifications, export from pyaggr3g470r.models import User, Feed, Article, Role from pyaggr3g470r.decorators import feed_access_required -from pyaggr3g470r.forms import SignupForm, SigninForm, AddFeedForm, \ - ProfileForm, InformationMessageForm, RecoverPasswordForm +from pyaggr3g470r.forms import SignupForm, SigninForm, \ + ProfileForm, UserForm, RecoverPasswordForm, \ + AddFeedForm, InformationMessageForm from pyaggr3g470r.controllers import UserController, FeedController, \ ArticleController if not conf.ON_HEROKU: @@ -685,10 +686,11 @@ def create_user(user_id=None): """ Create or edit a user. """ - form = ProfileForm() + form = UserForm() if request.method == 'POST': if form.validate(): + print("Form validated...") role_user = Role.query.filter(Role.name == "user").first() if user_id is not None: # Edit a user @@ -700,6 +702,7 @@ def create_user(user_id=None): flash(gettext('User') + ' ' + user.nickname + ' ' + gettext('successfully updated.'), 'success') else: # Create a new user + print("A new user...") user = User(nickname=form.nickname.data, email=form.email.data, pwdhash=generate_password_hash(form.password.data)) @@ -710,15 +713,16 @@ def create_user(user_id=None): flash(gettext('User') + ' ' + user.nickname + ' ' + gettext('successfully created.'), 'success') return redirect("/admin/edit_user/"+str(user.id)) else: + print("Problem with the form") return redirect(url_for('create_user')) if request.method == 'GET': if user_id is not None: user = User.query.filter(User.id == user_id).first() - form = ProfileForm(obj=user) + form = UserForm(obj=user) message = gettext('Edit the user') + ' <i>' + user.nickname + '</i>' else: - form = ProfileForm() + form = UserForm() message = gettext('Add a new user') return render_template('/admin/create_user.html', form=form, message=message) |