Merge pull request #397 from alphagov/human-readable-phone-numbers

Make it easier to deal with phone numbers in spreadsheets
This commit is contained in:
Chris Hill-Scott
2016-04-06 11:44:32 +01:00
16 changed files with 36 additions and 25 deletions

View File

@@ -73,6 +73,10 @@
}
&-index {
width: 15px;
}
}
.table-field-heading {

View File

@@ -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

View File

@@ -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 @@
</td>
{%- endmacro %}
{% macro index_field(text) -%}
<td class="table-field-index">
<span>{{ text }}</span>
</td>
{%- endmacro %}
{% macro text_field(text) -%}
{% call field() %}
{{ text }}

View File

@@ -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,

View File

@@ -29,7 +29,7 @@
{{ current_service.id }}
</p>
{% call(item) list_table(
{% call(item, row_number) list_table(
keys,
empty_message="You havent created any API keys yet",
caption="API keys",

View File

@@ -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 @@
</form>
{% 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() %}

View File

@@ -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 havent sent any batch messages yet',

View File

@@ -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 havent sent any batch messages yet',

View File

@@ -19,7 +19,7 @@
<a href="{{ url_for(".view_notifications", service_id=current_service.id, job_id=job_id, status=['sent', 'delivered'], page=1) }}">Successful messages</a>&emsp;
<a href="{{ url_for(".view_notifications", service_id=current_service.id, job_id=job_id, status=['failed', 'complaint', 'bounce'], page=1) }}">Failed messages</a>
</p>
{% call(item) list_table(
{% call(item, row_number) list_table(
jobs,
caption="Recent activity",
caption_visible=False,

View File

@@ -29,7 +29,7 @@ Manage users GOV.UK Notify
{% endif %}
</div>
{% 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() %}

View File

@@ -20,7 +20,7 @@
<a href="{{ url_for(".view_notifications", service_id=current_service.id, status=['sent', 'delivered'], page=1) }}">Successful messages</a>&emsp;
<a href="{{ url_for(".view_notifications", service_id=current_service.id, status=['failed', 'complaint', 'bounce'], page=1) }}">Failed messages</a>
</p>
{% call(item) list_table(
{% call(item, row_number) list_table(
notifications,
caption="Recent activity",
caption_visible=False,

View File

@@ -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:
</p>
{% 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 %}

View File

@@ -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'],

View File

@@ -9,7 +9,7 @@
<h1 class="heading-large">Your profile</h1>
{% 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')},

View File

@@ -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

View File

@@ -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']