Merge pull request #1961 from alphagov/ken-show-client-reference

Add client reference to API Integration / message log
This commit is contained in:
kentsanggds
2018-03-20 10:54:47 +00:00
committed by GitHub
5 changed files with 40 additions and 6 deletions

View File

@@ -66,10 +66,12 @@
<div> <div>
<dl id="notification-{{ notification.id }}" class="api-notifications-item-data bottom-gutter-1-2"> <dl id="notification-{{ notification.id }}" class="api-notifications-item-data bottom-gutter-1-2">
{% for key in [ {% for key in [
'id', 'notification_type', 'created_at', 'updated_at', 'sent_at', 'status' 'id', 'client_reference', 'notification_type', 'created_at', 'updated_at', 'sent_at', 'status'
] %} ] %}
<dt>{{ key }}:</dt> {% if notification[key] %}
<dd class="api-notifications-item-data-item">{{ notification[key] }}</dd> <dt>{{ key }}:</dt>
<dd class="api-notifications-item-data-item">{{ notification[key] }}</dd>
{% endif %}
{% endfor %} {% endfor %}
{% if notification['notification_type'] == 'letter' %} {% if notification['notification_type'] == 'letter' %}
<a href="{{ url_for('.view_notification', service_id=current_service.id, notification_id=notification.id) }}">View letter</a> <a href="{{ url_for('.view_notification', service_id=current_service.id, notification_id=notification.id) }}">View letter</a>

View File

@@ -16,7 +16,7 @@
<p> <p>
{% if is_precompiled_letter %} {% if is_precompiled_letter %}
Provided as PDF. Sent Provided as PDF, sent
{% else %} {% else %}
{% if help %} {% if help %}
{{ template.name }} {{ template.name }}

View File

@@ -361,7 +361,8 @@ def notification_json(
rows=5, rows=5,
personalisation=None, personalisation=None,
template_type=None, template_type=None,
reply_to_text=None reply_to_text=None,
client_reference=None,
): ):
if template is None: if template is None:
template = template_json(service_id, str(generate_uuid()), type_=template_type) template = template_json(service_id, str(generate_uuid()), type_=template_type)
@@ -410,6 +411,7 @@ def notification_json(
'personalisation': personalisation or {}, 'personalisation': personalisation or {},
'notification_type': template_type, 'notification_type': template_type,
'reply_to_text': reply_to_text, 'reply_to_text': reply_to_text,
'client_reference': client_reference,
} for i in range(rows)], } for i in range(rows)],
'total': rows, 'total': rows,
'page_size': 50, 'page_size': 50,

View File

@@ -89,6 +89,34 @@ def test_letter_notifications_should_have_link_to_view_letter(
assert (page.select_one('details a') is not None) == has_links assert (page.select_one('details a') is not None) == has_links
@pytest.mark.parametrize('client_reference, shows_ref', [
('foo', True),
(None, False),
])
def test_letter_notifications_should_show_client_reference(
client_request,
api_user_active,
fake_uuid,
mock_has_permissions,
mocker,
client_reference,
shows_ref
):
mock_get_notifications(mocker, api_user_active, client_reference=client_reference)
page = client_request.get(
'main.api_integration',
service_id=fake_uuid,
)
dt_arr = [p.text for p in page.select('dt')]
if shows_ref:
assert 'client_reference:' in dt_arr
assert page.select_one('dd:nth-of-type(2)').text == 'foo'
else:
assert 'client_reference:' not in dt_arr
def test_should_show_api_page_for_live_service( def test_should_show_api_page_for_live_service(
logged_in_client, logged_in_client,
mock_login, mock_login,

View File

@@ -1765,6 +1765,7 @@ def mock_get_notifications(
personalisation=None, personalisation=None,
redact_personalisation=False, redact_personalisation=False,
is_precompiled_letter=False, is_precompiled_letter=False,
client_reference=None,
): ):
def _get_notifications( def _get_notifications(
service_id, service_id,
@@ -1804,7 +1805,8 @@ def mock_get_notifications(
rows=rows, rows=rows,
job=job, job=job,
personalisation=personalisation, personalisation=personalisation,
template_type=diff_template_type template_type=diff_template_type,
client_reference=client_reference,
) )
return mocker.patch( return mocker.patch(