From e547732c7829437d6edb6294efcc22757fdcc4b2 Mon Sep 17 00:00:00 2001 From: Pete Herlihy Date: Wed, 24 Jan 2018 10:34:06 +0000 Subject: [PATCH 1/6] Adding a link to the Notify blog --- app/templates/admin_template.html | 1 + 1 file changed, 1 insertion(+) diff --git a/app/templates/admin_template.html b/app/templates/admin_template.html index 32b66105f..c6146930f 100644 --- a/app/templates/admin_template.html +++ b/app/templates/admin_template.html @@ -82,6 +82,7 @@
  • System status
  • Performance
  • Slack channel
  • +
  • Blog
  • From 30cf635bee1130e20af245196f3439fe598b4861 Mon Sep 17 00:00:00 2001 From: Pete Herlihy Date: Tue, 23 Jan 2018 15:46:49 +0000 Subject: [PATCH 2/6] [WIP] Updated roadmap 23 Jan 2018 --- app/templates/views/roadmap.html | 51 ++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/app/templates/views/roadmap.html b/app/templates/views/roadmap.html index 0060ac182..530f1221c 100644 --- a/app/templates/views/roadmap.html +++ b/app/templates/views/roadmap.html @@ -16,27 +16,52 @@

    Roadmap

    The GOV.UK Notify roadmap shows the things we’re working on and when we hope to have them ready for you to use.

    -

    It’s only a guide and things might change.

    +

    This roadmap is a only a guide and may change from month to month.

    You can contact us for more detail about these features, or to suggest something else you’d like Notify to offer.

    Sending and receiving messages

    -

    We’re working on new features so that you can:

    + +

    February – March 2018

    +
      -
    • allow services to get text messages replies via the API (November 2017)
    • -
    • posting delivery receipts to services (December 2017)
    • -
    • sending of pre-compiled letters (January 2018)
    • -
    • customising the expiry time for text messages (February - April 2018)
    • -
    • sending of pre-compiled text messages and emails (February - April 2018)
    • -
    • distributing delivery of notifications over a period of time (May 2018 onwards)
    • -
    • Automated content scanning for banned content (May 2018 onwards)
    • -
    • Checking mobile numbers are valid before sending (May 2018 onwards)
    • +
    • Sending pre-compiled text messages and emails through templates
    • +
    • Sending of pre-compiled letters
    • +
    + +

    April 2018 onwards

    + +
      +
    • Additional letter formatting options
    • +
    • Customised expiry time for text messages
    • +
    • Distributed delivery of notifications over a period of time
    • +
    • Automated content scanning for banned content
    • +
    • Checking mobile numbers are valid before sending
    • +
    • Sending of pre-compiled text messages and emails without templates
    • +
    • Publishing patterns for effective notifications
    • +
    • Saving work in progress/draft templates
    • +
    • Exploring other channels (Facebook messenger, WhatsApp, Push Notifications)

    Managing your account

    -

    We want to offer the functionality for:

    + +

    February – March 2018

    +
      -
    • allow service owners to manage team members details (February - April 2018)
    • -
    • allowing people to request to join a service (February - April 2018)
    • +
    • Caseworking interface
    • +
    • Organisational view of service activity
    • +
    + +

    April 2018 onwards

    + +
      +
    • Allow multiple teams within a service
    • +
    • Add NHS and Parliament email sending domains
    • +
    • Let service owners to update team members phone number or email address
    • +
    • Let teams to enable or disable features themselves
    • +
    • Retire version 1 of the API
    • +
    • Add public endpoints for usage and reporting
    • +
    • Self-service access to invoices
    • +
    • Additional payment methods for teams using Notify
    From 707ee8e7485ca71eacc502753acedc9d0722684a Mon Sep 17 00:00:00 2001 From: Pete Herlihy Date: Wed, 24 Jan 2018 10:19:33 +0000 Subject: [PATCH 3/6] Reword the health warning in the roadmap. --- app/templates/views/roadmap.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/views/roadmap.html b/app/templates/views/roadmap.html index 530f1221c..7847dba14 100644 --- a/app/templates/views/roadmap.html +++ b/app/templates/views/roadmap.html @@ -16,7 +16,7 @@

    Roadmap

    The GOV.UK Notify roadmap shows the things we’re working on and when we hope to have them ready for you to use.

    -

    This roadmap is a only a guide and may change from month to month.

    +

    This roadmap is a only a guide and things might change.

    You can contact us for more detail about these features, or to suggest something else you’d like Notify to offer.

    Sending and receiving messages

    From a44aee05cbb155c5917b856fc6c22e456514f44c Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 24 Jan 2018 11:33:26 +0000 Subject: [PATCH 4/6] Update date ranges to GOV.UK style --- app/templates/views/roadmap.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/views/roadmap.html b/app/templates/views/roadmap.html index 7847dba14..536097901 100644 --- a/app/templates/views/roadmap.html +++ b/app/templates/views/roadmap.html @@ -21,7 +21,7 @@

    Sending and receiving messages

    -

    February – March 2018

    +

    February to March 2018

    • Sending pre-compiled text messages and emails through templates
    • @@ -44,7 +44,7 @@

      Managing your account

      -

      February – March 2018

      +

      February to March 2018

      • Caseworking interface
      • From 555392b5da106991d7bb5a7584429729d826d5f1 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 19 Jan 2018 13:45:54 +0000 Subject: [PATCH 5/6] Allows services to choose if they can send letters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our support ticket analysis shows that the most common action request after going live is turning on letters. We just do this for any team that requests it – there’s no gatekeeping. So we should just allow people to make the change themselves. This will be a better experience for our users, and less work for us. The design of the page replicates roughly what we have for international text messaging. --- app/main/forms.py | 11 +++ app/main/views/service_settings.py | 16 ++++- app/templates/views/pricing.html | 2 +- .../views/service-settings/set-letters.html | 32 ++++----- tests/app/main/views/test_service_settings.py | 71 +++++++++---------- 5 files changed, 72 insertions(+), 60 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index 90171249f..3ec7e33a8 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -584,6 +584,17 @@ class ServiceLetterContactBlockForm(StripWhitespaceForm): ) +class ServiceSwitchLettersForm(StripWhitespaceForm): + + enabled = RadioField( + 'Send letters', + choices=[ + ('on', 'On'), + ('off', 'Off'), + ], + ) + + class ServiceBrandingOrg(StripWhitespaceForm): def __init__(self, organisations=[], *args, **kwargs): diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index e1f44d919..6ecf54c98 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -35,6 +35,7 @@ from app.main.forms import ( FreeSMSAllowance, ServiceEditInboundNumberForm, SMSPrefixForm, + ServiceSwitchLettersForm, ) from app import user_api_client, current_service, organisations_client, inbound_number_client, billing_api_client from notifications_utils.formatters import formatted_list @@ -502,12 +503,25 @@ def service_set_inbound_sms(service_id): ) -@main.route("/services//service-settings/set-letters", methods=['GET']) +@main.route("/services//service-settings/set-letters", methods=['GET', 'POST']) @login_required @user_has_permissions('manage_settings', admin_override=True) def service_set_letters(service_id): + form = ServiceSwitchLettersForm( + enabled='on' if 'letter' in current_service['permissions'] else 'off' + ) + if form.validate_on_submit(): + force_service_permission( + service_id, + 'letter', + on=(form.enabled.data == 'on'), + ) + return redirect( + url_for(".service_settings", service_id=service_id) + ) return render_template( 'views/service-settings/set-letters.html', + form=form, ) diff --git a/app/templates/views/pricing.html b/app/templates/views/pricing.html index aa4f063cb..632f0b7cf 100644 --- a/app/templates/views/pricing.html +++ b/app/templates/views/pricing.html @@ -87,7 +87,7 @@ -

        Letters

        +

        Letters

        The cost of sending a letter depends on how many sheets of paper you need.

        {% call mapping_table( diff --git a/app/templates/views/service-settings/set-letters.html b/app/templates/views/service-settings/set-letters.html index 60f2895fb..b32fe1009 100644 --- a/app/templates/views/service-settings/set-letters.html +++ b/app/templates/views/service-settings/set-letters.html @@ -1,34 +1,26 @@ {% extends "withnav_template.html" %} -{% from "components/textbox.html" import textbox %} +{% from "components/radios.html" import radios %} {% from "components/page-footer.html" import page_footer %} {% block service_page_title %} - Text message sender + Send letters {% endblock %} {% block maincolumn_content %}
        -

        Letters

        - {% if 'letter' in current_service.permissions %} -

        - Your service can send letters. -

        -

        - If you want to stop your service from sending letters, - get in touch with the GOV.UK Notify team. -

        - {% else %} -

        - Using GOV.UK Notify to send letters is an invitation‑only feature. -

        -

        - If you want to try it out, - get in touch with the GOV.UK Notify team. -

        - {% endif %} +

        Send letters

        +

        + It costs between 30p and 45p to send a letter using Notify. +

        +

        + See pricing for the list + of rates. +

        + {{ radios(form.enabled) }} {{ page_footer( + 'Save', back_link=url_for('.service_settings', service_id=current_service.id), back_link_text='Back to settings' ) }} diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 498ad5071..a346aea45 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -1557,40 +1557,50 @@ def test_should_set_sms_allowance( ) +@pytest.mark.parametrize(( + 'expected_initial_value,' + 'posted_value,' + 'initial_permissions,' + 'expected_updated_permissions' +), [ + ('off', 'on', ['email', 'sms'], ['email', 'sms', 'letter']), + ('on', 'off', ['email', 'sms', 'letter'], ['email', 'sms']), +]) def test_switch_service_enable_letters( - logged_in_platform_admin_client, + client_request, service_one, mocker, + expected_initial_value, + posted_value, + initial_permissions, + expected_updated_permissions, ): mocked_fn = mocker.patch('app.service_api_client.update_service_with_properties', return_value=service_one) + service_one['permissions'] = initial_permissions - response = logged_in_platform_admin_client.get( - url_for('main.service_switch_can_send_letters', service_id=service_one['id']) + page = client_request.get( + 'main.service_set_letters', + service_id=service_one['id'], ) - assert response.status_code == 302 - assert response.location == url_for('main.service_settings', service_id=service_one['id'], _external=True) - assert 'letter' in mocked_fn.call_args[0][1]['permissions'] + assert page.select_one('input[checked]')['value'] == expected_initial_value + assert len(page.select('input[checked]')) == 1 + + client_request.post( + 'main.service_set_letters', + service_id=service_one['id'], + _data={'enabled': posted_value}, + _expected_redirect=url_for( + 'main.service_settings', + service_id=service_one['id'], + _external=True + ) + ) + + assert set(mocked_fn.call_args[0][1]['permissions']) == set(expected_updated_permissions) assert mocked_fn.call_args[0][0] == service_one['id'] -def test_switch_service_disable_letters( - logged_in_platform_admin_client, - service_one, - mocker, -): - service_one['permissions'] = ['letter'] - mocked_fn = mocker.patch('app.service_api_client.update_service_with_properties', return_value=service_one) - - response = logged_in_platform_admin_client.get( - url_for('main.service_switch_can_send_letters', service_id=service_one['id']) - ) - - assert response.status_code == 302 - assert response.location == url_for('main.service_settings', service_id=service_one['id'], _external=True) - assert mocked_fn.call_args == call(service_one['id'], {"permissions": []}) - - @pytest.mark.parametrize('permissions, expected_checked', [ (['international_sms'], 'on'), ([''], 'off'), @@ -1802,21 +1812,6 @@ def test_cant_resume_active_service( @pytest.mark.parametrize('endpoint, permissions, expected_p', [ - ( - 'main.service_set_letters', - [], - ( - 'Using GOV.UK Notify to send letters is an invitation‑only ' - 'feature.' - ) - ), - ( - 'main.service_set_letters', - ['letter'], - ( - 'Your service can send letters.' - ) - ), ( 'main.service_set_inbound_sms', ['sms'], From 86e21f2b4b4c96213f973e000ac7918cb1b4a89c Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 19 Jan 2018 13:53:17 +0000 Subject: [PATCH 6/6] Remove platform admin letter/international buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users can choose whether to have these features on or off now. And a platform admin can still use the same controls to switch the features on or off on behalf of a user. There’s no need for the separate buttons. --- app/main/views/service_settings.py | 16 ---------------- app/templates/views/service-settings.html | 5 ----- .../test_service_setting_permissions.py | 3 --- tests/app/main/views/test_service_settings.py | 4 ---- 4 files changed, 28 deletions(-) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 6ecf54c98..b99ef1807 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -253,14 +253,6 @@ def update_service_permissions(service_id, permissions, sms_sender=None): service_api_client.update_service_with_properties(service_id, data) -@main.route("/services//service-settings/can-send-letters") -@login_required -@user_has_permissions(admin_override=True) -def service_switch_can_send_letters(service_id): - switch_service_permissions(service_id, 'letter') - return redirect(url_for('.service_settings', service_id=service_id)) - - @main.route("/services//service-settings/send-letters-as-pdf") @login_required @user_has_permissions(admin_override=True) @@ -269,14 +261,6 @@ def service_switch_send_letters_as_pdf(service_id): return redirect(url_for('.service_settings', service_id=service_id)) -@main.route("/services//service-settings/can-send-international-sms") -@login_required -@user_has_permissions(admin_override=True) -def service_switch_can_send_international_sms(service_id): - switch_service_permissions(service_id, 'international_sms') - return redirect(url_for('.service_settings', service_id=service_id)) - - @main.route("/services//service-settings/can-send-email") @login_required @user_has_permissions(admin_override=True) diff --git a/app/templates/views/service-settings.html b/app/templates/views/service-settings.html index 561d606d7..99a6b4e7b 100644 --- a/app/templates/views/service-settings.html +++ b/app/templates/views/service-settings.html @@ -243,11 +243,6 @@ {{ 'Stop sending emails' if 'email' in current_service.permissions else 'Allow to send emails' }} -
      • - - {{ 'Stop sending letters' if 'letter' in current_service.permissions else 'Allow to send letters' }} - -
      • {% if 'letter' in current_service.permissions %}
      • diff --git a/tests/app/main/views/service_settings/test_service_setting_permissions.py b/tests/app/main/views/service_settings/test_service_setting_permissions.py index 71ffc7018..4e0d08b36 100644 --- a/tests/app/main/views/service_settings/test_service_setting_permissions.py +++ b/tests/app/main/views/service_settings/test_service_setting_permissions.py @@ -31,9 +31,6 @@ def get_service_settings_page( ({'permissions': ['email']}, '.service_switch_can_send_email', {}, 'Stop sending emails'), ({'permissions': []}, '.service_switch_can_send_email', {}, 'Allow to send emails'), - ({'permissions': ['letter']}, '.service_switch_can_send_letters', {}, 'Stop sending letters'), - ({'permissions': []}, '.service_switch_can_send_letters', {}, 'Allow to send letters'), - ({'permissions': ['sms']}, '.service_switch_can_send_sms', {}, 'Stop sending sms'), ({'permissions': []}, '.service_switch_can_send_sms', {}, 'Allow to send sms'), diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index a346aea45..b87f3a572 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -530,8 +530,6 @@ def test_route_permissions( 'main.service_request_to_go_live', 'main.service_switch_live', 'main.service_switch_research_mode', - 'main.service_switch_can_send_letters', - 'main.service_switch_can_send_international_sms', 'main.archive_service', ]) def test_route_invalid_permissions( @@ -584,8 +582,6 @@ def test_route_for_platform_admin( @pytest.mark.parametrize('route', [ 'main.service_switch_live', 'main.service_switch_research_mode', - 'main.service_switch_can_send_letters', - 'main.service_switch_can_send_international_sms', ]) def test_route_for_platform_admin_update_service( mocker,