2018-02-20 11:22:17 +00:00
|
|
|
|
from flask import abort, current_app, render_template
|
2017-07-26 10:59:10 +01:00
|
|
|
|
from flask_wtf import FlaskForm as Form
|
2020-04-15 17:58:57 +01:00
|
|
|
|
from notifications_utils.template import SMSPreviewTemplate
|
2018-02-20 11:22:17 +00:00
|
|
|
|
from wtforms import (
|
|
|
|
|
|
FileField,
|
|
|
|
|
|
PasswordField,
|
|
|
|
|
|
StringField,
|
|
|
|
|
|
TextAreaField,
|
|
|
|
|
|
validators,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2016-01-11 11:13:06 +00:00
|
|
|
|
from app.main import main
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@main.route('/_styleguide')
|
|
|
|
|
|
def styleguide():
|
2016-01-11 13:15:10 +00:00
|
|
|
|
|
2016-02-15 11:47:54 +00:00
|
|
|
|
if not current_app.config['SHOW_STYLEGUIDE']:
|
|
|
|
|
|
abort(404)
|
|
|
|
|
|
|
2016-01-11 13:15:10 +00:00
|
|
|
|
class FormExamples(Form):
|
|
|
|
|
|
username = StringField(u'Username')
|
|
|
|
|
|
password = PasswordField(u'Password', [validators.required()])
|
2016-02-15 11:32:27 +00:00
|
|
|
|
code = StringField('Enter code')
|
2016-01-11 13:15:10 +00:00
|
|
|
|
message = TextAreaField(u'Message')
|
2016-02-02 17:28:30 +00:00
|
|
|
|
file_upload = FileField('Upload a CSV file to add your recipients’ details')
|
2016-01-11 13:15:10 +00:00
|
|
|
|
|
2016-02-21 11:15:15 +00:00
|
|
|
|
sms = "Your vehicle tax for ((registration number)) is due on ((date)). Renew online at www.gov.uk/vehicle-tax"
|
2016-01-11 13:15:10 +00:00
|
|
|
|
|
2016-02-21 11:15:15 +00:00
|
|
|
|
form = FormExamples()
|
|
|
|
|
|
form.message.data = sms
|
2016-01-11 13:15:10 +00:00
|
|
|
|
form.validate()
|
|
|
|
|
|
|
2020-04-15 17:58:57 +01:00
|
|
|
|
template = SMSPreviewTemplate({'content': sms, 'template_type': 'sms'})
|
2016-02-21 11:15:15 +00:00
|
|
|
|
|
2016-01-11 13:15:10 +00:00
|
|
|
|
return render_template(
|
|
|
|
|
|
'views/styleguide.html',
|
2016-02-21 11:15:15 +00:00
|
|
|
|
form=form,
|
|
|
|
|
|
template=template
|
2016-01-11 13:15:10 +00:00
|
|
|
|
)
|