Make sure confirmation/danger banners have a H1

This makes errors on all pages have a `<h1>` element, which is important
for accessibility. It means a bit of rewriting the messages, but I think
they’re better for it.
This commit is contained in:
Chris Hill-Scott
2017-07-24 14:50:56 +01:00
parent 40e79c6827
commit befe93ec0b
4 changed files with 53 additions and 47 deletions

View File

@@ -428,22 +428,24 @@ def delete_service_template(service_id, template_id):
last_used_notification = template_statistics_client.get_template_statistics_for_template(
service_id, template['id']
)
message = '{} was last used {} ago'.format(
last_used_notification['template']['name'],
message = 'It was last used {} ago.'.format(
get_human_readable_delta(
parse(last_used_notification['created_at']).replace(tzinfo=None),
datetime.utcnow())
datetime.utcnow()
)
)
except HTTPError as e:
if e.status_code == 404:
message = '{} has never been used'.format(template['name'])
message = 'Its never been used.'.format(template['name'])
else:
raise e
flash('{}. Are you sure you want to delete it?'.format(message), 'delete')
return render_template(
'views/templates/template.html',
template_delete_confirmation_message=(
'Are you sure you want to delete {}?'.format(template['name']),
message,
),
template=get_template(
template,
current_service,

View File

@@ -7,7 +7,7 @@
{% endif %}
>
{% if subhead -%}
{{ subhead }}&ensp;
<h1 class="banner-title">{{ subhead }}</h1>
{%- endif -%}
{{ body }}
{% if delete_button %}

View File

@@ -29,6 +29,20 @@
</div>
{% endif %}
{% if template_delete_confirmation_message %}
<div class="bottom-gutter">
{% call banner_wrapper(type='dangerous', subhead=template_delete_confirmation_message[0]) %}
<p>
{{ template_delete_confirmation_message[1] }}
</p>
<form method='post'>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" class="button" name="delete" value="Confirm" />
</form>
{% endcall %}
</div>
{% endif %}
<h1 class="heading-large">{{ template.name }}</h1>
<div class="grid-row">