summaryrefslogtreecommitdiffstats
path: root/app.py
diff options
context:
space:
mode:
authorMarian Sigler <m@qjym.de>2012-10-01 01:39:17 +0200
committerMarian Sigler <m@qjym.de>2012-10-01 01:39:17 +0200
commit1cf89afc3c3d7fc9735597c768501ede19206a69 (patch)
tree23b8e08adfe8d0ed4e62936d12e12121dbffef5f /app.py
parente712284e6dacc85677da480ff0be03c524d85d9a (diff)
downloadweb-1cf89afc3c3d7fc9735597c768501ede19206a69.tar.gz
web-1cf89afc3c3d7fc9735597c768501ede19206a69.tar.bz2
web-1cf89afc3c3d7fc9735597c768501ede19206a69.zip
Add admin panel: Allow creation of usernames that are in the blacklist.
Diffstat (limited to 'app.py')
-rw-r--r--app.py51
1 files changed, 39 insertions, 12 deletions
diff --git a/app.py b/app.py
index 2754b96..ccbc5dc 100644
--- a/app.py
+++ b/app.py
@@ -84,17 +84,7 @@ def register():
#TODO: check for double mails
form = RegisterForm(request.form, csrf_enabled=False)
if request.method == 'POST' and form.validate():
- username = form.username.data
- mail = form.mail.data
-
- confirm_token = make_confirmation('register', (username, mail))
- confirm_link = url_for('register_complete', token=confirm_token, _external=True)
-
- body = render_template('mail/register.txt', username=username,
- mail=mail, link=confirm_link)
-
- send_mail(mail, u'E-Mail-Adresse bestätigen', body,
- sender=app.config.get('MAIL_CONFIRM_SENDER'))
+ send_register_confirmation_mail(form.username.data, form.mail.data)
flash(u'Es wurde eine E-Mail an die angegebene Adresse geschickt, '
u'um diese zu überprüfen. Bitte folge den Anweisungen in der '
@@ -277,6 +267,43 @@ def about():
return {}
+@app.route('/admin')
+@templated('admin_index.html')
+def admin():
+ return {}
+
+
+@app.route('/admin/create_account', methods=['GET', 'POST'])
+@templated('admin_create_account.html')
+@admin_required
+def admin_create_account():
+ form = AdminCreateAccountForm()
+ if request.method == 'POST' and form.validate():
+ send_register_confirmation_mail(form.username.data, form.mail.data)
+
+ flash(u'Mail versandt.', 'success')
+ return redirect(url_for('index'))
+ return {'form': form}
+
+@app.route('/admin/view_blacklist')
+@app.route('/admin/view_blacklist/<start>')
+@templated('admin_view_blacklist.html')
+@admin_required
+def admin_view_blacklist(start=''):
+ entries = app.username_blacklist
+ if start:
+ entries = [e for e in entries if e.startswith(start)]
+
+ next_letters = set(e[len(start)] for e in entries if len(e) > len(start))
+
+ return {
+ 'entries': entries,
+ 'start': start,
+ 'next_letters': next_letters,
+ }
+
+
+
@app.errorhandler(403)
@app.errorhandler(404)
def errorhandler(e):
@@ -290,7 +317,7 @@ def debug():
# we need the app to exist before initializing the forms
from forms import RegisterForm, RegisterCompleteForm, LoginForm, SettingsForm,\
- LostPasswordForm
+ LostPasswordForm, AdminCreateAccountForm
if __name__ == '__main__':