diff --git a/app/models/service.py b/app/models/service.py
index 132ac157c..041ef5e5a 100644
--- a/app/models/service.py
+++ b/app/models/service.py
@@ -6,6 +6,7 @@ from notifications_utils.timezones import local_timezone
from werkzeug.utils import cached_property
from app.models import JSONModel
+from app.models.contact_list import ContactLists
from app.models.job import (
ImmediateJobs,
PaginatedJobs,
@@ -695,3 +696,7 @@ class Service(JSONModel):
for report in self.returned_letter_summary
if parse(report['reported_at'] + " 00:00:00") >= seven_days_ago
)
+
+ @property
+ def contact_lists(self):
+ return ContactLists(self.id)
diff --git a/app/templates/views/send-test.html b/app/templates/views/send-test.html
index f2b71ec9e..9ea19106c 100644
--- a/app/templates/views/send-test.html
+++ b/app/templates/views/send-test.html
@@ -33,7 +33,7 @@
{% if link_to_upload %}
Upload a list of {{ recipient_count_label(999, template.template_type) }}
- {% if current_user.platform_admin %}
+ {% if current_user.platform_admin and current_service.contact_lists %}
Use a saved list
{% endif %}
{% endif %}
diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py
index db80d72d6..c7112599b 100644
--- a/tests/app/main/views/test_send.py
+++ b/tests/app/main/views/test_send.py
@@ -1424,6 +1424,7 @@ def test_platform_admin_has_link_to_use_existing_list(
client_request,
mock_get_service_template,
mock_has_jobs,
+ mock_get_contact_lists,
fake_uuid,
user,
):
@@ -1465,6 +1466,32 @@ def test_platform_admin_has_link_to_use_existing_list(
]
+def test_no_link_to_use_existing_list_for_service_without_lists(
+ mocker,
+ client_request,
+ mock_get_service_template,
+ mock_has_jobs,
+ fake_uuid,
+):
+ mocker.patch(
+ 'app.models.contact_list.ContactLists.client_method',
+ return_value=[],
+ )
+ client_request.login(create_platform_admin_user())
+ page = client_request.get(
+ 'main.send_one_off',
+ service_id=SERVICE_ONE_ID,
+ template_id=fake_uuid,
+ _follow_redirects=True,
+ )
+ assert [
+ link.text for link in page.select('form a')
+ ] == [
+ 'Upload a list of phone numbers',
+ 'Use my phone number',
+ ]
+
+
@pytest.mark.parametrize('user', (
create_active_user_with_permissions(),
create_active_caseworking_user(),