Add a message saying a template has been redacted

This is useful if it’s been redacted by someone who isn’t you.
This commit is contained in:
Chris Hill-Scott
2017-06-28 15:26:09 +01:00
parent afbe175d15
commit 6e48dc7689
5 changed files with 31 additions and 5 deletions

View File

@@ -42,6 +42,7 @@
&-delete-link-without-button {
@include core-19;
padding-left: 0;
display: inline-block;
}
&-secondary-link {

View File

@@ -50,14 +50,16 @@
<br/>
{% endif %}
{% if current_user.has_permissions(permissions=['manage_templates'], admin_override=True) %}
<span class="page-footer-delete-link page-footer-delete-link-without-button">
<span class="page-footer-delete-link page-footer-delete-link-without-button bottom-gutter-2-3">
<a href="{{ url_for('.delete_service_template', service_id=current_service.id, template_id=template.id) }}">Delete this template</a>
</span>
&emsp;
{% if not template.redact_personalisation %}
{% if not template._template.redact_personalisation %}
<span class="page-footer-delete-link page-footer-delete-link-without-button">
<a href="{{ url_for('.confirm_redact_template', service_id=current_service.id, template_id=template.id) }}">Hide personalisation after sending</a>
</span>
{% else %}
<p class="hint">Personalisation is hidden after sending</p>
{% endif %}
{% endif %}
</div>

View File

@@ -91,7 +91,9 @@ def template_json(service_id,
subject=None,
version=1,
archived=False,
process_type='normal'):
process_type='normal',
redact_personalisation=False,
):
template = {
'id': id_,
'name': name,
@@ -101,10 +103,12 @@ def template_json(service_id,
'version': version,
'updated_at': datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f'),
'archived': archived,
'process_type': process_type
'process_type': process_type,
}
if subject is not None:
template['subject'] = subject
if redact_personalisation is not None:
template['redact_personalisation'] = redact_personalisation
return template

View File

@@ -987,3 +987,21 @@ def test_should_show_redact_template(
)
mock_redact_template.assert_called_once_with(SERVICE_ONE_ID, fake_uuid)
def test_should_show_hint_once_template_redacted(
client_request,
mocker,
service_one,
fake_uuid,
):
mock_get_service_email_template(mocker, redact_personalisation=True)
page = client_request.get(
'main.view_template',
service_id=SERVICE_ONE_ID,
template_id=fake_uuid,
)
assert page.select('.hint')[0].text == 'Personalisation is hidden after sending'

View File

@@ -351,7 +351,7 @@ def mock_get_service_template_with_placeholders(mocker):
@pytest.fixture(scope='function')
def mock_get_service_email_template(mocker, content=None, subject=None):
def mock_get_service_email_template(mocker, content=None, subject=None, redact_personalisation=False):
def _get(service_id, template_id, version=None):
template = template_json(
service_id,
@@ -360,6 +360,7 @@ def mock_get_service_email_template(mocker, content=None, subject=None):
"email",
content or "Your vehicle tax expires on ((date))",
subject or "Your ((thing)) is due soon",
redact_personalisation=redact_personalisation,
)
return {'data': template}