From 2fb589342b8ec84e07ea94fa9db008e1bf19b09e Mon Sep 17 00:00:00 2001 From: Drew Short Date: Wed, 30 Jan 2019 12:11:50 -0600 Subject: [PATCH] Linking to registration page + URL params autofill * Added registrationCode url param to the registration page to autofill the code * Added a link column to the admin registration code table for easy copying of registration links --- app.py | 7 +++++-- templates/admin.html | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 0ac759f..eed745d 100644 --- a/app.py +++ b/app.py @@ -10,7 +10,7 @@ from flask_login import LoginManager, login_required, login_user, logout_user, U from flask_wtf import CSRFProtect from db import get_db, get_registration_codes, add_registration_code, \ - expire_registration_code, delete_registration_code + expire_registration_code, delete_registration_code, get_registered_users from forms import RegistrationForm, LoginForm, RegistrationCodeForm, \ ExpireRegistrationCodeForm @@ -93,6 +93,8 @@ def registration(): form = RegistrationForm() if form.validate_on_submit(): return redirect('/success') + if 'registrationCode' in request.values: + form.registration_code.data = request.values['registrationCode'] return render_template('register.html', form=form) @@ -101,7 +103,8 @@ def registration(): def admin_index(): context = { 'add_registration_code_form': RegistrationCodeForm(), - 'registration_codes': get_registration_codes() + 'registration_codes': get_registration_codes(), + 'registered_users': get_registered_users() } return render_template('admin.html', **context) diff --git a/templates/admin.html b/templates/admin.html index 6d90cf9..52a2b5c 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -13,6 +13,7 @@ Expiration Time Usages Max Usages + Registration Link Expire @@ -23,6 +24,7 @@ {{ registration_code.expiration_time|tojson|safe }} {{ registration_code.usages|tojson|safe }} {{ registration_code.max_usages|tojson|safe }} + link
@@ -40,6 +42,23 @@
+
+ + + + + + + {% for registered_user in registered_users %} + + + + + {% endfor %} + +
UserRegistration Time
{{ registered_user.username|tojson|safe }}{{ registered_user.registration_time|tojson|safe }}
+
+
{{ add_registration_code_form.csrf_token }} {{ add_registration_code_form.expiration_time.label }} {{ add_registration_code_form.expiration_time() }}