From b22ea172b91eb9e2e884016e9921ce784b810f8d Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Sun, 15 Mar 2020 14:43:39 +0000 Subject: [PATCH] Add button to uploads page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need a place where people can get into the contact list journey. This is going to be the uploads page, because that’s where stuff you upload lives. At the moment this is platform-admin only, until we’re ready to launch the feature. --- app/templates/views/jobs/jobs.html | 13 ++++++++++++- tests/app/main/views/test_uploads.py | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/templates/views/jobs/jobs.html b/app/templates/views/jobs/jobs.html index 347ac2a6d..3516c2daf 100644 --- a/app/templates/views/jobs/jobs.html +++ b/app/templates/views/jobs/jobs.html @@ -31,7 +31,10 @@

{% endif %} {{ previous_next_navigation(prev_page, next_page) }} - {% if current_service.can_upload_letters and current_user.has_permissions('send_messages') %} + {% if ( + current_service.can_upload_letters and + current_user.has_permissions('send_messages') + ) or current_user.platform_admin %}
{{ govukButton({ "element": "a", @@ -39,6 +42,14 @@ "href": url_for('.upload_letter', service_id=current_service.id), "classes": "govuk-button--secondary" }) }} + {% if current_user.platform_admin %} + {{ govukButton({ + "element": "a", + "text": "Upload a contact list", + "href": url_for('.upload_contact_list', service_id=current_service.id), + "classes": "govuk-button--secondary govuk-!-margin-left-3" + }) }} + {% endif %}
{% endif %} diff --git a/tests/app/main/views/test_uploads.py b/tests/app/main/views/test_uploads.py index ecc739d02..6ee68999e 100644 --- a/tests/app/main/views/test_uploads.py +++ b/tests/app/main/views/test_uploads.py @@ -15,6 +15,7 @@ from tests.conftest import ( SERVICE_ONE_ID, create_active_caseworking_user, create_active_user_with_permissions, + create_platform_admin_user, ) @@ -39,6 +40,30 @@ def test_no_upload_letters_button_without_permission( assert not page.find('a', text=re.compile('Upload a letter')) +@pytest.mark.parametrize('user', ( + pytest.param( + create_platform_admin_user(), + ), + pytest.param( + create_active_user_with_permissions(), + marks=pytest.mark.xfail(raises=AssertionError), + ), +)) +def test_platform_admin_has_upload_contact_list( + client_request, + mock_get_uploads, + mock_get_jobs, + user, +): + client_request.login(user) + page = client_request.get('main.uploads', service_id=SERVICE_ONE_ID) + button = page.find('a', text=re.compile('Upload a contact list')) + assert button + assert button['href'] == url_for( + 'main.upload_contact_list', service_id=SERVICE_ONE_ID, + ) + + @pytest.mark.parametrize('extra_permissions, expected_empty_message', ( (['letter'], ( 'You have not uploaded any files recently. '