diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index 7a0a95feb..bcd47c542 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -22,6 +22,7 @@ @import '../govuk_elements/public/sass/elements/forms'; @import '../govuk_elements/public/sass/elements/forms/form-validation'; @import '../govuk_elements/public/sass/elements/forms/form-block-labels'; +@import '../govuk_elements/public/sass/elements/forms/form-validation'; @import '../govuk_elements/public/sass/elements/icons'; @import '../govuk_elements/public/sass/elements/layout'; @import '../govuk_elements/public/sass/elements/lists'; diff --git a/app/main/forms.py b/app/main/forms.py index e06595ba4..a6315928d 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -1,5 +1,5 @@ from flask_wtf import Form -from wtforms import StringField, PasswordField, ValidationError +from wtforms import StringField, PasswordField, ValidationError, TextAreaField from wtforms.validators import DataRequired, Email, Length, Regexp from app.main.validators import Blacklist, ValidateUserCodes @@ -121,6 +121,19 @@ class AddServiceForm(Form): raise ValidationError('Service name already exists') +class ServiceNameForm(Form): + service_name = StringField(u'New name') + + +class ConfirmPasswordForm(Form): + password = PasswordField(u'Enter password') + + +class TemplateForm(Form): + template_name = StringField(u'Template name') + template_body = TextAreaField(u'Message') + + class ForgotPasswordForm(Form): email_address = email_address() diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 6553a876e..b031fd447 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -2,6 +2,7 @@ from flask import render_template, redirect, request, url_for, abort from flask_login import login_required from app.main import main +from app.main.forms import ConfirmPasswordForm, ServiceNameForm service = { 'name': 'Service name', @@ -20,10 +21,15 @@ def service_settings(): @main.route("/service-settings/name", methods=['GET', 'POST']) def name(): + + form = ServiceNameForm() + form.service_name.data = 'Service name' + if request.method == 'GET': return render_template( 'views/service-settings/name.html', - service=service + service=service, + form=form ) elif request.method == 'POST': return redirect(url_for('.confirm_name_change')) @@ -31,10 +37,14 @@ def name(): @main.route("/service-settings/name/confirm", methods=['GET', 'POST']) def confirm_name_change(): + + form = ConfirmPasswordForm() + if request.method == 'GET': return render_template( 'views/service-settings/confirm.html', - heading='Change your service name' + heading='Change your service name', + form=form ) elif request.method == 'POST': return redirect(url_for('.service_settings')) @@ -64,11 +74,15 @@ def status(): @main.route("/service-settings/status/confirm", methods=['GET', 'POST']) def confirm_status_change(): + + form = ConfirmPasswordForm() + if request.method == 'GET': return render_template( 'views/service-settings/confirm.html', heading='Turn off all outgoing notifications', - destructive=True + destructive=True, + form=form ) elif request.method == 'POST': return redirect(url_for('.service_settings')) @@ -87,11 +101,15 @@ def delete(): @main.route("/service-settings/delete/confirm", methods=['GET', 'POST']) def confirm_delete(): + + form = ConfirmPasswordForm() + if request.method == 'GET': return render_template( 'views/service-settings/confirm.html', heading='Delete this service from Notify', - destructive=True + destructive=True, + form=form ) elif request.method == 'POST': return redirect(url_for('.dashboard')) diff --git a/app/main/views/styleguide.py b/app/main/views/styleguide.py index 516a39b6c..f778f9dcf 100644 --- a/app/main/views/styleguide.py +++ b/app/main/views/styleguide.py @@ -1,7 +1,24 @@ from flask import render_template +from flask_wtf import Form +from wtforms import StringField, PasswordField, TextAreaField, validators from app.main import main @main.route('/_styleguide') def styleguide(): - return render_template('views/styleguide.html') + + class FormExamples(Form): + username = StringField(u'Username') + password = PasswordField(u'Password', [validators.required()]) + message = TextAreaField(u'Message') + + form = FormExamples() + + form.message.data = "Your vehicle tax for ((registration number)) is due on ((date)). Renew online at www.gov.uk/vehicle-tax" # noqa + + form.validate() + + return render_template( + 'views/styleguide.html', + form=form + ) diff --git a/app/main/views/templates.py b/app/main/views/templates.py index ff80cb353..2d7d38e85 100644 --- a/app/main/views/templates.py +++ b/app/main/views/templates.py @@ -1,6 +1,7 @@ from flask import request, render_template, redirect, url_for from app.main import main +from app.main.forms import TemplateForm @main.route("/templates") @@ -10,12 +11,17 @@ def manage_templates(): @main.route("/templates/template", methods=['GET', 'POST']) def add_template(): + + form = TemplateForm() + + form.template_name.data = 'Reminder' + form.template_body.data = 'Vehicle tax: Your vehicle tax for ((registration number)) expires on ((date)). Tax your vehicle at www.gov.uk/vehicle-tax' # noqa + if request.method == 'GET': return render_template( 'views/edit-template.html', - template_name='Reminder', - template_body='Vehicle tax: Your vehicle tax for ((registration number)) expires on ((date)). Tax your vehicle at www.gov.uk/vehicle-tax', # noqa - h1='Edit template' + h1='Edit template', + form=form ) elif request.method == 'POST': return redirect(url_for('.manage_templates')) @@ -23,10 +29,14 @@ def add_template(): @main.route("/templates/template/add", methods=['GET', 'POST']) def edit_template(): + + form = TemplateForm() + if request.method == 'GET': return render_template( 'views/edit-template.html', - h1='Add template' + h1='Add template', + form=form ) elif request.method == 'POST': return redirect(url_for('.manage_templates')) diff --git a/app/templates/admin_template.html b/app/templates/admin_template.html index a03e47612..c127da3f7 100644 --- a/app/templates/admin_template.html +++ b/app/templates/admin_template.html @@ -1,4 +1,3 @@ -{%- from "components/form-field.html" import render_field %} {% extends "govuk_template.html" %} {% block head %} diff --git a/app/templates/components/form-field.html b/app/templates/components/form-field.html deleted file mode 100644 index 691b4c579..000000000 --- a/app/templates/components/form-field.html +++ /dev/null @@ -1,12 +0,0 @@ -{% macro render_field(field) %} -
If you have forgotten your password, we can send you an email to create a new password.
- + diff --git a/app/templates/views/new-password.html b/app/templates/views/new-password.html index 580325410..16c098cb9 100644 --- a/app/templates/views/new-password.html +++ b/app/templates/views/new-password.html @@ -1,4 +1,6 @@ {% extends "admin_template.html" %} +{% from "components/textbox.html" import textbox %} +{% from "components/page-footer.html" import page_footer %} {% block page_title %} GOV.UK Notify @@ -13,17 +15,9 @@ GOV.UK NotifyYou can now create a new password for your account.
- {% else %} Message about email address does not exist. Some one needs to figure out the words here. diff --git a/app/templates/views/register.html b/app/templates/views/register.html index f640ac116..9bb45a3a8 100644 --- a/app/templates/views/register.html +++ b/app/templates/views/register.html @@ -1,4 +1,5 @@ {% extends "admin_template.html" %} +{% from "components/textbox.html" import textbox %} {% from "components/page-footer.html" import page_footer %} {% block page_title %} @@ -16,12 +17,10 @@ GOV.UK Notify | Create an account diff --git a/app/templates/views/service-settings/confirm.html b/app/templates/views/service-settings/confirm.html index fe0cd05c9..20206724c 100644 --- a/app/templates/views/service-settings/confirm.html +++ b/app/templates/views/service-settings/confirm.html @@ -14,7 +14,7 @@ GOV.UK Notify | Service settingsWe've sent you a text message with a verification code.
-We've sent you confirmation codes by email and text message. You need to enter both codes here.
-