mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
109526520: render verify template with VerifyForm
This commit is contained in:
@@ -3,4 +3,4 @@ from flask import Blueprint
|
||||
main = Blueprint('main', __name__)
|
||||
|
||||
|
||||
from app.main.views import index, sign_in, register
|
||||
from app.main.views import index, sign_in, register, verify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from flask_wtf import Form
|
||||
from wtforms import StringField, PasswordField
|
||||
from wtforms import StringField, PasswordField, IntegerField
|
||||
from wtforms.validators import DataRequired, Email, Length, Regexp
|
||||
|
||||
from app.main.validators import Blacklist
|
||||
@@ -36,3 +36,8 @@ class RegisterUserForm(Form):
|
||||
validators=[DataRequired(message='Please enter your password'),
|
||||
Length(10, 255, message='Password must be at least 10 characters'),
|
||||
Blacklist(message='That password is blacklisted, too common')])
|
||||
|
||||
|
||||
class VerifyForm(Form):
|
||||
sms_code = IntegerField(DataRequired(message='SMS code can not be empty'))
|
||||
email_code = IntegerField(DataRequired(message='Email code can not be empty'))
|
||||
|
||||
@@ -19,11 +19,6 @@ def registerfrominvite():
|
||||
return render_template('register-from-invite.html')
|
||||
|
||||
|
||||
@main.route("/verify")
|
||||
def verify():
|
||||
return render_template('verify.html')
|
||||
|
||||
|
||||
@main.route("/verify-mobile")
|
||||
def verifymobile():
|
||||
return render_template('verify-mobile.html')
|
||||
|
||||
19
app/main/views/verify.py
Normal file
19
app/main/views/verify.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from app.main import main
|
||||
from flask import render_template, redirect, jsonify
|
||||
|
||||
from app.main.forms import VerifyForm
|
||||
|
||||
|
||||
@main.route('/verify', methods=['GET'])
|
||||
def render_verify():
|
||||
return render_template('verify.html', form=VerifyForm())
|
||||
|
||||
|
||||
@main.route('/verify', methods=['POST'])
|
||||
def process_verify():
|
||||
form = VerifyForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
return redirect('/add-service')
|
||||
else:
|
||||
return jsonify(form.errors), 400
|
||||
7
tests/app/main/views/test_verify.py
Normal file
7
tests/app/main/views/test_verify.py
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
def test_should_return_verify_template(notifications_admin, notifications_admin_db):
|
||||
response = notifications_admin.test_client().get('/verify')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Activate your account' in response.get_data(as_text=True)
|
||||
Reference in New Issue
Block a user