From d71269ca87b8497197c2768079da5dc2ec9d67f6 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 1 Jul 2016 11:37:09 +0100 Subject: [PATCH 01/30] Hide download CSV link when in the tour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is really no point to downloading the CSV file of delivery info when you’re in the tour. It’s just distracting at this point. --- .../partials/jobs/notifications.html | 2 +- tests/app/main/views/test_jobs.py | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/templates/partials/jobs/notifications.html b/app/templates/partials/jobs/notifications.html index 0ba32b741..1148f8752 100644 --- a/app/templates/partials/jobs/notifications.html +++ b/app/templates/partials/jobs/notifications.html @@ -4,7 +4,7 @@
{% endif %} - {% if notifications %} + {% if notifications and request.args.get('help', '0') == '0' %}

Download as a CSV file   diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index d6922f0a3..850a6f80a 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -99,6 +99,34 @@ def test_should_show_page_for_one_job( ) +def test_should_show_not_show_csv_download_in_tour( + app_, + service_one, + active_user_with_permissions, + mock_get_service_template, + mock_get_service_statistics, + mock_get_job, + mocker, + mock_get_notifications, + fake_uuid +): + with app_.test_request_context(), app_.test_client() as client: + client.login(active_user_with_permissions, mocker, service_one) + response = client.get(url_for( + 'main.view_job', + service_id=service_one['id'], + job_id=fake_uuid, + help=3 + )) + + assert response.status_code == 200 + assert url_for( + 'main.view_job_csv', + service_id=service_one['id'], + job_id=fake_uuid + ) not in response.get_data(as_text=True) + + @freeze_time("2016-01-01 11:09:00.061258") def test_should_show_updates_for_one_job_as_json( app_, From 80e0832f7d5ecc2b1a4b8781c16bde4af2512bc0 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 5 Jul 2016 11:39:07 +0100 Subject: [PATCH 02/30] Make a function for parsing `help` query param Our templates are a littered with `request.args.get('help', '0')`. This commit refactors these into a single helper method, which can be used by the view functions, then passed to the template. This makes the templates cleaner, and should make it easier to refactor `help` out of the query parameters entirely in the future. --- app/main/views/jobs.py | 7 +++++-- app/main/views/send.py | 8 +++++--- app/templates/main_nav.html | 10 +++++----- app/templates/partials/jobs/notifications.html | 2 +- app/templates/views/check.html | 2 +- app/templates/views/send-test.html | 2 +- app/utils.py | 4 ++++ 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 4d6e71a60..e1baa38c4 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -28,6 +28,7 @@ from app.utils import ( user_has_permissions, generate_notifications_csv) from app.statistics_utils import sum_of_statistics, statistics_by_state, add_rate_to_jobs +from app.utils import get_help_argument def _parse_filter_args(filter_dict): @@ -98,7 +99,8 @@ def view_job(service_id, job_id): job_id=job['id'], status=request.args.get('status', '') ), - partials=get_job_partials(job) + partials=get_job_partials(job), + help=get_help_argument() ) @@ -311,7 +313,8 @@ def get_job_partials(job): notifications=notification_api_client.get_notifications_for_service( job['service'], job['id'], status=filter_args.get('status') )['notifications'], - status=request.args.get('status', '') + status=request.args.get('status', ''), + help=get_help_argument() ), 'status': render_template( 'partials/jobs/status.html', diff --git a/app/main/views/send.py b/app/main/views/send.py index faeb3acf4..07aa0eb52 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -29,7 +29,7 @@ from app.main.uploader import ( s3download ) from app import job_api_client, service_api_client, current_service, user_api_client, statistics_api_client -from app.utils import user_has_permissions, get_errors_for_csv, Spreadsheet +from app.utils import user_has_permissions, get_errors_for_csv, Spreadsheet, get_help_argument def get_page_headings(template_type): @@ -181,7 +181,8 @@ def send_test(service_id, template_id): 'views/send-test.html', template=template, recipient_column=first_column_heading[template.template_type], - example=[get_example_csv_rows(template, use_example_as_example=False)] + example=[get_example_csv_rows(template, use_example_as_example=False)], + help=get_help_argument() ) @@ -278,7 +279,8 @@ def check_messages(service_id, template_type, upload_id): upload_id=upload_id, form=CsvUploadForm(), statistics=statistics, - back_link=back_link + back_link=back_link, + help=get_help_argument() ) diff --git a/app/templates/main_nav.html b/app/templates/main_nav.html index 1fdfb461c..d9e051222 100644 --- a/app/templates/main_nav.html +++ b/app/templates/main_nav.html @@ -1,9 +1,9 @@ {% from "components/banner.html" import banner_wrapper %} -{% if request.args['help'] and request.args['help'] != '0' %} +{% if help %} {% call banner_wrapper(type='tour') %}

Try this example

-
+

1.

@@ -13,7 +13,7 @@

-
+

2.

@@ -23,7 +23,7 @@

-
+

3.

@@ -31,7 +31,7 @@

Notify delivers the message

- {% if request.args['help'] == '3' %} + {% if help == '3' %} Now go to your dashboard diff --git a/app/templates/partials/jobs/notifications.html b/app/templates/partials/jobs/notifications.html index 1148f8752..506c2007d 100644 --- a/app/templates/partials/jobs/notifications.html +++ b/app/templates/partials/jobs/notifications.html @@ -4,7 +4,7 @@
{% endif %} - {% if notifications and request.args.get('help', '0') == '0' %} + {% if notifications and not help %}

Download as a CSV file   diff --git a/app/templates/views/check.html b/app/templates/views/check.html index 9f3571dad..ab638153b 100644 --- a/app/templates/views/check.html +++ b/app/templates/views/check.html @@ -174,7 +174,7 @@ {% else %}

diff --git a/app/templates/views/send-test.html b/app/templates/views/send-test.html index 980ba2a1b..d564730fc 100644 --- a/app/templates/views/send-test.html +++ b/app/templates/views/send-test.html @@ -55,7 +55,7 @@ {% endcall %} {{ page_footer("Preview", back_link=( - url_for('.choose_template', service_id=current_service.id, template_type=template.template_type)) if not request.args['help'] else None + url_for('.send_messages', service_id=current_service.id, template_id=template.id)) if not help else None ) }} diff --git a/app/utils.py b/app/utils.py index 242af78dc..f3b4edb15 100644 --- a/app/utils.py +++ b/app/utils.py @@ -186,3 +186,7 @@ class Spreadsheet(): file_type=extension, file_content=file_content.getvalue() ).to_array(), filename) + + +def get_help_argument(): + return request.args.get('help') if request.args.get('help') in ('1', '2', '3') else None From f9ebb337e3545ea8d4ca0949d1ea95c642ad9064 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 7 Jul 2016 09:17:50 +0100 Subject: [PATCH 03/30] Tidy layout of team page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The team page was a bit of a mess: - invited and active tables didn’t line up - lots of things were wrapping onto two lines - the empty fields for when a user didn’t have permissions looked broken This commit splits each row of the table (not actually a table any more) onto two lines. First line has the user’s info, second has their permissions and any associated actions. --- app/assets/images/cross-grey.png | Bin 0 -> 1190 bytes .../stylesheets/components/tick-cross.scss | 46 +++++++ app/assets/stylesheets/main.scss | 2 + app/assets/stylesheets/views/users.scss | 16 +++ app/templates/components/tick-cross.html | 15 +++ app/templates/views/manage-users.html | 116 +++++++++++------- tests/app/main/views/test_manage_users.py | 11 +- 7 files changed, 159 insertions(+), 47 deletions(-) create mode 100644 app/assets/images/cross-grey.png create mode 100644 app/assets/stylesheets/components/tick-cross.scss create mode 100644 app/assets/stylesheets/views/users.scss create mode 100644 app/templates/components/tick-cross.html diff --git a/app/assets/images/cross-grey.png b/app/assets/images/cross-grey.png new file mode 100644 index 0000000000000000000000000000000000000000..3c665adb94e171aa085edabf6b74184f96892522 GIT binary patch literal 1190 zcmb`HTTl~s7{&j)Y?1{kY*3*lQ8tOS7B65`jAID|f+X5l6jW-kNh~o83`UR^kVvyT zBLs|u=};=-NJgt*r+8shtes{f1fwHr#@0)%n3z;+<)Yi#W{W8_KK8v2-#IhChx78y zIgPpNa;8P`q5uHXlnVKVu$x~W$`0#*RCg_GvnsO-D)WrnE30%BdLSz@Zqwt+GMz!c zL9Z*SDZi?J4**1=l*{s~?~e|Tsrc)$y^r+r=zJZEXA#x4h@Of+$z`jM1?yYcK91^w zWq;4;n)t}e-vw_BwYM+5wFVbnn%Gk$bpa$EZQW#h}C(Rzx*?-gE&o7z$G)kKyy710M0pHw`4`w-VDDBsfP zbHDuS__k0R6;V_(?_PehHwup?d+Az$lTNx8!bv+_3*)4ju8qJ+ExjCIGCQ*cSa5|& z1>_j+NChHbGeTz698g0z>|xq~1*ABZhw;AWudzRz0=F=S!x(q0Fh4^d1jL}b35cXo z<`Puv7en17NRsl*qo~g>hOab%ccn?@kC9W6e(K2O9Cpgh0|2~Cv%?2$rDbv8-WyK! z4VGl`dW%8ZcPKh=cQtO+@QIYVGNhk5$3_1yFc_d>&ct>u6Swr!vF>v_x<-yA!S4t@ zlb-zI&%LMfLD3%KSTEWJR||f3T-+3o*bV~6G<#PeKVXoZ?%;25SMl78M6q8@TX_mShHn$p-tclx_kT=S+++& zaey4*MYnsf%0_QAh=Z?}70yR54nB_r5HXmPYDBgMf^1)-vm&-LfgBJ2rW$`y&|kbi z<1I%#Sc@FyOM0;G!Mli-0J?v^PK9qX_rWqQKKAf-rhSeVHnU;Z;I;3$2V8xyXF4=` zXRH|=@~h#e1Xx*@j2x$XptHCIqh=B{rdUvl$(yKnVy!6|ti|M3Y6hV;eE^n{dF5hv zdIC{uGJ-CV!7{~#gA58L6ISJgf>?$t2ihsv(~&Z%M%1lL!?(z8^LC`&(D11(As~r4 nbWv%Nx^B|>bl_55#LoX6GY!@~oV+3VydGqvQufV=Ey literal 0 HcmV?d00001 diff --git a/app/assets/stylesheets/components/tick-cross.scss b/app/assets/stylesheets/components/tick-cross.scss new file mode 100644 index 000000000..a44aa023c --- /dev/null +++ b/app/assets/stylesheets/components/tick-cross.scss @@ -0,0 +1,46 @@ +%tick-cross { + @include core-16; + display: inline-block; + background-size: 19px 19px; + background-repeat: no-repeat; + background-position: 0 0; + padding: 1px 0 0 25px; +} + +.tick-cross { + + &-tick { + @extend %tick-cross; + background-image: file-url('tick.png'); + } + + &-cross { + @extend %tick-cross; + background-image: file-url('cross-grey.png'); + color: $secondary-text-colour; + } + + &-list { + + @extend %grid-row; + margin-top: 5px; + + &-permissions { + + @include grid-column(3/4); + + li { + display: inline-block; + margin-right: 0.5em; + } + + } + + &-edit-link { + @include grid-column(1/4); + text-align: right; + } + + } + +} diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index b1e27910b..a6d147629 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -54,11 +54,13 @@ $path: '/static/images/'; @import 'components/message'; @import 'components/phone'; @import 'components/research-mode'; +@import 'components/tick-cross'; @import 'views/job'; @import 'views/edit-template'; @import 'views/documenation'; @import 'views/dashboard'; +@import 'views/users'; // TODO: break this up @import 'app'; diff --git a/app/assets/stylesheets/views/users.scss b/app/assets/stylesheets/views/users.scss new file mode 100644 index 000000000..93a4631c3 --- /dev/null +++ b/app/assets/stylesheets/views/users.scss @@ -0,0 +1,16 @@ +.user-list { + + @include core-16; + + &-item { + + padding: $gutter-half 0; + border-top: 1px solid $border-colour; + + &:last-child { + border-bottom: 1px solid $border-colour; + } + + } + +} diff --git a/app/templates/components/tick-cross.html b/app/templates/components/tick-cross.html new file mode 100644 index 000000000..6467b38ca --- /dev/null +++ b/app/templates/components/tick-cross.html @@ -0,0 +1,15 @@ +{% macro tick_cross(yes, label) %} +
  • + {% if yes %} + + Can + {{ label}} + + {% else %} + + Can’t + {{ label}} + + {% endif %} +
  • +{% endmacro %} diff --git a/app/templates/views/manage-users.html b/app/templates/views/manage-users.html index 2448a4409..928423489 100644 --- a/app/templates/views/manage-users.html +++ b/app/templates/views/manage-users.html @@ -1,6 +1,7 @@ {% extends "withnav_template.html" %} {% from "components/table.html" import list_table, row, field, boolean_field, hidden_field_heading %} {% from "components/page-footer.html" import page_footer %} +{% from "components/tick-cross.html" import tick_cross %} {% set table_options = { 'field_headings': [ @@ -29,49 +30,82 @@ Manage users – GOV.UK Notify {% endif %}
    - {% call(item, row_number) list_table( - users, caption='Active', **table_options - ) %} - {% call field() %} - {{ item.name }} - {%- if item.email_address == current_user.email_address -%} -  (you) - {% endif %} - {% endcall %} - {{ boolean_field(item.has_permissions(permissions=['send_texts', 'send_emails', 'send_letters'])) }} - {{ boolean_field(item.has_permissions(permissions=['manage_users', 'manage_templates', 'manage_settings'])) }} - {{ boolean_field(item.has_permissions(permissions=['manage_api_keys'])) }} - {% call field(align='right') %} - {% if current_user.has_permissions(['manage_users']) %} - {% if current_user.id != item.id %} - Edit - {% endif %} - {% endif %} - {% endcall %} - {% endcall %} +

    + Active +

    +
    + {% for user in users %} +
    +

    + {{ user.name }}  + {%- if user.email_address == current_user.email_address -%} + (you) + {% endif %} + +

    +
      +
      + {{ tick_cross( + user.has_permissions(permissions=['send_texts', 'send_emails', 'send_letters']), + 'Send messages' + ) }} + {{ tick_cross( + user.has_permissions(permissions=['manage_users', 'manage_templates', 'manage_settings']), + 'Manage service' + ) }} + {{ tick_cross( + user.has_permissions(permissions=['manage_api_keys']), + 'Access API keys' + ) }} +
      + {% if current_user.has_permissions(['manage_users']) %} + {% if current_user.id != user.id %} + + {% endif %} + {% endif %} +
    +
    + {% endfor %} +
    {% if invited_users %} - {% call(item, row_number) list_table( - invited_users, caption='Invited', **table_options - ) %} - {% call field() %} - {{ item.email_address }} - {% endcall %} - {{ boolean_field(item.has_permissions(permissions=['send_texts', 'send_emails', 'send_letters'])) }} - {{ boolean_field(item.has_permissions(permissions=['manage_users', 'manage_templates', 'manage_settings'])) }} - {{ boolean_field(item.has_permissions(permissions=['manage_api_keys'])) }} - {% if item.status == 'pending' %} - {% call field(align='right') %} - {% if current_user.has_permissions(['manage_users']) %} - Cancel invitation - {% endif %} - {% endcall %} - {% else %} - {% call field() %} - {{ item.status }} - {% endcall %} - {% endif %} - {% endcall %} +

    + Invited +

    +
    + {% for user in invited_users %} +
    +

    + {{ user.email_address }} +

    +
      +
      + {{ tick_cross( + user.has_permissions(permissions=['send_texts', 'send_emails', 'send_letters']), + 'Send messages' + ) }} + {{ tick_cross( + user.has_permissions(permissions=['manage_users', 'manage_templates', 'manage_settings']), + 'Manage service' + ) }} + {{ tick_cross( + user.has_permissions(permissions=['manage_api_keys']), + 'Access API keys' + ) }} +
      + +
    +
    + {% endfor %} +
    {% endif %} {% endblock %} diff --git a/tests/app/main/views/test_manage_users.py b/tests/app/main/views/test_manage_users.py index e090d443d..767fb752e 100644 --- a/tests/app/main/views/test_manage_users.py +++ b/tests/app/main/views/test_manage_users.py @@ -205,10 +205,9 @@ def test_manage_users_shows_invited_user(app_, assert response.status_code == 200 page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') assert page.h1.string.strip() == 'Team members' - invites_table = page.find_all('table')[1] - cols = invites_table.find_all('td') - assert cols[0].text.strip() == 'invited_user@test.gov.uk' - assert cols[4].text.strip() == 'Cancel invitation' + invited_users_list = page.find_all('div', {'class': 'user-list'})[1] + assert invited_users_list.find_all('h3')[0].text.strip() == 'invited_user@test.gov.uk' + assert invited_users_list.find_all('a')[0].text.strip() == 'Cancel invitation' def test_manage_users_does_not_show_accepted_invite(app_, @@ -232,8 +231,8 @@ def test_manage_users_does_not_show_accepted_invite(app_, assert response.status_code == 200 page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') assert page.h1.string.strip() == 'Team members' - tables = page.find_all('table') - assert len(tables) == 1 + user_lists = page.find_all('div', {'class': 'user-list'}) + assert len(user_lists) == 1 assert not page.find(text='invited_user@test.gov.uk') From 7edff474103f938d99c4a762eae8175d3afa1872 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 7 Jul 2016 12:34:38 +0100 Subject: [PATCH 04/30] Put email address on team page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Right now, a user can change their name and masquerade as someone else and the service manager has no way of telling who is who. This is also true for platform admins, where they can see the users of a service but can’t identify which department they are from. This commit adds a user’s email address next to their name to remedy this. --- app/templates/views/manage-users.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/templates/views/manage-users.html b/app/templates/views/manage-users.html index 928423489..34dc100ab 100644 --- a/app/templates/views/manage-users.html +++ b/app/templates/views/manage-users.html @@ -40,6 +40,8 @@ Manage users – GOV.UK Notify {{ user.name }}  {%- if user.email_address == current_user.email_address -%} (you) + {% else %} + {{ user.email_address }} {% endif %} From 0cc3bb5970b5e7089dab18675b7fdcb2de5fa74b Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Fri, 8 Jul 2016 14:38:59 +0100 Subject: [PATCH 05/30] using python3 in falback venv --- scripts/bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 82274e091..c4d81cb44 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -21,7 +21,7 @@ function display_result { } if [ ! $VIRTUAL_ENV ]; then - virtualenv ./venv + virtualenv -p python3 ./venv . ./venv/bin/activate fi From f9a90485793ff10dffe9d8af672fb97e918572ba Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 11 Jul 2016 10:45:54 +0100 Subject: [PATCH 06/30] =?UTF-8?q?Make=20=E2=80=98temporary=20failure?= =?UTF-8?q?=E2=80=99=20error=20less=20cryptic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ‘Phone number doesn’t exist’ as opposed to ‘Permanent failure’ has tested well because it talks in terms of things people understand. We should do the same for ‘Temporary failure’, because users are unclear: - why this is happening - if it’s temporary, is Notify going to retry it (it’s not) We think that ‘Phone/inbox not currently accepting messages’ answers makes these things clearer. I’ve reworded it slightly to: - ‘Inbox not accepting messages right now’ - ‘Phone not accepting messages right now’ --- app/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index d4211a033..89e9e91cb 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -235,16 +235,16 @@ def format_notification_status(status, template_type): 'email': { 'failed': 'Failed', 'technical-failure': 'Technical failure', - 'temporary-failure': 'Temporary failure', - 'permanent-failure': 'Email address does not exist', + 'temporary-failure': 'Inbox not accepting messages right now', + 'permanent-failure': 'Email address doesn’t exist', 'delivered': 'Delivered', 'sending': 'Sending' }, 'sms': { 'failed': 'Failed', 'technical-failure': 'Technical failure', - 'temporary-failure': 'Temporary failure', - 'permanent-failure': 'Phone number does not exist', + 'temporary-failure': 'Phone not accepting messages right now', + 'permanent-failure': 'Phone number doesn’t exist', 'delivered': 'Delivered', 'sending': 'Sending' } From 50c20ce68020e5a09f6446a6d9ba3a05082d2310 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 11 Jul 2016 10:49:01 +0100 Subject: [PATCH 07/30] Add formatted notification status to CSV This commit makes the CSV download use the same language for failure reasons as the frontend. It also adds a test around this stuff, which was patchily tested before. --- app/utils.py | 4 +-- tests/__init__.py | 31 +++++++++++++--------- tests/app/main/views/test_jobs.py | 2 +- tests/app/test_utils.py | 44 ++++++++++++++++++++++++++++++- tests/conftest.py | 35 ++++++++++++++++++------ 5 files changed, 92 insertions(+), 24 deletions(-) diff --git a/app/utils.py b/app/utils.py index a6d38de51..6f2c9e3ec 100644 --- a/app/utils.py +++ b/app/utils.py @@ -89,7 +89,7 @@ def get_errors_for_csv(recipients, template_type): def generate_notifications_csv(json_list): - from app import format_datetime + from app import format_datetime, format_notification_status content = StringIO() retval = None with content as csvfile: @@ -102,7 +102,7 @@ def generate_notifications_csv(json_list): x['template']['name'], x['template']['template_type'], x['job']['original_file_name'] if x['job'] else '', - x['status'], + format_notification_status(x['status'], x['template']['template_type']), format_datetime(x['created_at'])]) retval = content.getvalue() return retval diff --git a/tests/__init__.py b/tests/__init__.py index 79dfd64f1..df6d357fb 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -149,13 +149,15 @@ def job_json(service_id, original_file_name="thisisatest.csv", notification_count=1, notifications_sent=1, - status=''): + status=None): if job_id is None: job_id = str(generate_uuid()) if template_id is None: template_id = str(generate_uuid()) if created_at is None: created_at = str(datetime.utcnow().time()) + if status is None: + status = 'Delivered' data = { 'id': job_id, 'service': service_id, @@ -174,16 +176,19 @@ def job_json(service_id, return data -def notification_json(service_id, - job=None, - template=None, - to='07123456789', - status='delivered', - sent_at=None, - job_row_number=None, - created_at=None, - updated_at=None, - with_links=False): +def notification_json( + service_id, + job=None, + template=None, + to='07123456789', + status=None, + sent_at=None, + job_row_number=None, + created_at=None, + updated_at=None, + with_links=False, + rows=5 +): if template is None: template = template_json(service_id, str(generate_uuid())) if sent_at is None: @@ -192,6 +197,8 @@ def notification_json(service_id, created_at = str(datetime.utcnow().time()) if updated_at is None: updated_at = str((datetime.utcnow() + timedelta(minutes=1)).time()) + if status is None: + status = 'delivered' links = {} if with_links: links = { @@ -213,7 +220,7 @@ def notification_json(service_id, 'updated_at': updated_at, 'job_row_number': job_row_number, 'template_version': template['version'] - } for i in range(5)], + } for i in range(rows)], 'total': 5, 'page_size': 50, 'links': links diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 850a6f80a..b7fcc6460 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -152,7 +152,7 @@ def test_should_show_updates_for_one_job_as_json( assert 'Recipient' in content['notifications'] assert '07123456789' in content['notifications'] assert 'Status' in content['notifications'] - assert job_json['status'] in content['status'] + print(content['notifications']) assert 'Delivered' in content['notifications'] assert '11:10' in content['notifications'] assert 'Uploaded by Test User on 1 January at 11:09' in content['status'] diff --git a/tests/app/test_utils.py b/tests/app/test_utils.py index edb400a33..4f64a5a09 100644 --- a/tests/app/test_utils.py +++ b/tests/app/test_utils.py @@ -1,4 +1,8 @@ -from app.utils import email_safe +import pytest +from io import StringIO +from app.utils import email_safe, generate_notifications_csv +from csv import DictReader +from freezegun import freeze_time def test_email_safe_return_dot_separated_email_domain(): @@ -6,3 +10,41 @@ def test_email_safe_return_dot_separated_email_domain(): expected = 'some.service.withstuff.b123' actual = email_safe(test_name) assert actual == expected + + +@pytest.mark.parametrize( + "status, template_type, expected_status", + [ + ('sending', None, 'Sending'), + ('delivered', None, 'Delivered'), + ('failed', None, 'Failed'), + ('technical-failure', None, 'Technical failure'), + ('temporary-failure', 'email', 'Inbox not accepting messages right now'), + ('permanent-failure', 'email', 'Email address doesn’t exist'), + ('temporary-failure', 'sms', 'Phone not accepting messages right now'), + ('permanent-failure', 'sms', 'Phone number doesn’t exist') + ] +) +@freeze_time("2016-01-01 11:09:00.061258") +def test_generate_csv_from_notifications( + app_, + service_one, + active_user_with_permissions, + mock_get_notifications, + status, + template_type, + expected_status +): + with app_.test_request_context(): + csv_content = generate_notifications_csv( + mock_get_notifications( + service_one['id'], + rows=1, + set_template_type=template_type, + set_status=status + )['notifications'] + ) + + for row in DictReader(StringIO(csv_content)): + assert row['Time'] == 'Friday 01 January 2016 at 11:09' + assert row['Status'] == expected_status diff --git a/tests/conftest.py b/tests/conftest.py index f54853382..35c881a18 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -870,17 +870,36 @@ def mock_get_jobs(mocker, api_user_active): @pytest.fixture(scope='function') def mock_get_notifications(mocker, api_user_active): - def _get_notifications(service_id, - job_id=None, - page=1, - page_size=50, - template_type=None, - status=None, - limit_days=None): + def _get_notifications( + service_id, + job_id=None, + page=1, + page_size=50, + template_type=None, + status=None, + limit_days=None, + rows=5, + set_template_type=None, + set_status=None + ): job = None if job_id is not None: job = job_json(service_id, api_user_active, job_id=job_id) - return notification_json(service_id, job=job) + if set_template_type: + return notification_json( + service_id, + template={'template_type': set_template_type, 'name': 'name', 'id': 'id', 'version': 1}, + rows=rows, + status=set_status, + job=job + ) + else: + return notification_json( + service_id, + rows=rows, + status=set_status, + job=job + ) return mocker.patch( 'app.notification_api_client.get_notifications_for_service', From 8d59b51387738898898144ca998ee6a20a42acf2 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 11 Jul 2016 13:40:27 +0100 Subject: [PATCH 08/30] Use shorter sentences to describe sending state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was running on a bit… --- app/templates/views/delivery-and-failure.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/views/delivery-and-failure.html b/app/templates/views/delivery-and-failure.html index eb409e73f..a5050a7e3 100644 --- a/app/templates/views/delivery-and-failure.html +++ b/app/templates/views/delivery-and-failure.html @@ -25,9 +25,9 @@ Delivery and failure – GOV.UK Notify

    Sending

    -

    All new messages start with the state ‘Sending’.

    +

    All messages start in the ‘Sending’ state.

    -

    This means that we have accepted the message, the message is waiting in a queue to be sent to our email or text message delivery partners.

    +

    This means that we have accepted the message. It’s waiting in a queue to be sent to our email or text message delivery partners.

    Delivered

    From 90bdf51e3a65b6263ce33122fbfee8818a3fb3f2 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 11 Jul 2016 13:41:43 +0100 Subject: [PATCH 09/30] Rename failure status on delivery page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …so that they agree with what we show in the interface/CSV, eg ‘phone does not exist’ instead of ‘permanent failure’. --- app/templates/views/delivery-and-failure.html | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/templates/views/delivery-and-failure.html b/app/templates/views/delivery-and-failure.html index a5050a7e3..22221bcb0 100644 --- a/app/templates/views/delivery-and-failure.html +++ b/app/templates/views/delivery-and-failure.html @@ -16,8 +16,9 @@ Delivery and failure – GOV.UK Notify @@ -35,19 +36,21 @@ Delivery and failure – GOV.UK Notify

    We can’t tell you if they’ve read it – to do so would require invasive and unreliable tracking techniques.

    -

    Permanently failed

    +

    Phone number or email address does not exist

    -

    This means the email address or mobile number doesn’t exist or is blacklisted – also known as a ‘hard bounce’.

    +

    You’re still billed for text messages to non-existant phone numbers.

    -

    You’re still billed for these text messages.

    +

    You need to remove the email address or mobile number from your database.

    -

    You need to remove this email address or mobile number from your database.

    +

    Inbox not accepting messages right now

    -

    Temporarily failed

    +

    This can happen for a number of reasons, eg the user’s inbox was full.

    -

    This means the email address or mobile number was full, or the mobile phone was switched off – also known as a ‘soft bounce’.

    +

    You can choose to retry this message later or not.

    -

    We mark messages as ‘Temporarily failed’.

    +

    Phone not accepting messages right now

    + +

    This means the user’s phone was full or hasn’t been switched on in the last 72 hours.

    You’re still billed for these messages.

    From d22b2f678dff365db79d1a9610efbb24e9913d13 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 11 Jul 2016 13:42:26 +0100 Subject: [PATCH 10/30] =?UTF-8?q?Make=20=E2=80=98message=E2=80=99=20plural?= =?UTF-8?q?=20when=20talking=20about=20retries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In each of these cases the previous sentence talks about messages, plural, so these lines should agree. --- app/templates/views/delivery-and-failure.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/templates/views/delivery-and-failure.html b/app/templates/views/delivery-and-failure.html index 22221bcb0..4a9153ef8 100644 --- a/app/templates/views/delivery-and-failure.html +++ b/app/templates/views/delivery-and-failure.html @@ -40,13 +40,13 @@ Delivery and failure – GOV.UK Notify

    You’re still billed for text messages to non-existant phone numbers.

    -

    You need to remove the email address or mobile number from your database.

    +

    You need to remove these email addresses or phone numbers from your database.

    Inbox not accepting messages right now

    This can happen for a number of reasons, eg the user’s inbox was full.

    -

    You can choose to retry this message later or not.

    +

    You can choose to retry these messages later or not.

    Phone not accepting messages right now

    @@ -54,7 +54,7 @@ Delivery and failure – GOV.UK Notify

    You’re still billed for these messages.

    -

    You can choose to retry this message later or not.

    +

    You can choose to retry these messages later or not.

    Technical failure

    @@ -64,7 +64,7 @@ Delivery and failure – GOV.UK Notify

    You won’t be billed for these messages.

    -

    You need to retry this message yourself later.

    +

    You need to retry these messages yourself later.

    From 5f67560b1ebce9a78f06f306d76f4e1cc74a90e3 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 11 Jul 2016 13:53:55 +0100 Subject: [PATCH 11/30] Link to failure reasons from job/activity pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If something has failed and you don’t know why, you should be able to find out why. Let’s try adding a link to the page explaining why, so it’s not just buried in the footer. --- app/__init__.py | 14 +++++++++++++- app/templates/partials/jobs/notifications.html | 6 ++++++ app/templates/views/delivery-and-failure.html | 2 ++ app/templates/views/notifications.html | 6 ++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/__init__.py b/app/__init__.py index 89e9e91cb..e2852b6b3 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -12,7 +12,9 @@ from flask import ( make_response, current_app, request, - g) + g, + url_for +) from flask._compat import string_types from flask.globals import _lookup_req_object from flask_login import LoginManager @@ -112,6 +114,7 @@ def create_app(): application.add_template_filter(format_date_short) application.add_template_filter(format_notification_status) application.add_template_filter(format_notification_status_as_field_status) + application.add_template_filter(format_notification_status_as_url) application.after_request(useful_headers_after_request) application.after_request(save_service_after_request) @@ -262,6 +265,15 @@ def format_notification_status_as_field_status(status): }.get(status, 'error') +def format_notification_status_as_url(status): + url = partial(url_for, "main.delivery_and_failure") + return { + 'technical-failure': url(_anchor='technical-failure'), + 'temporary-failure': url(_anchor='not-accepting-messages'), + 'permanent-failure': url(_anchor='does-not-exist') + }.get(status) + + @login_manager.user_loader def load_user(user_id): return user_api_client.get_user(user_id) diff --git a/app/templates/partials/jobs/notifications.html b/app/templates/partials/jobs/notifications.html index 506c2007d..74971d1d8 100644 --- a/app/templates/partials/jobs/notifications.html +++ b/app/templates/partials/jobs/notifications.html @@ -34,7 +34,13 @@ align='right', status=item.status|format_notification_status_as_field_status ) %} + {% if item.status|format_notification_status_as_url %} + + {% endif %} {{ item.status|format_notification_status(item.template.template_type) }} + {% if item.status|format_notification_status_as_url %} + + {% endif %} {% endcall %} {% endcall %} diff --git a/app/templates/views/delivery-and-failure.html b/app/templates/views/delivery-and-failure.html index 4a9153ef8..ac3c9a8f8 100644 --- a/app/templates/views/delivery-and-failure.html +++ b/app/templates/views/delivery-and-failure.html @@ -42,6 +42,8 @@ Delivery and failure – GOV.UK Notify

    You need to remove these email addresses or phone numbers from your database.

    + +

    Inbox not accepting messages right now

    This can happen for a number of reasons, eg the user’s inbox was full.

    diff --git a/app/templates/views/notifications.html b/app/templates/views/notifications.html index 592eb3ec1..69d8ed40e 100644 --- a/app/templates/views/notifications.html +++ b/app/templates/views/notifications.html @@ -73,7 +73,13 @@ ) }} {% call field(status=item.status|format_notification_status_as_field_status, align='right') %} + {% if item.status|format_notification_status_as_url %} + + {% endif %} {{ item.status|format_notification_status(item.template.template_type) }} + {% if item.status|format_notification_status_as_url %} + + {% endif %} {% endcall %} {% endcall %} From fc3d155f3bfcffc7d886a2e6af147e0ce897a611 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 14:41:20 +0100 Subject: [PATCH 12/30] add info about keys --- docs/index.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/index.md b/docs/index.md index 5be0824ac..47b277bd0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,6 +8,8 @@ This document is for central government developers and technical architects who * [Authenticate requests](#AuthRequests) * [JSON Web Tokens: claims](#JWT_claims) * [API client libraries](#client_libraries) +* [test_integ](#Testing your integration with GOV.UK Notify) + * [API_keys](#API keys) * [API endpoints](#API_endpoints) * [Send notifications: POST](#sendnotifications) * [Retrieve notifications: GET](#getnotifications) @@ -111,6 +113,41 @@ GOV.UK Notify supports the following client libraries: These provide example code for calling the API and for creating API tokens. +

    Testing your integration with GOV.UK Notify

    + +Service teams should do all their testing within the GOV.UK Notify production environment (https://api.notifications.service.gov.uk). + +You don’t need different service accounts or environments. Instead, there are 3 types of API key that let you do functional and performance integration testing. + +

    API keys

    + +The types of API key that you can create within GOV.UK Notify are: + +* normal key +* team key + +

    Normal keys

    + +Normal keys have the same permissions as the service: + +* when the service is in ‘Trial mode’, you can only send to members of your team and you are restricted to 50 messages per day +* when the service is live, you can use the key to send messages to anyone + +Messages sent with a normal key show up on your dashboard and count against your text message and email allowances. + +There is no need to generate a new key when the service moves from trial to live. + +Don’t use your normal key for automated testing. + +

    Team keys

    + +Use a team key for end-to-end functional testing. + +A team key lets you send real messages to members of your team. You get an error if you try to send messages to anyone else. + +Messages sent with a team key show up on your dashboard and count against your text message and email allowances. + +

    API endpoints

    You can use the GOV.UK Notify API to: From d1e885954b9bea30b48a858ace6927e079a09161 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 14:55:11 +0100 Subject: [PATCH 13/30] Add Test key --- docs/index.md | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/docs/index.md b/docs/index.md index 47b277bd0..28a0a755c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,8 +8,8 @@ This document is for central government developers and technical architects who * [Authenticate requests](#AuthRequests) * [JSON Web Tokens: claims](#JWT_claims) * [API client libraries](#client_libraries) -* [test_integ](#Testing your integration with GOV.UK Notify) - * [API_keys](#API keys) +* [Testing your integration with GOV.UK Notify](#test_integ) + * [API keys](#API_keys) * [API endpoints](#API_endpoints) * [Send notifications: POST](#sendnotifications) * [Retrieve notifications: GET](#getnotifications) @@ -121,10 +121,11 @@ You don’t need different service accounts or environments. Instead, there are

    API keys

    -The types of API key that you can create within GOV.UK Notify are: +The 3 types of API key that you can create within GOV.UK Notify are: * normal key * team key +* team key

    Normal keys

    @@ -141,13 +142,31 @@ Don’t use your normal key for automated testing.

    Team keys

    -Use a team key for end-to-end functional testing. +Use team keys for end-to-end functional testing. A team key lets you send real messages to members of your team. You get an error if you try to send messages to anyone else. Messages sent with a team key show up on your dashboard and count against your text message and email allowances. +

    Test keys

    + +Use test keys to test the performance of your service and its integration with GOV.UK Notify under load. + +Test keys don’t send real messages but generate realistic responses. There’s no restriction on who you can send to or how many messages you can send per day. + +Messages sent using a test key don’t show up on your dashboard or count against your text message and email allowances. + +

    GOV.UK Notify API keys

    + +Sends real messages? | Appears in activity and statistics? | Daily service limit +--- | --- | --- +Normal key | Yes | Yes | 50 (trial) Unlimited (live) +Team key | Yes (only team members) | Yes | 50 (trial) Unlimited (live) +Test key | No | No | Unlimited + + +

    API endpoints

    You can use the GOV.UK Notify API to: From dd729a76b2eaf5382a9294b24272441df1e2c5b9 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:00:03 +0100 Subject: [PATCH 14/30] API keys, work --- docs/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/index.md b/docs/index.md index 28a0a755c..c5d01bc02 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,7 +8,7 @@ This document is for central government developers and technical architects who * [Authenticate requests](#AuthRequests) * [JSON Web Tokens: claims](#JWT_claims) * [API client libraries](#client_libraries) -* [Testing your integration with GOV.UK Notify](#test_integ) +* [Test your integration with GOV.UK Notify](#test_integ) * [API keys](#API_keys) * [API endpoints](#API_endpoints) * [Send notifications: POST](#sendnotifications) @@ -113,7 +113,7 @@ GOV.UK Notify supports the following client libraries: These provide example code for calling the API and for creating API tokens. -

    Testing your integration with GOV.UK Notify

    +

    Test your integration with GOV.UK Notify

    Service teams should do all their testing within the GOV.UK Notify production environment (https://api.notifications.service.gov.uk). @@ -131,7 +131,7 @@ The 3 types of API key that you can create within GOV.UK Notify are: Normal keys have the same permissions as the service: -* when the service is in ‘Trial mode’, you can only send to members of your team and you are restricted to 50 messages per day +* when the service is in trial mode, you can send only to members of your team and you are restricted to 50 messages per day * when the service is live, you can use the key to send messages to anyone Messages sent with a normal key show up on your dashboard and count against your text message and email allowances. @@ -160,7 +160,7 @@ Messages sent using a test key don’t show up on your dashboard or count agains

    GOV.UK Notify API keys

    Sends real messages? | Appears in activity and statistics? | Daily service limit ---- | --- | --- +--- | --- | --- | --- Normal key | Yes | Yes | 50 (trial) Unlimited (live) Team key | Yes (only team members) | Yes | 50 (trial) Unlimited (live) Test key | No | No | Unlimited From 488de1ce7c86cf930ea4e72408049205fef0bbad Mon Sep 17 00:00:00 2001 From: Pete Herlihy Date: Mon, 11 Jul 2016 15:01:28 +0100 Subject: [PATCH 15/30] Removed 'states are the same for email and text' blurb. --- app/templates/views/delivery-and-failure.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/templates/views/delivery-and-failure.html b/app/templates/views/delivery-and-failure.html index ac3c9a8f8..e5de2bc10 100644 --- a/app/templates/views/delivery-and-failure.html +++ b/app/templates/views/delivery-and-failure.html @@ -22,8 +22,6 @@ Delivery and failure – GOV.UK Notify
  • Technical failure
  • -

    Our delivery states are the same for both email and text message.

    -

    Sending

    All messages start in the ‘Sending’ state.

    From bef9e7cbe5ab64db2dc188ca29b91a89bc75ead2 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:01:49 +0100 Subject: [PATCH 16/30] API keys table --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index c5d01bc02..a686a3339 100644 --- a/docs/index.md +++ b/docs/index.md @@ -159,7 +159,7 @@ Messages sent using a test key don’t show up on your dashboard or count agains

    GOV.UK Notify API keys

    -Sends real messages? | Appears in activity and statistics? | Daily service limit +Type of key | Sends real messages? | Appears in activity and statistics? | Daily service limit --- | --- | --- | --- Normal key | Yes | Yes | 50 (trial) Unlimited (live) Team key | Yes (only team members) | Yes | 50 (trial) Unlimited (live) From 66528d953d4610534fd963f85c59a6193232e238 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:04:21 +0100 Subject: [PATCH 17/30] links to sections --- docs/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/index.md b/docs/index.md index a686a3339..2bb9ce31c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -123,9 +123,9 @@ You don’t need different service accounts or environments. Instead, there are The 3 types of API key that you can create within GOV.UK Notify are: -* normal key -* team key -* team key +* [normal keys](#normal_keys) +* [team keys](#team_keys) +* [test keys](#test_keys)

    Normal keys

    From 280a140e4e2028bc80092666d7601f273251b457 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:05:23 +0100 Subject: [PATCH 18/30] API keys table --- docs/index.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 2bb9ce31c..ecaece0ad 100644 --- a/docs/index.md +++ b/docs/index.md @@ -161,8 +161,12 @@ Messages sent using a test key don’t show up on your dashboard or count agains Type of key | Sends real messages? | Appears in activity and statistics? | Daily service limit --- | --- | --- | --- -Normal key | Yes | Yes | 50 (trial) Unlimited (live) -Team key | Yes (only team members) | Yes | 50 (trial) Unlimited (live) +Normal key | Yes | Yes | 50 (trial) + +Unlimited (live) +Team key | Yes (only team members) | Yes | 50 (trial) + +Unlimited (live) Test key | No | No | Unlimited From 4f4614a2acbfbf73808de2e4d846e713e0404c44 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:05:52 +0100 Subject: [PATCH 19/30] API keys table --- docs/index.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index ecaece0ad..7c82612d3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -162,10 +162,8 @@ Messages sent using a test key don’t show up on your dashboard or count agains Type of key | Sends real messages? | Appears in activity and statistics? | Daily service limit --- | --- | --- | --- Normal key | Yes | Yes | 50 (trial) - Unlimited (live) Team key | Yes (only team members) | Yes | 50 (trial) - Unlimited (live) Test key | No | No | Unlimited From ec77d60c8fe1f2063e710c0d5525662afdf3f3eb Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:06:25 +0100 Subject: [PATCH 20/30] API keys table --- docs/index.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/index.md b/docs/index.md index 7c82612d3..2bb9ce31c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -161,10 +161,8 @@ Messages sent using a test key don’t show up on your dashboard or count agains Type of key | Sends real messages? | Appears in activity and statistics? | Daily service limit --- | --- | --- | --- -Normal key | Yes | Yes | 50 (trial) -Unlimited (live) -Team key | Yes (only team members) | Yes | 50 (trial) -Unlimited (live) +Normal key | Yes | Yes | 50 (trial) Unlimited (live) +Team key | Yes (only team members) | Yes | 50 (trial) Unlimited (live) Test key | No | No | Unlimited From cd94e37b7c02c44adcc1bc5a36622234de718cf8 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:07:55 +0100 Subject: [PATCH 21/30] move table up --- docs/index.md | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/docs/index.md b/docs/index.md index 2bb9ce31c..b95814918 100644 --- a/docs/index.md +++ b/docs/index.md @@ -127,6 +127,12 @@ The 3 types of API key that you can create within GOV.UK Notify are: * [team keys](#team_keys) * [test keys](#test_keys) +Type of key | Sends real messages? | Appears in activity and statistics? | Daily service limit +--- | --- | --- | --- +Normal key | Yes | Yes | 50 (trial) Unlimited (live) +Team key | Yes (only team members) | Yes | 50 (trial) Unlimited (live) +Test key | No | No | Unlimited +

    Normal keys

    Normal keys have the same permissions as the service: @@ -157,16 +163,6 @@ Test keys don’t send real messages but generate realistic responses. There’s Messages sent using a test key don’t show up on your dashboard or count against your text message and email allowances. -

    GOV.UK Notify API keys

    - -Type of key | Sends real messages? | Appears in activity and statistics? | Daily service limit ---- | --- | --- | --- -Normal key | Yes | Yes | 50 (trial) Unlimited (live) -Team key | Yes (only team members) | Yes | 50 (trial) Unlimited (live) -Test key | No | No | Unlimited - - -

    API endpoints

    You can use the GOV.UK Notify API to: From 23082d784bc3c080c652681e7c4356e81b8d5c77 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:17:06 +0100 Subject: [PATCH 22/30] minor edit to respect style guide --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index b95814918..57af01b51 100644 --- a/docs/index.md +++ b/docs/index.md @@ -23,7 +23,7 @@ This document is for central government developers and technical architects who GOV.UK Notify is a cross-government platform that lets government services send notifications by text or email. It's currently in beta. -There are 2 ways to send notifications: +To send notifications you can: * use the [GOV.UK Notify](https://www.notifications.service.gov.uk/) web application * [integrate your web applications or back office systems](#integrate_Notify) with the GOV.UK Notify API From 2a10134087572efa56d1b7b47905bee4506e80c0 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:40:36 +0100 Subject: [PATCH 23/30] add 'to' --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 57af01b51..c1f610555 100644 --- a/docs/index.md +++ b/docs/index.md @@ -28,7 +28,7 @@ To send notifications you can: * use the [GOV.UK Notify](https://www.notifications.service.gov.uk/) web application * [integrate your web applications or back office systems](#integrate_Notify) with the GOV.UK Notify API -The GOV.UK Notify allows you to [send notifications (POST)](#sendnotifications) and [get the status of notifications (GET)](#getnotifications) you have sent. +The GOV.UK Notify API allows you to [send notifications (POST)](#sendnotifications) and [get the status of notifications (GET)](#getnotifications) you have sent. To find out more about GOV.UK Notify, see the [Government as a Platform](https://governmentasaplatform.blog.gov.uk/) blog. @@ -130,7 +130,7 @@ The 3 types of API key that you can create within GOV.UK Notify are: Type of key | Sends real messages? | Appears in activity and statistics? | Daily service limit --- | --- | --- | --- Normal key | Yes | Yes | 50 (trial) Unlimited (live) -Team key | Yes (only team members) | Yes | 50 (trial) Unlimited (live) +Team key | Yes (only to team members) | Yes | 50 (trial) Unlimited (live) Test key | No | No | Unlimited

    Normal keys

    From 0ea063f96894bfa9f71f4a82bc1cd2a8a428a760 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:41:15 +0100 Subject: [PATCH 24/30] add commas in table --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index c1f610555..16b086c5c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -129,8 +129,8 @@ The 3 types of API key that you can create within GOV.UK Notify are: Type of key | Sends real messages? | Appears in activity and statistics? | Daily service limit --- | --- | --- | --- -Normal key | Yes | Yes | 50 (trial) Unlimited (live) -Team key | Yes (only to team members) | Yes | 50 (trial) Unlimited (live) +Normal key | Yes | Yes | 50 (trial), Unlimited (live) +Team key | Yes (only to team members) | Yes | 50 (trial), Unlimited (live) Test key | No | No | Unlimited

    Normal keys

    From 96eb67613efd813e6657d607eed034603dbb1f9f Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:42:18 +0100 Subject: [PATCH 25/30] reformat info in table for test --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 16b086c5c..043b0886c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -129,7 +129,7 @@ The 3 types of API key that you can create within GOV.UK Notify are: Type of key | Sends real messages? | Appears in activity and statistics? | Daily service limit --- | --- | --- | --- -Normal key | Yes | Yes | 50 (trial), Unlimited (live) +Normal key | Yes | Yes | Trial: 50; Live: unlimited Team key | Yes (only to team members) | Yes | 50 (trial), Unlimited (live) Test key | No | No | Unlimited From 1f38f8293be0abffddad489d41bc1563c4f0dff2 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:43:30 +0100 Subject: [PATCH 26/30] revert --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 043b0886c..1a4dfe21e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -129,8 +129,8 @@ The 3 types of API key that you can create within GOV.UK Notify are: Type of key | Sends real messages? | Appears in activity and statistics? | Daily service limit --- | --- | --- | --- -Normal key | Yes | Yes | Trial: 50; Live: unlimited -Team key | Yes (only to team members) | Yes | 50 (trial), Unlimited (live) +Normal key | Yes | Yes | 50 (trial), unlimited (live) +Team key | Yes (only to team members) | Yes | 50 (trial), unlimited (live) Test key | No | No | Unlimited

    Normal keys

    From 4da3baffe4d78a0a44e7082d31cd4be77220e741 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:45:07 +0100 Subject: [PATCH 27/30] link to API keys section --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 1a4dfe21e..20d10c0a2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -48,7 +48,7 @@ To find out more about GOV.UK Notify, see the [Government as a Platform](https:/ > > Your ((item)) is due for renewal on ((date)). - 3. Create an API key. This will be used to connect to the GOV.UK Notify API. + 3. Create an [API key](#API_keys). This will be used to connect to the GOV.UK Notify API. Each service can have multiple API keys. This allows you to integrate several systems, each with its own key. You can also have separate keys for your development and test environments. From f17675155ba2f069b7eea5a9670681bdab7af969 Mon Sep 17 00:00:00 2001 From: Catherine Heywood Date: Mon, 11 Jul 2016 15:46:42 +0100 Subject: [PATCH 28/30] improve readability --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 20d10c0a2..a5e810231 100644 --- a/docs/index.md +++ b/docs/index.md @@ -159,7 +159,7 @@ Messages sent with a team key show up on your dashboard and count against your t Use test keys to test the performance of your service and its integration with GOV.UK Notify under load. -Test keys don’t send real messages but generate realistic responses. There’s no restriction on who you can send to or how many messages you can send per day. +Test keys don’t send real messages but they do generate realistic responses. There’s no restriction on who you can send to or how many messages you can send per day. Messages sent using a test key don’t show up on your dashboard or count against your text message and email allowances. From f3cf4bf7082027d4c75292b48d34a8582a0c5ef5 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 12 Jul 2016 09:08:42 +0100 Subject: [PATCH 29/30] Fix mismatch HTML tags in doc --- docs/index.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/index.md b/docs/index.md index 19fc2e863..42645b3f8 100644 --- a/docs/index.md +++ b/docs/index.md @@ -59,7 +59,7 @@ To find out more about GOV.UK Notify, see the [Government as a Platform](https:/ There are 2 ways to integrate the API into your service: * use one of the client libraries provided by GOV.UK Notify: - + * [Python library](https://github.com/alphagov/notifications-python-client/blob/master/README.md#usage) * [PHP library](https://github.com/alphagov/notifications-php-client/blob/master/README.md#usage) * [Java library](https://github.com/alphagov/notifications-java-client) @@ -123,9 +123,9 @@ You don’t need different service accounts or environments. Instead, there are The 3 types of API key that you can create within GOV.UK Notify are: -* [normal keys](#normal_keys) +* [normal keys](#normal_keys) * [team keys](#team_keys) -* [test keys](#test_keys) +* [test keys](#test_keys) Type of key | Sends real messages? | Appears in activity and statistics? | Daily service limit --- | --- | --- | --- @@ -133,12 +133,13 @@ Normal key | Yes | Yes | 50 (trial), unlimited (live) Team key | Yes (only to team members) | Yes | 50 (trial), unlimited (live) Test key | No | No | Unlimited -

    Normal keys

    +

    Normal keys

    Normal keys have the same permissions as the service: * when the service is in trial mode, you can send only to members of your team and you are restricted to 50 messages per day * when the service is live, you can use the key to send messages to anyone +* three Messages sent with a normal key show up on your dashboard and count against your text message and email allowances. @@ -146,7 +147,7 @@ There is no need to generate a new key when the service moves from trial to live Don’t use your normal key for automated testing. -

    Team keys

    +

    Team keys

    Use team keys for end-to-end functional testing. @@ -155,7 +156,7 @@ A team key lets you send real messages to members of your team. You get an error Messages sent with a team key show up on your dashboard and count against your text message and email allowances. -

    Test keys

    +

    Test keys

    Use test keys to test the performance of your service and its integration with GOV.UK Notify under load. From df63dc52453658475e1188e46681439310cf0472 Mon Sep 17 00:00:00 2001 From: catherineheywood Date: Tue, 12 Jul 2016 09:20:41 +0100 Subject: [PATCH 30/30] Remove sections Remove sections About GOV.UK Notify and Getting started --- docs/index.md | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/docs/index.md b/docs/index.md index 42645b3f8..23a603249 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,8 +2,6 @@ This document is for central government developers and technical architects who want to use the GOV.UK Notify platform to send notifications to users of their digital service. -* [About GOV.UK Notify](#about_Notify) -* [Before you start](#beforestart) * [Integrate the GOV.UK Notify API into your service](#integrate_Notify) * [Authenticate requests](#AuthRequests) * [JSON Web Tokens: claims](#JWT_claims) @@ -19,40 +17,7 @@ This document is for central government developers and technical architects who -

    About GOV.UK Notify

    -GOV.UK Notify is a cross-government platform that lets government services send notifications by text or email. It's currently in beta. - -To send notifications you can: - -* use the [GOV.UK Notify](https://www.notifications.service.gov.uk/) web application -* [integrate your web applications or back office systems](#integrate_Notify) with the GOV.UK Notify API - -The GOV.UK Notify API allows you to [send notifications (POST)](#sendnotifications) and [get the status of notifications (GET)](#getnotifications) you have sent. - -To find out more about GOV.UK Notify, see the [Government as a Platform](https://governmentasaplatform.blog.gov.uk/) blog. - -

    Before you start

    - - 1. Register for a [GOV.UK Notify](https://www.notifications.service.gov.uk/) account. - - You'll need an email address from a local or central government organisation and your mobile phone for 2-factor authentication. - - 2. Add a template so you can send text and email notifications. - - **Note:** A template is required even if you send notifications with the GOV.UK Notify API. - - You can personalise the template using double brackets for placeholders. For example: - - > Dear ((name)), - > - > Your ((item)) is due for renewal on ((date)). - - 3. Create an [API key](#API_keys). This will be used to connect to the GOV.UK Notify API. - - Each service can have multiple API keys. This allows you to integrate several systems, each with its own key. You can also have separate keys for your development and test environments. - - **Important:** API keys are secret, so save them somewhere safe. Don't commit API keys to public source code repositories.

    Integrate the GOV.UK Notify API into your service