Skip to content

Commit 3385e9b

Browse files
authored
Merge pull request #67 from LandRegistry/govuk-frontend-46
GOV.UK Frontend 4.6.0
2 parents 11300ea + a0d949a commit 3385e9b

15 files changed

+114
-95
lines changed

.github/workflows/python-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
14+
python-version: ["3.8", "3.9", "3.10", "3.11"]
1515

1616
steps:
1717
- uses: actions/checkout@v3

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.10
1+
3.11

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GOV.UK Frontend Flask
22

3-
![govuk-frontend 4.5.0](https://img.shields.io/badge/govuk--frontend%20version-4.5.0-005EA5?logo=gov.uk&style=flat)
3+
![govuk-frontend 4.6.0](https://img.shields.io/badge/govuk--frontend%20version-4.6.0-005EA5?logo=gov.uk&style=flat)
44

55
**GOV.UK Frontend Flask is a [community tool](https://design-system.service.gov.uk/community/resources-and-tools/) of the [GOV.UK Design System](https://design-system.service.gov.uk/). The Design System team is not responsible for it and cannot support you with using it. Contact the [maintainers](#contributors) directly if you need [help](#support) or you want to request a feature.**
66

@@ -15,7 +15,7 @@ The app is provided intentionally bare, with just the essential parts that all s
1515

1616
### Required
1717

18-
- Python 3.7.x or higher
18+
- Python 3.8.x or higher
1919

2020
### Optional
2121

app/demos/forms.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,40 +294,46 @@ class KitchenSinkForm(FlaskForm):
294294

295295

296296
class ConditionalRevealForm(FlaskForm):
297-
how_prefer_contacted = RadioField(
297+
contact = RadioField(
298298
"How would you prefer to be contacted?",
299299
widget=GovRadioInput(),
300-
validators=[InputRequired(message="Choose how you would prefer to be contacted")],
300+
validators=[InputRequired(message="Select how you would prefer to be contacted")],
301301
choices=[
302302
("email", "Email"),
303303
("phone", "Phone"),
304-
("text_message", "Text message"),
304+
("text", "Text message"),
305305
],
306306
description="Select one option.",
307307
)
308308

309-
email_address = StringField(
309+
contact_by_email = StringField(
310310
"Email address",
311311
widget=GovTextInput(),
312312
# Set up the validation for each of the conditional fields with a custom RequiredIf validator
313313
# This will mark this field as required if the how_prefer_contacted is set to email
314-
validators=[RequiredIf("how_prefer_contacted", "email", message="Enter an email address")],
314+
validators=[
315+
RequiredIf(
316+
"contact", "email", message="Enter an email address in the correct format, like name@example.com"
317+
)
318+
],
315319
)
316320

317-
phone = StringField(
321+
contact_by_phone = StringField(
318322
"Phone number",
319323
widget=GovTextInput(),
320-
validators=[RequiredIf("how_prefer_contacted", "phone", message="Enter a phone number")],
324+
validators=[
325+
RequiredIf("contact", "phone", message="Enter a telephone number, like 01632 960 001 or +44 808 157 0192")
326+
],
321327
)
322328

323-
mobile_phone = StringField(
329+
contact_by_text = StringField(
324330
"Mobile phone number",
325331
widget=GovTextInput(),
326332
validators=[
327333
RequiredIf(
328-
"how_prefer_contacted",
329-
"text_message",
330-
message="Enter a mobile phone number",
334+
"contact",
335+
"text",
336+
message="Enter a mobile phone number, like 07700 900 982",
331337
)
332338
],
333339
)

app/demos/routes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,33 @@ def forms():
3636
def bank_details():
3737
form = BankDetailsForm()
3838
if form.validate_on_submit():
39-
flash("Form successfully submitted", "success")
40-
return redirect(url_for("main.index"))
39+
flash("Demo form successfully submitted", "success")
40+
return redirect(url_for("demos.forms"))
4141
return render_template("bank_details.html", form=form)
4242

4343

4444
@bp.route("/forms/create-account", methods=["GET", "POST"])
4545
def create_account():
4646
form = CreateAccountForm()
4747
if form.validate_on_submit():
48-
flash("Form successfully submitted", "success")
49-
return redirect(url_for("main.index"))
48+
flash("Demo form successfully submitted", "success")
49+
return redirect(url_for("demos.forms"))
5050
return render_template("create_account.html", form=form)
5151

5252

5353
@bp.route("/forms/kitchen-sink", methods=["GET", "POST"])
5454
def kitchen_sink():
5555
form = KitchenSinkForm()
5656
if form.validate_on_submit():
57-
flash("Form successfully submitted", "success")
58-
return redirect(url_for("main.index"))
57+
flash("Demo form successfully submitted", "success")
58+
return redirect(url_for("demos.forms"))
5959
return render_template("kitchen_sink.html", form=form)
6060

6161

6262
@bp.route("/forms/conditional-reveal", methods=["GET", "POST"])
6363
def conditional_reveal():
6464
form = ConditionalRevealForm()
6565
if form.validate_on_submit():
66-
flash("Form successfully submitted", "success")
67-
return redirect(url_for("main.index"))
66+
flash("Demo form successfully submitted", "success")
67+
return redirect(url_for("demos.forms"))
6868
return render_template("conditional_reveal.html", form=form)

app/templates/base.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<meta name="description" content="{{config['SERVICE_NAME']}}">
1414
<meta name="keywords" content="GOV.UK, govuk, gov, government, uk, frontend, ui, user interface, jinja, python, flask, port, template, templating, macro, component, design system, html, forms, wtf, wtforms, widget, widgets, demo, example">
1515
<meta name="author" content="{{config['DEPARTMENT_NAME']}}">
16-
<!--[if gt IE 8]><!--><link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='govuk-frontend-4.5.0.min.css') }}" /><!--<![endif]-->
17-
<!--[if IE 8]><link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='govuk-frontend-ie8-4.5.0.min.css') }}" /><![endif]-->
16+
<!--[if gt IE 8]><!--><link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='govuk-frontend-4.6.0.min.css') }}" /><!--<![endif]-->
17+
<!--[if IE 8]><link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='govuk-frontend-ie8-4.6.0.min.css') }}" /><![endif]-->
1818
{% assets "css" %}<link href="{{ ASSET_URL }}" rel="stylesheet">{% endassets %}
1919
{% endblock %}
2020

@@ -162,7 +162,7 @@
162162

163163
{% block bodyEnd %}
164164
<!--[if gt IE 8]><!-->
165-
<script src="{{ url_for('static', filename='govuk-frontend-4.5.0.min.js') }}"> </script>
165+
<script src="{{ url_for('static', filename='govuk-frontend-4.6.0.min.js') }}"> </script>
166166
<script>window.GOVUKFrontend.initAll()</script>
167167
<!--<![endif]-->
168168
{% assets "js" %}<script type="text/javascript" src="{{ ASSET_URL }}"></script>{% endassets %}

app/templates/demos/conditional_reveal.html

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,29 @@ <h1 class="govuk-heading-xl">Conditionally revealed inputs</h1>
3535
{{ form.csrf_token }}
3636

3737
<!-- Grab html for conditional fields -->
38-
{% set email_address %}
39-
{{ form.email_address() }}
38+
{% set emailHtml %}
39+
{{ form.contact_by_email(params={
40+
'type': 'email',
41+
'autocomplete': 'email',
42+
'spellcheck': false,
43+
'classes': 'govuk-!-width-one-third'
44+
}) }}
4045
{% endset %}
4146

42-
{% set phone %}
43-
{{ form.phone() }}
47+
{% set phoneHtml %}
48+
{{ form.contact_by_phone(params={
49+
'type': 'tel',
50+
'autocomplete': 'tel',
51+
'classes': 'govuk-!-width-one-third'
52+
}) }}
4453
{% endset %}
4554

46-
{% set mobile_phone %}
47-
{{ form.mobile_phone() }}
55+
{% set textHtml %}
56+
{{ form.contact_by_text(params={
57+
'type': 'tel',
58+
'autocomplete': 'tel',
59+
'classes': 'govuk-!-width-one-third'
60+
}) }}
4861
{% endset %}
4962

5063
<!--
@@ -58,21 +71,21 @@ <h1 class="govuk-heading-xl">Conditionally revealed inputs</h1>
5871
The field definition in ConditionalRevealForm has three options.
5972
Therefore we have an array of three items here to match.
6073
-->
61-
{{ form.how_prefer_contacted(params={
74+
{{ form.contact(params={
6275
'items': [
6376
{
6477
'conditional': {
65-
'html': email_address
78+
'html': emailHtml
6679
}
6780
},
6881
{
6982
'conditional': {
70-
'html': phone
83+
'html': phoneHtml
7184
}
7285
},
7386
{
7487
'conditional': {
75-
'html': mobile_phone
88+
'html': textHtml
7689
}
7790
}
7891
]

app/templates/demos/forms.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
{% block content %}
2323
<div class="govuk-grid-row">
2424
<div class="govuk-grid-column-two-thirds">
25+
{{ super() }}
2526
<span class="govuk-caption-xl">Demo</span>
2627
<h1 class="govuk-heading-l">Forms</h1>
2728
<ul class="govuk-list govuk-list--bullet">

build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ rm -rf app/static/images
44
rm -rf app/static/govuk-frontend*
55

66
# Get new release distribution assets and move to static directory
7-
curl -L https://github.com/alphagov/govuk-frontend/releases/download/v4.5.0/release-v4.5.0.zip > govuk_frontend.zip
7+
curl -L https://github.com/alphagov/govuk-frontend/releases/download/v4.6.0/release-v4.6.0.zip > govuk_frontend.zip
88
unzip -o govuk_frontend.zip -d app/static
99
mv app/static/assets/* app/static
1010

@@ -21,10 +21,10 @@ rm -rf govuk_frontend.zip
2121
rm -rf govuk_components
2222

2323
# Get new release source code and move to a directory
24-
curl -L https://github.com/alphagov/govuk-frontend/archive/v4.5.0.zip > govuk_frontend_source.zip
24+
curl -L https://github.com/alphagov/govuk-frontend/archive/v4.6.0.zip > govuk_frontend_source.zip
2525
unzip -o govuk_frontend_source.zip -d govuk_frontend_source
2626
mkdir govuk_components
27-
mv govuk_frontend_source/govuk-frontend-4.5.0/package/govuk/components/** govuk_components
27+
mv govuk_frontend_source/govuk-frontend-4.6.0/package/govuk/components/** govuk_components
2828

2929
# Remove all files apart from test fixtures json
3030
find govuk_components -type f ! -name 'fixtures.json' -delete

requirements.in

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
cssmin==0.2.0
2-
email_validator==1.3.1
2+
email_validator==2.0.0.post2
33
flask-assets==2.0
44
flask-compress==1.13
5-
flask-limiter==3.2.0
5+
flask-limiter==3.3.0
66
flask-talisman==1.0.0
7-
flask==2.2.3
8-
govuk-frontend-jinja==2.5.0
9-
govuk-frontend-wtf==2.3.0
7+
flask==2.3.1
8+
govuk-frontend-jinja==2.6.0
9+
govuk-frontend-wtf==2.4.0
1010
gunicorn==20.1.0
1111
jsmin==3.0.1
12-
python-dotenv==0.21.1
13-
redis==4.5.1
12+
python-dotenv==1.0.0
13+
redis==4.5.4

requirements.txt

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.10
2+
# This file is autogenerated by pip-compile with Python 3.11
33
# by the following command:
44
#
55
# pip-compile requirements.in
66
#
77
async-timeout==4.0.2
88
# via redis
9+
blinker==1.6.2
10+
# via flask
911
brotli==1.0.9
1012
# via flask-compress
1113
click==8.1.3
@@ -18,9 +20,9 @@ deprecated==1.2.13
1820
# via limits
1921
dnspython==2.3.0
2022
# via email-validator
21-
email-validator==1.3.1
23+
email-validator==2.0.0.post2
2224
# via -r requirements.in
23-
flask==2.2.3
25+
flask==2.3.1
2426
# via
2527
# -r requirements.in
2628
# flask-assets
@@ -32,22 +34,24 @@ flask-assets==2.0
3234
# via -r requirements.in
3335
flask-compress==1.13
3436
# via -r requirements.in
35-
flask-limiter==3.2.0
37+
flask-limiter==3.3.0
3638
# via -r requirements.in
3739
flask-talisman==1.0.0
3840
# via -r requirements.in
3941
flask-wtf==1.1.1
4042
# via govuk-frontend-wtf
41-
govuk-frontend-jinja==2.5.0
43+
govuk-frontend-jinja==2.6.0
4244
# via
4345
# -r requirements.in
4446
# govuk-frontend-wtf
45-
govuk-frontend-wtf==2.3.0
47+
govuk-frontend-wtf==2.4.0
4648
# via -r requirements.in
4749
gunicorn==20.1.0
4850
# via -r requirements.in
4951
idna==3.4
5052
# via email-validator
53+
importlib-resources==5.12.0
54+
# via limits
5155
itsdangerous==2.1.2
5256
# via
5357
# flask
@@ -59,9 +63,9 @@ jinja2==3.1.2
5963
# govuk-frontend-wtf
6064
jsmin==3.0.1
6165
# via -r requirements.in
62-
limits==3.2.0
66+
limits==3.4.0
6367
# via flask-limiter
64-
markdown-it-py==2.1.0
68+
markdown-it-py==2.2.0
6569
# via rich
6670
markupsafe==2.1.2
6771
# via
@@ -72,25 +76,25 @@ mdurl==0.1.2
7276
# via markdown-it-py
7377
ordered-set==4.1.0
7478
# via flask-limiter
75-
packaging==23.0
79+
packaging==23.1
7680
# via limits
77-
pygments==2.14.0
81+
pygments==2.15.1
7882
# via rich
79-
python-dotenv==0.21.1
83+
python-dotenv==1.0.0
8084
# via -r requirements.in
81-
redis==4.5.1
85+
redis==4.5.4
8286
# via -r requirements.in
83-
rich==13.3.1
87+
rich==13.3.4
8488
# via flask-limiter
8589
typing-extensions==4.5.0
8690
# via
8791
# flask-limiter
8892
# limits
8993
webassets==2.0
9094
# via flask-assets
91-
werkzeug==2.2.3
95+
werkzeug==2.3.0
9296
# via flask
93-
wrapt==1.14.1
97+
wrapt==1.15.0
9498
# via deprecated
9599
wtforms==3.0.1
96100
# via

requirements_dev.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
bandit==1.7.4
1+
bandit==1.7.5
22
black==22.12.0
3-
flake8-bugbear==23.2.13
3+
flake8-bugbear==23.3.23
44
isort==5.12.0
55
pep8-naming==0.13.3
6-
pip-tools==6.12.2
7-
pur==7.0.0
6+
pip-tools==6.13.0
7+
pur==7.1.0
88
pytest-cov==4.0.0
99
safety==2.3.5

0 commit comments

Comments
 (0)