summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2016-02-02 04:32:34 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2016-02-02 04:44:18 +0100
commitbb9a6c6a384e02364e4eb10ef560b4fd4f05e5f0 (patch)
treedbc7e86656921b1e71b8c14a8d2802eade8ae645
parent2f06faee7523df0f17ccfc4d3c568295734336c2 (diff)
downloadweb-bb9a6c6a384e02364e4eb10ef560b4fd4f05e5f0.tar.gz
web-bb9a6c6a384e02364e4eb10ef560b4fd4f05e5f0.tar.bz2
web-bb9a6c6a384e02364e4eb10ef560b4fd4f05e5f0.zip
forms: No need to supply request.form to the Forms
The wtforms classes get the request data by default.
-rw-r--r--accounts/views/admin/__init__.py5
-rw-r--r--accounts/views/default/__init__.py10
2 files changed, 8 insertions, 7 deletions
diff --git a/accounts/views/admin/__init__.py b/accounts/views/admin/__init__.py
index d008d98..5c908a1 100644
--- a/accounts/views/admin/__init__.py
+++ b/accounts/views/admin/__init__.py
@@ -32,7 +32,7 @@ def index():
@templated('admin/create_account.html')
def create_account():
form = AdminCreateAccountForm()
- if request.method == 'POST' and form.validate():
+ if form.validate_on_submit():
current_app.mail_backend.send(form.mail.data, 'mail/register.txt',
username=form.username.data)
@@ -64,7 +64,8 @@ def disable_account():
form = AdminDisableAccountForm()
if 'uid' in request.args:
form = AdminDisableAccountForm(username=request.args['uid'])
- if request.method == 'POST' and form.validate():
+
+ if form.validate_on_submit():
random_pw = str(uuid4())
form.user.change_password(random_pw)
for service in current_app.all_services:
diff --git a/accounts/views/default/__init__.py b/accounts/views/default/__init__.py
index eec173e..a3e6c0e 100644
--- a/accounts/views/default/__init__.py
+++ b/accounts/views/default/__init__.py
@@ -21,7 +21,7 @@ bp = Blueprint('default', __name__)
@templated('register.html')
@logout_required
def register():
- form = RegisterForm(request.form)
+ form = RegisterForm()
if form.validate_on_submit():
current_app.mail_backend.send(form.mail.data, 'mail/register.txt',
username=form.username.data)
@@ -51,7 +51,7 @@ def register_complete(token):
flash(u'Du hast den Benutzer bereits angelegt! Du kannst dich jetzt einfach einloggen:')
return redirect(url_for('.index'))
- form = RegisterCompleteForm(request.form)
+ form = RegisterCompleteForm()
if form.validate_on_submit():
password = form.password.data
@@ -79,7 +79,7 @@ def register_complete(token):
@templated('lost_password.html')
@logout_required
def lost_password():
- form = LostPasswordForm(request.form)
+ form = LostPasswordForm()
if form.validate_on_submit():
#TODO: make the link only usable once (e.g include a hash of the old pw)
# atm the only thing we do is make the link valid for only little time
@@ -100,7 +100,7 @@ def lost_password():
def lost_password_complete(token):
username = Confirmation('lost_password').loads_http(token, max_age=4*60*60)
- form = RegisterCompleteForm(request.form)
+ form = RegisterCompleteForm()
if form.validate_on_submit():
user = current_app.user_backend.get_by_uid(username)
user.change_password(form.password.data)
@@ -121,7 +121,7 @@ def lost_password_complete(token):
@templated('index.html')
@login_required
def index():
- form = SettingsForm(request.form, mail=current_user.mail)
+ form = SettingsForm(mail=current_user.mail)
if form.validate_on_submit():
changed = False