mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-10 18:22:37 -04:00
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:
@@ -428,22 +428,24 @@ def delete_service_template(service_id, template_id):
|
|||||||
last_used_notification = template_statistics_client.get_template_statistics_for_template(
|
last_used_notification = template_statistics_client.get_template_statistics_for_template(
|
||||||
service_id, template['id']
|
service_id, template['id']
|
||||||
)
|
)
|
||||||
message = '{} was last used {} ago'.format(
|
message = 'It was last used {} ago.'.format(
|
||||||
last_used_notification['template']['name'],
|
|
||||||
get_human_readable_delta(
|
get_human_readable_delta(
|
||||||
parse(last_used_notification['created_at']).replace(tzinfo=None),
|
parse(last_used_notification['created_at']).replace(tzinfo=None),
|
||||||
datetime.utcnow())
|
datetime.utcnow()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
if e.status_code == 404:
|
if e.status_code == 404:
|
||||||
message = '{} has never been used'.format(template['name'])
|
message = 'It’s never been used.'.format(template['name'])
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
flash('{}. Are you sure you want to delete it?'.format(message), 'delete')
|
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'views/templates/template.html',
|
'views/templates/template.html',
|
||||||
|
template_delete_confirmation_message=(
|
||||||
|
'Are you sure you want to delete {}?'.format(template['name']),
|
||||||
|
message,
|
||||||
|
),
|
||||||
template=get_template(
|
template=get_template(
|
||||||
template,
|
template,
|
||||||
current_service,
|
current_service,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
>
|
>
|
||||||
{% if subhead -%}
|
{% if subhead -%}
|
||||||
{{ subhead }} 
|
<h1 class="banner-title">{{ subhead }}</h1>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{{ body }}
|
{{ body }}
|
||||||
{% if delete_button %}
|
{% if delete_button %}
|
||||||
|
|||||||
@@ -29,6 +29,20 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% 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>
|
<h1 class="heading-large">{{ template.name }}</h1>
|
||||||
|
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
|
|||||||
@@ -679,16 +679,10 @@ def test_should_redirect_when_saving_a_template_email(
|
|||||||
|
|
||||||
|
|
||||||
def test_should_show_delete_template_page_with_time_block(
|
def test_should_show_delete_template_page_with_time_block(
|
||||||
logged_in_client,
|
client_request,
|
||||||
api_user_active,
|
|
||||||
mock_login,
|
|
||||||
mock_get_service,
|
|
||||||
mock_get_service_template,
|
mock_get_service_template,
|
||||||
mock_get_user,
|
|
||||||
mock_get_user_by_email,
|
|
||||||
mock_has_permissions,
|
|
||||||
fake_uuid,
|
|
||||||
mocker,
|
mocker,
|
||||||
|
fake_uuid
|
||||||
):
|
):
|
||||||
with freeze_time('2012-01-01 12:00:00'):
|
with freeze_time('2012-01-01 12:00:00'):
|
||||||
template = template_json('1234', '1234', "Test template", "sms", "Something very interesting")
|
template = template_json('1234', '1234', "Test template", "sms", "Something very interesting")
|
||||||
@@ -698,30 +692,25 @@ def test_should_show_delete_template_page_with_time_block(
|
|||||||
return_value=notification)
|
return_value=notification)
|
||||||
|
|
||||||
with freeze_time('2012-01-01 12:10:00'):
|
with freeze_time('2012-01-01 12:10:00'):
|
||||||
service_id = fake_uuid
|
page = client_request.get(
|
||||||
template_id = fake_uuid
|
|
||||||
response = logged_in_client.get(url_for(
|
|
||||||
'.delete_service_template',
|
'.delete_service_template',
|
||||||
service_id=service_id,
|
service_id=SERVICE_ONE_ID,
|
||||||
template_id=template_id))
|
template_id=fake_uuid,
|
||||||
content = response.get_data(as_text=True)
|
_test_page_title=False,
|
||||||
assert response.status_code == 200
|
)
|
||||||
assert 'Test template was last used 10 minutes ago. Are you sure you want to delete it?' in content
|
assert page.h1.text == 'Are you sure you want to delete Two week reminder?'
|
||||||
assert 'Are you sure' in content
|
assert normalize_spaces(page.select('.banner-dangerous p')[0].text) == (
|
||||||
assert 'Two week reminder' in content
|
'It was last used 10 minutes ago.'
|
||||||
assert 'Template <em>content</em> with & entity' in content
|
)
|
||||||
mock_get_service_template.assert_called_with(service_id, template_id)
|
assert normalize_spaces(page.select('.sms-message-wrapper')[0].text) == (
|
||||||
|
'service one: Template <em>content</em> with & entity'
|
||||||
|
)
|
||||||
|
mock_get_service_template.assert_called_with(SERVICE_ONE_ID, fake_uuid)
|
||||||
|
|
||||||
|
|
||||||
def test_should_show_delete_template_page_with_never_used_block(
|
def test_should_show_delete_template_page_with_never_used_block(
|
||||||
logged_in_client,
|
client_request,
|
||||||
api_user_active,
|
|
||||||
mock_login,
|
|
||||||
mock_get_service,
|
|
||||||
mock_get_service_template,
|
mock_get_service_template,
|
||||||
mock_get_user,
|
|
||||||
mock_get_user_by_email,
|
|
||||||
mock_has_permissions,
|
|
||||||
fake_uuid,
|
fake_uuid,
|
||||||
mocker,
|
mocker,
|
||||||
):
|
):
|
||||||
@@ -729,20 +718,20 @@ def test_should_show_delete_template_page_with_never_used_block(
|
|||||||
'app.template_statistics_client.get_template_statistics_for_template',
|
'app.template_statistics_client.get_template_statistics_for_template',
|
||||||
side_effect=HTTPError(response=Mock(status_code=404), message="Default message")
|
side_effect=HTTPError(response=Mock(status_code=404), message="Default message")
|
||||||
)
|
)
|
||||||
service_id = fake_uuid
|
page = client_request.get(
|
||||||
template_id = fake_uuid
|
|
||||||
response = logged_in_client.get(url_for(
|
|
||||||
'.delete_service_template',
|
'.delete_service_template',
|
||||||
service_id=service_id,
|
service_id=SERVICE_ONE_ID,
|
||||||
template_id=template_id))
|
template_id=fake_uuid,
|
||||||
|
_test_page_title=False,
|
||||||
content = response.get_data(as_text=True)
|
)
|
||||||
assert response.status_code == 200
|
assert page.h1.text == 'Are you sure you want to delete Two week reminder?'
|
||||||
assert 'Two week reminder has never been used. Are you sure you want to delete it?' in content
|
assert normalize_spaces(page.select('.banner-dangerous p')[0].text) == (
|
||||||
assert 'Are you sure' in content
|
'It’s never been used.'
|
||||||
assert 'Two week reminder' in content
|
)
|
||||||
assert 'Template <em>content</em> with & entity' in content
|
assert normalize_spaces(page.select('.sms-message-wrapper')[0].text) == (
|
||||||
mock_get_service_template.assert_called_with(service_id, template_id)
|
'service one: Template <em>content</em> with & entity'
|
||||||
|
)
|
||||||
|
mock_get_service_template.assert_called_with(SERVICE_ONE_ID, fake_uuid)
|
||||||
|
|
||||||
|
|
||||||
def test_should_redirect_when_deleting_a_template(
|
def test_should_redirect_when_deleting_a_template(
|
||||||
@@ -1094,6 +1083,7 @@ def test_should_show_message_before_redacting_template(
|
|||||||
'main.redact_template',
|
'main.redact_template',
|
||||||
service_id=SERVICE_ONE_ID,
|
service_id=SERVICE_ONE_ID,
|
||||||
template_id=fake_uuid,
|
template_id=fake_uuid,
|
||||||
|
_test_page_title=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert (
|
assert (
|
||||||
|
|||||||
Reference in New Issue
Block a user