diff --git a/app/assets/stylesheets/components/table.scss b/app/assets/stylesheets/components/table.scss index 8a37c677e..fe6ff2016 100644 --- a/app/assets/stylesheets/components/table.scss +++ b/app/assets/stylesheets/components/table.scss @@ -73,6 +73,10 @@ } + &-index { + width: 15px; + } + } .table-field-heading { diff --git a/app/main/views/send.py b/app/main/views/send.py index 98fde5e54..a44626776 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -18,7 +18,7 @@ from flask import ( from flask_login import login_required, current_user from utils.template import Template -from utils.recipients import RecipientCSV, first_column_heading +from utils.recipients import RecipientCSV, first_column_heading, validate_and_format_phone_number from app.main import main from app.main.forms import CsvUploadForm @@ -55,7 +55,9 @@ def get_example_csv_rows(template, number_of_rows=2): [ { 'email': current_user.email_address, - 'sms': current_user.mobile_number + 'sms': validate_and_format_phone_number( + current_user.mobile_number, human_readable=True + ) }[template.template_type] ] + [ "{} {}".format(header, i) for header in template.placeholders diff --git a/app/templates/components/table.html b/app/templates/components/table.html index 9ab70a29f..f6a1ed0fe 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -29,7 +29,7 @@ {% call mapping_table(caption, field_headings, field_headings_visible, caption_visible) %} {% for item in items %} {% call row() %} - {{ parent_caller(item) }} + {{ parent_caller(item, loop.index + 1) }} {% endcall %} {% endfor %} {% if not items %} @@ -55,6 +55,12 @@ {%- endmacro %} +{% macro index_field(text) -%} + + {{ text }} + +{%- endmacro %} + {% macro text_field(text) -%} {% call field() %} {{ text }} diff --git a/app/templates/partials/jobs/notifications.html b/app/templates/partials/jobs/notifications.html index bc4ecfaaf..5a257f1b4 100644 --- a/app/templates/partials/jobs/notifications.html +++ b/app/templates/partials/jobs/notifications.html @@ -1,6 +1,6 @@ {% from "components/table.html" import list_table, field, right_aligned_field_heading %} -{% call(item) list_table( +{% call(item, row_number) list_table( notifications, caption=uploaded_file_name, caption_visible=False, diff --git a/app/templates/views/api-keys.html b/app/templates/views/api-keys.html index 2f1422fba..fd59b9f79 100644 --- a/app/templates/views/api-keys.html +++ b/app/templates/views/api-keys.html @@ -29,7 +29,7 @@ {{ current_service.id }}

- {% call(item) list_table( + {% call(item, row_number) list_table( keys, empty_message="You haven’t created any API keys yet", caption="API keys", diff --git a/app/templates/views/check.html b/app/templates/views/check.html index 549602ad0..37db226d8 100644 --- a/app/templates/views/check.html +++ b/app/templates/views/check.html @@ -2,7 +2,7 @@ {% from "components/banner.html" import banner_wrapper %} {% from "components/email-message.html" import email_message %} {% from "components/sms-message.html" import sms_message %} -{% from "components/table.html" import list_table, field, text_field, hidden_field_heading %} +{% from "components/table.html" import list_table, field, text_field, index_field, hidden_field_heading %} {% from "components/placeholder.html" import placeholder %} {% from "components/file-upload.html" import file_upload %} {% from "components/page-footer.html" import page_footer %} @@ -71,14 +71,12 @@ {% endif %} - {% call(item) list_table( + {% call(item, row_number) list_table( recipients.initial_annotated_rows_with_errors if rows_have_errors else recipients.initial_annotated_rows, caption=original_file_name, field_headings=['1'] + recipients.column_headers_with_placeholders_highlighted ) %} - {% call field() %} - {{ item.index + 2 }} - {% endcall %} + {{ index_field(item.index + 2) }} {% for column in recipients.column_headers %} {% if item[column].error %} {% call field() %} diff --git a/app/templates/views/dashboard/jobs.html b/app/templates/views/dashboard/jobs.html index e562111d1..7556dc85a 100644 --- a/app/templates/views/dashboard/jobs.html +++ b/app/templates/views/dashboard/jobs.html @@ -1,6 +1,6 @@ {% from "components/table.html" import list_table, field, right_aligned_field_heading, hidden_field_heading %} -{% call(item) list_table( +{% call(item, row_number) list_table( jobs, caption="Recent batch jobs", empty_message='You haven’t sent any batch messages yet', diff --git a/app/templates/views/dashboard/template-statistics.html b/app/templates/views/dashboard/template-statistics.html index 428269c96..beccff247 100644 --- a/app/templates/views/dashboard/template-statistics.html +++ b/app/templates/views/dashboard/template-statistics.html @@ -1,5 +1,5 @@ {% from "components/table.html" import list_table, field, right_aligned_field_heading %} -{% call(item) list_table( +{% call(item, row_number) list_table( template_statistics, caption="Recent templates used", empty_message='You haven’t sent any batch messages yet', diff --git a/app/templates/views/jobs/jobs.html b/app/templates/views/jobs/jobs.html index 29155f853..f13318692 100644 --- a/app/templates/views/jobs/jobs.html +++ b/app/templates/views/jobs/jobs.html @@ -19,7 +19,7 @@ Successful messagesFailed messages

- {% call(item) list_table( + {% call(item, row_number) list_table( jobs, caption="Recent activity", caption_visible=False, diff --git a/app/templates/views/manage-users.html b/app/templates/views/manage-users.html index df4aaba75..57be01c74 100644 --- a/app/templates/views/manage-users.html +++ b/app/templates/views/manage-users.html @@ -29,7 +29,7 @@ Manage users – GOV.UK Notify {% endif %} - {% call(item) list_table( + {% call(item, row_number) list_table( users, caption='Active', **table_options ) %} {% call field() %} @@ -48,7 +48,7 @@ Manage users – GOV.UK Notify {% endcall %} {% if invited_users %} - {% call(item) list_table( + {% call(item, row_number) list_table( invited_users, caption='Invited', **table_options ) %} {% call field() %} diff --git a/app/templates/views/notifications.html b/app/templates/views/notifications.html index f74ea97c4..d12601d87 100644 --- a/app/templates/views/notifications.html +++ b/app/templates/views/notifications.html @@ -20,7 +20,7 @@ Successful messagesFailed messages

- {% call(item) list_table( + {% call(item, row_number) list_table( notifications, caption="Recent activity", caption_visible=False, diff --git a/app/templates/views/send.html b/app/templates/views/send.html index d55694c85..f2dae8767 100644 --- a/app/templates/views/send.html +++ b/app/templates/views/send.html @@ -3,7 +3,7 @@ {% from "components/email-message.html" import email_message %} {% from "components/page-footer.html" import page_footer %} {% from "components/file-upload.html" import file_upload %} -{% from "components/table.html" import list_table, text_field %} +{% from "components/table.html" import list_table, text_field, index_field, index_field_heading %} {% block page_title %} Send text messages – GOV.UK Notify @@ -39,12 +39,13 @@ in your file, like this:

- {% call(item) list_table( + {% call(item, row_number) list_table( example, caption="Example", caption_visible=False, - field_headings=[recipient_column] + template.placeholders|list + field_headings=['1'] + [recipient_column] + template.placeholders|list ) %} + {{ index_field(row_number) }} {% for column in item %} {{ text_field(column) }} {% endfor %} diff --git a/app/templates/views/styleguide.html b/app/templates/views/styleguide.html index 2a767e3a9..fda319c10 100644 --- a/app/templates/views/styleguide.html +++ b/app/templates/views/styleguide.html @@ -178,7 +178,7 @@ {% endcall %} {% endcall %} - {% call(item) list_table( + {% call(item, row_number) list_table( [ { 'file': 'dispatch_20151114.csv', 'status': 'Queued' @@ -206,7 +206,7 @@ {% endcall %} {% endcall %} - {% call(item) list_table( + {% call(item, row_number) list_table( [], caption='Jobs', field_headings=['Job', 'Time'], diff --git a/app/templates/views/user-profile.html b/app/templates/views/user-profile.html index 4a563d0ad..9fa19d05c 100644 --- a/app/templates/views/user-profile.html +++ b/app/templates/views/user-profile.html @@ -9,7 +9,7 @@

Your profile

- {% call(item) list_table( + {% call(item, row_number) list_table( [ {'label': 'Name', 'value': current_user.name, 'url': url_for('.user_profile_name')}, {'label': 'Email address', 'value': current_user.email_address, 'url': url_for('.user_profile_email')}, diff --git a/requirements.txt b/requirements.txt index cf5dfeed9..3b1b1088c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,4 +14,4 @@ Pygments==2.0.2 git+https://github.com/alphagov/notifications-python-client.git@0.3.1#egg=notifications-python-client==0.3.1 -git+https://github.com/alphagov/notifications-utils.git@3.2.1#egg=notifications-utils==3.2.1 +git+https://github.com/alphagov/notifications-utils.git@3.3.0#egg=notifications-utils==3.3.0 diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index ed84b9404..02c942920 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -60,7 +60,7 @@ def test_send_test_sms_message_to_self( mock_get_users_by_service ): - expected_data = {'data': 'phone number\r\n07700 900762\r\n', 'file_name': 'Test run'} + expected_data = {'data': 'phone number\r\n07700 900 762\r\n', 'file_name': 'Test run'} mocker.patch('app.main.views.send.s3download', return_value='phone number\r\n+4412341234') with app_.test_request_context(): @@ -139,7 +139,7 @@ def test_download_example_csv( follow_redirects=True ) assert response.status_code == 200 - assert response.get_data(as_text=True) == 'phone number\r\n07700 900762\r\n07700 900762\r\n' + assert response.get_data(as_text=True) == 'phone number\r\n07700 900 762\r\n07700 900 762\r\n' assert 'text/csv' in response.headers['Content-Type']