mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-03 05:11:03 -04:00
Remove template link from preview for precompiled letters
This commit is contained in:
@@ -80,6 +80,7 @@ def view_notification(service_id, notification_id):
|
||||
estimated_letter_delivery_date=get_letter_timings(notification['created_at']).earliest_delivery,
|
||||
notification_id=notification['id'],
|
||||
can_receive_inbound=('inbound_sms' in current_service['permissions']),
|
||||
is_precompiled_letter=notification['template']['is_precompiled_letter']
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -15,12 +15,16 @@
|
||||
</h1>
|
||||
|
||||
<p>
|
||||
{% if help %}
|
||||
{{ template.name }}
|
||||
{% if is_precompiled_letter %}
|
||||
Sent
|
||||
{% else %}
|
||||
<a href="{{ url_for('.view_template', service_id=current_service.id, template_id=template.id) }}">{{ template.name }}</a>
|
||||
{% if help %}
|
||||
{{ template.name }}
|
||||
{% else %}
|
||||
<a href="{{ url_for('.view_template', service_id=current_service.id, template_id=template.id) }}">{{ template.name }}</a>
|
||||
{% endif %}
|
||||
sent
|
||||
{% endif %}
|
||||
sent
|
||||
{% if job and job.original_file_name != 'Report' %}
|
||||
from
|
||||
<a href="{{ url_for('.view_job', service_id=current_service.id, job_id=job.id) }}">{{ job.original_file_name }}</a>
|
||||
|
||||
@@ -205,6 +205,7 @@ def template_json(service_id,
|
||||
service_letter_contact=None,
|
||||
reply_to=None,
|
||||
reply_to_text=None,
|
||||
is_precompiled_letter=False,
|
||||
):
|
||||
template = {
|
||||
'id': id_,
|
||||
@@ -219,6 +220,7 @@ def template_json(service_id,
|
||||
'service_letter_contact': service_letter_contact,
|
||||
'reply_to': reply_to,
|
||||
'reply_to_text': reply_to_text,
|
||||
'is_precompiled_letter': is_precompiled_letter,
|
||||
}
|
||||
if content is None:
|
||||
template['content'] = "template content"
|
||||
|
||||
@@ -277,3 +277,37 @@ def test_notification_page_has_link_to_download_letter(
|
||||
download_link = None
|
||||
|
||||
assert download_link == expected_link(notification_id=fake_uuid)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('is_precompiled_letter, has_template_link', [
|
||||
(True, False),
|
||||
(False, True),
|
||||
])
|
||||
def test_notification_page_has_expected_template_link_for_letter(
|
||||
client_request,
|
||||
mocker,
|
||||
fake_uuid,
|
||||
service_one,
|
||||
is_precompiled_letter,
|
||||
has_template_link
|
||||
):
|
||||
|
||||
mock_get_notification(
|
||||
mocker, fake_uuid, template_type='letter', is_precompiled_letter=is_precompiled_letter)
|
||||
mocker.patch(
|
||||
'app.main.views.notifications.get_page_count_for_letter',
|
||||
return_value=1
|
||||
)
|
||||
|
||||
page = client_request.get(
|
||||
'main.view_notification',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
)
|
||||
|
||||
link = page.select_one('main > p:nth-of-type(1) > a')
|
||||
|
||||
if has_template_link:
|
||||
assert link
|
||||
else:
|
||||
assert link is None
|
||||
|
||||
@@ -2404,6 +2404,8 @@ def mock_get_notification(
|
||||
notification_status='delivered',
|
||||
redact_personalisation=False,
|
||||
template_type=None,
|
||||
template_name='sample template',
|
||||
is_precompiled_letter=False
|
||||
):
|
||||
def _get_notification(
|
||||
service_id,
|
||||
@@ -2430,6 +2432,8 @@ def mock_get_notification(
|
||||
subject='blah',
|
||||
redact_personalisation=redact_personalisation,
|
||||
type_=template_type,
|
||||
is_precompiled_letter=is_precompiled_letter,
|
||||
name=template_name
|
||||
)
|
||||
return noti
|
||||
|
||||
|
||||
Reference in New Issue
Block a user