From fee47aa3487d4fcc355ca7c92c5b1ee3f878f52a Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Thu, 20 Sep 2018 15:43:22 +0100 Subject: [PATCH] Hide Postage setting when letters are not enabled for service We don't show the sender addresses and letter branding on the settings page if a service doesn't have letters enabled, so we should also hide the postage for services that can't send letters. (Postage can only be seen by Platform Admin users at the moment, but this will change later). --- app/templates/views/service-settings.html | 2 +- tests/app/main/views/test_service_settings.py | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/templates/views/service-settings.html b/app/templates/views/service-settings.html index 0314769af..77e78020a 100644 --- a/app/templates/views/service-settings.html +++ b/app/templates/views/service-settings.html @@ -236,7 +236,7 @@ {% endcall %} {% if current_user.platform_admin %} - {% call row() %} + {% call settings_row(if_has_permission='letter') %} {{ text_field('Postage') }} {% set postage = {'first': 'First class only', 'second': 'Second class only'} %} {{ text_field(postage[current_service.postage]) }} diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index cab7f38e8..f35ca07ce 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -89,7 +89,6 @@ def mock_get_service_settings_page_common( 'Label Value Action', 'Send letters Off Change', - 'Postage Second class only Change', 'Label Value Action', 'Organisation Org 1 Change', @@ -216,6 +215,25 @@ def test_should_show_overview_for_service_with_more_things_set( assert row == " ".join(page.find_all('tr')[index + 1].text.split()) +def test_if_cant_send_letters_then_cant_see_postage( + logged_in_platform_admin_client, + service_one, + single_reply_to_email_address, + single_letter_contact_block, + mock_get_service_organisation, + single_sms_sender, + mock_get_service_settings_page_common, +): + response = logged_in_platform_admin_client.get(url_for('main.service_settings', service_id=SERVICE_ONE_ID)) + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + + letter_table = page.find_all('table')[3] + rows = letter_table.find_all('tr') + + assert len(rows) == 2 + assert 'Postage' not in letter_table + + def test_if_cant_send_letters_then_cant_see_letter_contact_block( client_request, service_one,