aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views
diff options
context:
space:
mode:
Diffstat (limited to 'pyaggr3g470r/views')
-rw-r--r--pyaggr3g470r/views/views.py14
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)
bgstack15