From aa0663cad803ad9e32609b2246817e366124cc23 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 17 Dec 2015 11:14:19 +0000 Subject: [PATCH 1/9] =?UTF-8?q?Add=20messages=20to=20the=20current=20job?= =?UTF-8?q?=E2=80=99s=20history?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This mocks out a data structure for a job’s messages, and renders this data: - on the notification page, as a table, which links through to… - …the page for an indidivual message --- .../stylesheets/components/sms-message.scss | 1 + app/assets/stylesheets/components/table.scss | 42 ++++++++++- app/main/__init__.py | 2 +- app/main/views/index.py | 15 ---- app/main/views/jobs.py | 70 +++++++++++++++++++ app/templates/components/table.html | 10 ++- app/templates/views/job.html | 45 ++++++++++-- app/templates/views/notification.html | 9 ++- 8 files changed, 162 insertions(+), 32 deletions(-) create mode 100644 app/main/views/jobs.py diff --git a/app/assets/stylesheets/components/sms-message.scss b/app/assets/stylesheets/components/sms-message.scss index 9263b8ec5..bf59c33b5 100644 --- a/app/assets/stylesheets/components/sms-message.scss +++ b/app/assets/stylesheets/components/sms-message.scss @@ -28,6 +28,7 @@ } &-wrapper { + width: 100%; display: inline-block; box-sizing: border-box; position: relative; diff --git a/app/assets/stylesheets/components/table.scss b/app/assets/stylesheets/components/table.scss index 33ff865ef..37478ad6d 100644 --- a/app/assets/stylesheets/components/table.scss +++ b/app/assets/stylesheets/components/table.scss @@ -1,7 +1,43 @@ -.table { +.table-heading { + text-align: left; +} + +%table-field, +.table-field { + + &:last-child { + padding-right: 0; + } + + &-status { + + &-default { + color: $secondary-text-colour; + } + + &-error { + color: $error-colour; + font-weight: bold; + } - &-heading { - text-align: left; } } + +.table-field-heading { + + &:last-child { + padding-right: 0; + } + + &-right-aligned { + display: block; + text-align: right; + } + +} + +.table-field-right-aligned { + @extend .table-field; + text-align: right; +} diff --git a/app/main/__init__.py b/app/main/__init__.py index 021b5c086..9347c19b2 100644 --- a/app/main/__init__.py +++ b/app/main/__init__.py @@ -3,4 +3,4 @@ from flask import Blueprint main = Blueprint('main', __name__) -from app.main.views import index, sign_in, register, two_factor, verify, sms, add_service, code_not_received +from app.main.views import index, sign_in, register, two_factor, verify, sms, add_service, code_not_received, jobs diff --git a/app/main/views/index.py b/app/main/views/index.py index c9cdc41dd..918ae5521 100644 --- a/app/main/views/index.py +++ b/app/main/views/index.py @@ -45,21 +45,6 @@ def checkemail(): return render_template('views/check-email.html') -@main.route("/jobs") -def showjobs(): - return render_template('views/jobs.html') - - -@main.route("/jobs/job") -def showjob(): - return render_template('views/job.html') - - -@main.route("/jobs/job/notification") -def shownotification(): - return render_template('views/notification.html') - - @main.route("/forgot-password") def forgotpassword(): return render_template('views/forgot-password.html') diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py new file mode 100644 index 000000000..e57846a08 --- /dev/null +++ b/app/main/views/jobs.py @@ -0,0 +1,70 @@ +from flask import render_template + +from app.main import main + + +messages = [ + { + 'phone': '+44 7700 900 579', + 'message': 'Vehicle tax: Your vehicle tax for LV75 TDG expires…', + 'status': 'Delivered', + 'time': '13:42', + 'id': '0' + }, + { + 'phone': '+44 7700 900 306', + 'message': 'Vehicle tax: Your vehicle tax for PL53 GBD expires…', + 'status': 'Delivered', + 'time': '13:42', + 'id': '1' + }, + { + 'phone': '+44 7700 900 454', + 'message': 'Vehicle tax: Your vehicle tax for LV75 TDG expires…', + 'status': 'Delivered', + 'time': '13:42', + 'id': '2' + }, + { + 'phone': '+44 7700 900 522', + 'message': 'Vehicle tax: Your vehicle tax for RE67 PLM expires…', + 'status': 'Failed', + 'time': '13:42', + 'id': '3' + } +] + + +@main.route("/jobs") +def showjobs(): + return render_template('views/jobs.html') + + +@main.route("/jobs/job/") +def showjob(): + return render_template( + 'views/job.html', + messages=messages, + counts={ + 'total': len(messages), + 'delivered': len([ + message for message in messages if message['status'] == 'Delivered' + ]), + 'failed': len([ + message for message in messages if message['status'] == 'Failed' + ]) + }, + cost='£0.00', + uploaded_file_name='contact-demo.csv', + template_used='Reminder template' + ) + + +@main.route("/jobs/job/notification/") +def shownotification(notification_id): + return render_template( + 'views/notification.html', + message=[ + message for message in messages if message['id'] == notification_id + ][0] + ) diff --git a/app/templates/components/table.html b/app/templates/components/table.html index c104c926a..346e9e4c8 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -32,8 +32,12 @@ {%- endmacro %} -{% macro field(first=False, wide=False, action=False) -%} - - {{ caller() }} +{% macro field(align='left', status='') -%} + + {{ caller() }} {%- endmacro %} + +{% macro right_aligned_field_heading(text) %} + {{ text }} +{%- endmacro %} diff --git a/app/templates/views/job.html b/app/templates/views/job.html index 7457debbc..feec2bd36 100644 --- a/app/templates/views/job.html +++ b/app/templates/views/job.html @@ -1,4 +1,5 @@ {% extends "withnav_template.html" %} +{% from "components/table.html" import table, field, right_aligned_field_heading %} {% block page_title %} GOV.UK Notify | Notifications activity @@ -6,14 +7,44 @@ GOV.UK Notify | Notifications activity {% block maincolumn_content %} -

Notifications for a specific job

+

+ {{ uploaded_file_name }} sent with {{ template_used }} +

-

This page will be where we list the notifications for a specific job.

+

+ {{ counts.total }} text messages +

- - +

+ {{ counts.failed }} failed deliveries +

+ +

+ {{ cost }} total cost +

+ + {% call(item) table( + messages, + caption='', + caption_visible=False, + field_headings=[ + 'To', + 'Message', + right_aligned_field_heading('Delivery status') + ] + ) %} + {% call field() %} + {{item.phone}} + {% endcall %} + {% call field() %} + {{item.message}} + {% endcall %} + {% call field( + align='right', + status='error' if item.status == 'Failed' else 'default' + ) %} + {{ item.status }} {{ item.time }} + {% endcall %} + {% endcall %} {% endblock %} diff --git a/app/templates/views/notification.html b/app/templates/views/notification.html index 99a6902db..cb17512a8 100644 --- a/app/templates/views/notification.html +++ b/app/templates/views/notification.html @@ -1,4 +1,5 @@ {% extends "withnav_template.html" %} +{% from "components/sms-message.html" import sms_message %} {% block page_title %} GOV.UK Notify | Notifications activity @@ -7,12 +8,14 @@ GOV.UK Notify | Notifications activity {% block maincolumn_content %} -

A specific notification

+

+ Text message to {{ message.phone }} +

-

This page will be where we show what happened for a specific notification.

+ {{ sms_message(message.message) }}

- View other notifications in this job + View other notifications in this job

From 2acf599c0494490c0564d2d4d21c613ed0539ed1 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 17 Dec 2015 11:52:24 +0000 Subject: [PATCH 2/9] =?UTF-8?q?Add=20big=20number=20component=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …and count the messages to display some totals --- .../stylesheets/components/big-number.scss | 10 ++++++ app/assets/stylesheets/main.scss | 4 +++ app/assets/stylesheets/views/job.scss | 3 ++ app/templates/components/big-number.html | 6 ++++ app/templates/components/table.html | 4 +-- app/templates/views/job.html | 34 +++++++++++++------ 6 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 app/assets/stylesheets/components/big-number.scss create mode 100644 app/assets/stylesheets/views/job.scss create mode 100644 app/templates/components/big-number.html diff --git a/app/assets/stylesheets/components/big-number.scss b/app/assets/stylesheets/components/big-number.scss new file mode 100644 index 000000000..4beea24df --- /dev/null +++ b/app/assets/stylesheets/components/big-number.scss @@ -0,0 +1,10 @@ +.big-number { + + @include bold-48; + + &-label { + @include core-19; + display: block; + } + +} diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index d6f59934b..3c7ed051b 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -27,6 +27,7 @@ @import '../govuk_elements/public/sass/elements/panels'; @import '../govuk_elements/public/sass/elements/tables'; + // Specific to this application @import 'grids'; @import 'components/template-picker'; @@ -35,6 +36,9 @@ @import 'components/submit-form'; @import 'components/table'; @import 'components/navigation'; +@import 'components/big-number'; + +@import 'views/job'; // TODO: break this up @import 'app'; diff --git a/app/assets/stylesheets/views/job.scss b/app/assets/stylesheets/views/job.scss new file mode 100644 index 000000000..35d54e57d --- /dev/null +++ b/app/assets/stylesheets/views/job.scss @@ -0,0 +1,3 @@ +.job-totals { + margin-bottom: $gutter; +} diff --git a/app/templates/components/big-number.html b/app/templates/components/big-number.html new file mode 100644 index 000000000..089466c25 --- /dev/null +++ b/app/templates/components/big-number.html @@ -0,0 +1,6 @@ +{% macro big_number(number, label) %} +
+ {{ number }} + {{ label }} +
+{% endmacro %} diff --git a/app/templates/components/table.html b/app/templates/components/table.html index 346e9e4c8..ee3c2838f 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -1,6 +1,6 @@ -{% macro table(items, caption='', field_headings='', field_headings_visible=True) -%} +{% macro table(items, caption='', field_headings='', field_headings_visible=True, caption_visible=True) -%} - diff --git a/app/templates/views/job.html b/app/templates/views/job.html index feec2bd36..bdae79d11 100644 --- a/app/templates/views/job.html +++ b/app/templates/views/job.html @@ -11,21 +11,33 @@ GOV.UK Notify | Notifications activity {{ uploaded_file_name }} sent with {{ template_used }} -

- {{ counts.total }} text messages -

+
    +
  • + {{ big_number( + counts.total, + 'text message' if 1 == counts.total else 'text messages' + )}} +
  • +
  • + {{ big_number( + counts.failed, + 'failed delivery' if 1 == counts.failed else 'failed deliveries' + )}} +
  • +
  • + {{ big_number( + cost, 'total cost' + )}} +
  • +
-

- {{ counts.failed }} failed deliveries -

- -

- {{ cost }} total cost -

+

+ You uploaded contact-demo.csv today at 13:42 +

{% call(item) table( messages, - caption='', + caption='Messages', caption_visible=False, field_headings=[ 'To', From 034c70bc979ec3d8aa25fbd6dfce313985348167 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 17 Dec 2015 14:05:35 +0000 Subject: [PATCH 3/9] =?UTF-8?q?Add=20a=20banner=20=E2=9C=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/stylesheets/components/banner.scss | 21 +++++++++++++++++++ app/assets/stylesheets/main.scss | 1 + app/main/views/jobs.py | 3 ++- app/templates/components/banner.html | 3 +++ app/templates/views/job.html | 4 ++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 app/assets/stylesheets/components/banner.scss create mode 100644 app/templates/components/banner.html diff --git a/app/assets/stylesheets/components/banner.scss b/app/assets/stylesheets/components/banner.scss new file mode 100644 index 000000000..a801b2ec7 --- /dev/null +++ b/app/assets/stylesheets/components/banner.scss @@ -0,0 +1,21 @@ +.banner { + + @include core-19; + background: $turquoise; + color: $white; + display: block; + padding: $gutter-half $gutter; + margin: 0 0 $gutter 0; + text-align: center; + position: relative; + + &:before { + @include core-24; + content: '✔'; + position: absolute; + top: $gutter-half; + left: $gutter-half; + margin-top: -2px; + } + +} diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index 3c7ed051b..13ac54a99 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -37,6 +37,7 @@ @import 'components/table'; @import 'components/navigation'; @import 'components/big-number'; +@import 'components/banner'; @import 'views/job'; diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index e57846a08..9e31dfa1e 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -56,7 +56,8 @@ def showjob(): }, cost='£0.00', uploaded_file_name='contact-demo.csv', - template_used='Reminder template' + template_used='Reminder template', + flash_message='We’ve started sending your notifications' ) diff --git a/app/templates/components/banner.html b/app/templates/components/banner.html new file mode 100644 index 000000000..2dab12c5d --- /dev/null +++ b/app/templates/components/banner.html @@ -0,0 +1,3 @@ +{% macro banner(body) %} + +{% endmacro %} diff --git a/app/templates/views/job.html b/app/templates/views/job.html index bdae79d11..c45772d16 100644 --- a/app/templates/views/job.html +++ b/app/templates/views/job.html @@ -1,5 +1,7 @@ {% extends "withnav_template.html" %} {% from "components/table.html" import table, field, right_aligned_field_heading %} +{% from "components/big-number.html" import big_number %} +{% from "components/banner.html" import banner %} {% block page_title %} GOV.UK Notify | Notifications activity @@ -11,6 +13,8 @@ GOV.UK Notify | Notifications activity {{ uploaded_file_name }} sent with {{ template_used }} + {{ banner(flash_message) }} +
  • {{ big_number( From d4a03a40c8923b6211f63d91e16c587c3af61729 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 17 Dec 2015 14:58:37 +0000 Subject: [PATCH 4/9] Add message history --- .../stylesheets/components/sms-message.scss | 32 +++++++++++++++++++ app/main/views/jobs.py | 16 +++++++--- app/templates/components/sms-message.html | 10 ++++++ app/templates/views/job.html | 2 +- app/templates/views/notification.html | 13 ++++++-- 5 files changed, 64 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/components/sms-message.scss b/app/assets/stylesheets/components/sms-message.scss index bf59c33b5..22d83cf6e 100644 --- a/app/assets/stylesheets/components/sms-message.scss +++ b/app/assets/stylesheets/components/sms-message.scss @@ -45,4 +45,36 @@ margin: 0; } + &-history { + + background: $turquoise; + color: $white; + padding: $gutter-half; + @include core-16; + margin-bottom: $gutter; + @extend %contain-floats; + + &-heading { + @include bold-16; + margin-bottom: 10px; + } + + &-status { + float: left; + margin: 0 0 10px 0; + padding: 0; + width: 66%; + } + + &-time { + float: left; + clear: left; + padding: 0; + width: 33%; + min-width: 3.2em; + max-width: 4.8em; + } + + } + } diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 9e31dfa1e..0d7e5b528 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -6,28 +6,28 @@ from app.main import main messages = [ { 'phone': '+44 7700 900 579', - 'message': 'Vehicle tax: Your vehicle tax for LV75 TDG expires…', + 'message': 'Vehicle tax: Your vehicle tax for LV75 TDG expires on 18 January 2016. Renew at www.gov.uk/vehicletax', # noqa 'status': 'Delivered', 'time': '13:42', 'id': '0' }, { 'phone': '+44 7700 900 306', - 'message': 'Vehicle tax: Your vehicle tax for PL53 GBD expires…', + 'message': 'Vehicle tax: Your vehicle tax for PL53 GBD expires on 18 January 2016. Renew at www.gov.uk/vehicletax', # noqa 'status': 'Delivered', 'time': '13:42', 'id': '1' }, { 'phone': '+44 7700 900 454', - 'message': 'Vehicle tax: Your vehicle tax for LV75 TDG expires…', + 'message': 'Vehicle tax: Your vehicle tax for LV75 TDG expires on 18 January 2016. Renew at www.gov.uk/vehicletax', # noqa 'status': 'Delivered', 'time': '13:42', 'id': '2' }, { 'phone': '+44 7700 900 522', - 'message': 'Vehicle tax: Your vehicle tax for RE67 PLM expires…', + 'message': 'Vehicle tax: Your vehicle tax for RE67 PLM expires on 18 January 2016. Renew at www.gov.uk/vehicletax', # noqa 'status': 'Failed', 'time': '13:42', 'id': '3' @@ -67,5 +67,11 @@ def shownotification(notification_id): 'views/notification.html', message=[ message for message in messages if message['id'] == notification_id - ][0] + ][0], + history=[ + {'time': '13:42', 'status': 'Delivered'}, + {'time': '13:42', 'status': 'Received by handset'}, + {'time': '13:42', 'status': 'Accepted by network'}, + {'time': '13:41', 'status': 'Sent'}, + ] ) diff --git a/app/templates/components/sms-message.html b/app/templates/components/sms-message.html index 5d5f11d12..d5f63909d 100644 --- a/app/templates/components/sms-message.html +++ b/app/templates/components/sms-message.html @@ -10,3 +10,13 @@ {% endmacro %} + +{% macro message_history(title, log, heading_level=2) %} +
    + {{ title }} + {% for update in log %} +
    {{ update.time }}
    +
    {{ update.status }}
    + {% endfor %} +
    +{% endmacro %} diff --git a/app/templates/views/job.html b/app/templates/views/job.html index c45772d16..534ac0d23 100644 --- a/app/templates/views/job.html +++ b/app/templates/views/job.html @@ -53,7 +53,7 @@ GOV.UK Notify | Notifications activity {{item.phone}} {% endcall %} {% call field() %} - {{item.message}} + {{item.message[:50]}}… {% endcall %} {% call field( align='right', diff --git a/app/templates/views/notification.html b/app/templates/views/notification.html index cb17512a8..c22cae954 100644 --- a/app/templates/views/notification.html +++ b/app/templates/views/notification.html @@ -1,5 +1,5 @@ {% extends "withnav_template.html" %} -{% from "components/sms-message.html" import sms_message %} +{% from "components/sms-message.html" import sms_message, message_history %} {% block page_title %} GOV.UK Notify | Notifications activity @@ -9,10 +9,17 @@ GOV.UK Notify | Notifications activity

    - Text message to {{ message.phone }} + Text message

    - {{ sms_message(message.message) }} +
    +
    + {{ sms_message(message.message, message.phone) }} +
    +
    + {{ message_history("Message history", history) }} +
    +

    View other notifications in this job From 0e6dab3f5c3566242b9e8e746d382067da315658 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 17 Dec 2015 16:21:34 +0000 Subject: [PATCH 5/9] Add unit tests for activity (and SMS) flows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are basic tests to make sure that the pages stay stitched together. Added for both the jobs and send SMS flows (because the send SMS flow didn’t have any before) --- app/main/views/jobs.py | 2 +- tests/app/main/views/test_jobs.py | 20 ++++++++++++++++++++ tests/app/main/views/test_sms.py | 27 +++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 tests/app/main/views/test_jobs.py create mode 100644 tests/app/main/views/test_sms.py diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 0d7e5b528..deeb92ed0 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -40,7 +40,7 @@ def showjobs(): return render_template('views/jobs.html') -@main.route("/jobs/job/") +@main.route("/jobs/job") def showjob(): return render_template( 'views/job.html', diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py new file mode 100644 index 000000000..68cd7820b --- /dev/null +++ b/tests/app/main/views/test_jobs.py @@ -0,0 +1,20 @@ +def test_should_return_list_of_all_jobs(notifications_admin): + response = notifications_admin.test_client().get('/jobs') + + assert response.status_code == 200 + assert 'This page will be where we show the list of jobs that this service has processed' in response.get_data(as_text=True) # noqa + + +def test_should_show_page_for_one_job(notifications_admin): + response = notifications_admin.test_client().get('/jobs/job') + + assert response.status_code == 200 + assert 'contact-demo.csv sent with Reminder template' in response.get_data(as_text=True) + + +def test_should_show_page_for_one_notification(notifications_admin): + response = notifications_admin.test_client().get('/jobs/job/notification/3') + + assert response.status_code == 200 + assert 'Text message' in response.get_data(as_text=True) + assert '+44 7700 900 522' in response.get_data(as_text=True) diff --git a/tests/app/main/views/test_sms.py b/tests/app/main/views/test_sms.py new file mode 100644 index 000000000..092d1c03d --- /dev/null +++ b/tests/app/main/views/test_sms.py @@ -0,0 +1,27 @@ +def test_should_return_sms_template_picker(notifications_admin): + response = notifications_admin.test_client().get('/sms/send') + + assert response.status_code == 200 + assert 'Choose text message template' in response.get_data(as_text=True) + + +def test_should_redirect_to_sms_check_page(notifications_admin): + response = notifications_admin.test_client().post('/sms/send') + + assert response.status_code == 302 + assert response.location == 'http://localhost/sms/check' + + +def test_should_return_check_sms_page(notifications_admin): + response = notifications_admin.test_client().get('/sms/check') + + assert response.status_code == 200 + assert 'Check and confirm' in response.get_data(as_text=True) + assert 'Send 10 text messages' in response.get_data(as_text=True) + + +def test_should_redirect_to_job(notifications_admin): + response = notifications_admin.test_client().post('/sms/check') + + assert response.status_code == 302 + assert response.location == 'http://localhost/jobs/job' From 31e6e53d4693f411d9edb186287165c3341bcf84 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 18 Dec 2015 10:26:56 +0000 Subject: [PATCH 6/9] Make data consistent from dashboard -> job MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - adds a table of recent activity to the job page, which is shared by the dashboard page - uses the same filename and message template as the first job shown on the dashboard - sets the time of file uploads/message delivery/message sending to always match ‘just now’ --- app/main/__init__.py | 4 +- app/main/views/_jobs.py | 62 +++++++++++++++++++++++ app/main/views/dashboard.py | 12 +++++ app/main/views/index.py | 16 ------ app/main/views/jobs.py | 31 +++++++----- app/templates/views/dashboard.html | 68 +++++++++----------------- app/templates/views/job.html | 4 +- app/templates/views/jobs.html | 25 ++++++++-- tests/app/main/views/test_dashboard.py | 6 +++ tests/app/main/views/test_jobs.py | 6 ++- 10 files changed, 152 insertions(+), 82 deletions(-) create mode 100644 app/main/views/_jobs.py create mode 100644 app/main/views/dashboard.py create mode 100644 tests/app/main/views/test_dashboard.py diff --git a/app/main/__init__.py b/app/main/__init__.py index 9347c19b2..a7134aef1 100644 --- a/app/main/__init__.py +++ b/app/main/__init__.py @@ -3,4 +3,6 @@ from flask import Blueprint main = Blueprint('main', __name__) -from app.main.views import index, sign_in, register, two_factor, verify, sms, add_service, code_not_received, jobs +from app.main.views import ( + index, sign_in, register, two_factor, verify, sms, add_service, code_not_received, jobs, dashboard +) diff --git a/app/main/views/_jobs.py b/app/main/views/_jobs.py new file mode 100644 index 000000000..52337d2ff --- /dev/null +++ b/app/main/views/_jobs.py @@ -0,0 +1,62 @@ +jobs = [ + { + 'job': 'Test message 1', + 'file': 'dispatch_20151114.csv', + 'time': 'Just now', + 'status': 'Queued' + }, + { + 'job': 'Mickey Mouse', + 'file': 'dispatch_20151117.csv', + 'time': '5 minutes ago', + 'status': 'Delivered' + }, + { + 'job': 'Asdfgg', + 'file': 'remdinder_monday.csv', + 'time': '30 minutes ago', + 'status': 'Failed' + }, + { + 'job': 'Test message 2', + 'file': 'appointments_wed.csv', + 'time': '2 hours ago', + 'status': 'Delivered' + }, + { + 'job': 'Reminder file', + 'file': 'appointments_mon.csv', + 'time': '11:44 Yesterday', + 'status': 'Delivered' + }, + { + 'job': 'Test message 1', + 'file': 'dispatch_20151114.csv', + 'time': '20 Jun 2015', + 'status': 'Queued' + }, + { + 'job': 'Mickey Mouse', + 'file': 'dispatch_20151117.csv', + 'time': '18 Jun 2015', + 'status': 'Delivered' + }, + { + 'job': 'Asdfgg', + 'file': 'remdinder_monday.csv', + 'time': '11 Jun 2015', + 'status': 'Failed' + }, + { + 'job': 'Test message 2', + 'file': 'appointments_wed.csv', + 'time': '11 Jun 2015', + 'status': 'Delivered' + }, + { + 'job': 'Final reminder', + 'file': 'appointments_mon.csv', + 'time': '11 Jun 2015', + 'status': 'Delivered' + } +] diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py new file mode 100644 index 000000000..1ddacc7d2 --- /dev/null +++ b/app/main/views/dashboard.py @@ -0,0 +1,12 @@ +from flask import render_template + +from app.main import main + +from ._jobs import jobs + + +@main.route("/dashboard") +def dashboard(): + return render_template( + 'views/dashboard.html', jobs=jobs + ) diff --git a/app/main/views/index.py b/app/main/views/index.py index 918ae5521..d3f2f7c16 100644 --- a/app/main/views/index.py +++ b/app/main/views/index.py @@ -24,17 +24,6 @@ def verifymobile(): return render_template('views/verify-mobile.html') -@main.route("/text-not-received-2") -def textnotreceived2(): - return render_template('views/text-not-received-2.html') - - -@main.route("/dashboard") -@login_required -def dashboard(): - return render_template('views/dashboard.html') - - @main.route("/send-email") def sendemail(): return render_template('views/send-email.html') @@ -75,11 +64,6 @@ def apikeys(): return render_template('views/api-keys.html') -@main.route("/verification-not-received") -def verificationnotreceived(): - return render_template('views/verification-not-received.html') - - @main.route("/manage-templates") def managetemplates(): return render_template('views/manage-templates.html') diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index deeb92ed0..3c5b81ccb 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -1,35 +1,38 @@ +import time from flask import render_template - from app.main import main +from ._jobs import jobs + +now = time.strftime('%H:%M') messages = [ { 'phone': '+44 7700 900 579', 'message': 'Vehicle tax: Your vehicle tax for LV75 TDG expires on 18 January 2016. Renew at www.gov.uk/vehicletax', # noqa 'status': 'Delivered', - 'time': '13:42', + 'time': now, 'id': '0' }, { 'phone': '+44 7700 900 306', 'message': 'Vehicle tax: Your vehicle tax for PL53 GBD expires on 18 January 2016. Renew at www.gov.uk/vehicletax', # noqa 'status': 'Delivered', - 'time': '13:42', + 'time': now, 'id': '1' }, { 'phone': '+44 7700 900 454', 'message': 'Vehicle tax: Your vehicle tax for LV75 TDG expires on 18 January 2016. Renew at www.gov.uk/vehicletax', # noqa 'status': 'Delivered', - 'time': '13:42', + 'time': now, 'id': '2' }, { 'phone': '+44 7700 900 522', 'message': 'Vehicle tax: Your vehicle tax for RE67 PLM expires on 18 January 2016. Renew at www.gov.uk/vehicletax', # noqa 'status': 'Failed', - 'time': '13:42', + 'time': now, 'id': '3' } ] @@ -37,7 +40,10 @@ messages = [ @main.route("/jobs") def showjobs(): - return render_template('views/jobs.html') + return render_template( + 'views/jobs.html', + jobs=jobs + ) @main.route("/jobs/job") @@ -55,8 +61,9 @@ def showjob(): ]) }, cost='£0.00', - uploaded_file_name='contact-demo.csv', - template_used='Reminder template', + uploaded_file_name='dispatch_20151114.csv', + uploaded_file_time=now, + template_used='Test message 1', flash_message='We’ve started sending your notifications' ) @@ -69,9 +76,9 @@ def shownotification(notification_id): message for message in messages if message['id'] == notification_id ][0], history=[ - {'time': '13:42', 'status': 'Delivered'}, - {'time': '13:42', 'status': 'Received by handset'}, - {'time': '13:42', 'status': 'Accepted by network'}, - {'time': '13:41', 'status': 'Sent'}, + {'time': now, 'status': 'Delivered'}, + {'time': now, 'status': 'Received by handset'}, + {'time': now, 'status': 'Accepted by network'}, + {'time': now, 'status': 'Sent'}, ] ) diff --git a/app/templates/views/dashboard.html b/app/templates/views/dashboard.html index d504eb152..ce672ad5f 100644 --- a/app/templates/views/dashboard.html +++ b/app/templates/views/dashboard.html @@ -1,55 +1,35 @@ {% extends "withnav_template.html" %} - +{% from "components/table.html" import table, field %} {% block page_title %} -GOV.UK Notify | Dashboard + GOV.UK Notify | Dashboard {% endblock %} {% block maincolumn_content %} -

    Dashboard

    +

    Dashboard

    -
+ {{ caption }}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Recent activity
Test message 1dispatch_20151114.csvJust nowQueued
Mickey Mousedispatch_20151117.csv5 minutes agoDelivered
Asdfggremdinder_monday.csv30 minutes agoFailed
Test message 2appointments_wed.csv2 hours agoDelivered
Reminder file+44788988763411:44 - 21 Nov 2015Delivered
-
-

See all notifications activity

+ {% call(item) table( + jobs[:3], + caption="Recent activity", + field_headings=['Job', 'File', 'Time', 'Status'] + ) %} + {% call field() %} + {{ item.file }} + {% endcall %} + {% call field() %} + {{ item.job }} + {% endcall %} + {% call field() %} + {{ item.time }} + {% endcall %} + {% call field() %} + {{ item.status }} + {% endcall %} + {% endcall %} +

+ See all notifications activity +

{% endblock %} diff --git a/app/templates/views/job.html b/app/templates/views/job.html index 534ac0d23..2cfd7a74e 100644 --- a/app/templates/views/job.html +++ b/app/templates/views/job.html @@ -10,7 +10,7 @@ GOV.UK Notify | Notifications activity {% block maincolumn_content %}

- {{ uploaded_file_name }} sent with {{ template_used }} + {{ uploaded_file_name }}

{{ banner(flash_message) }} @@ -36,7 +36,7 @@ GOV.UK Notify | Notifications activity

- You uploaded contact-demo.csv today at 13:42 + Sent with template {{ template_used }} at {{ uploaded_file_time }}

{% call(item) table( diff --git a/app/templates/views/jobs.html b/app/templates/views/jobs.html index 79a9604d8..b9bda799d 100644 --- a/app/templates/views/jobs.html +++ b/app/templates/views/jobs.html @@ -1,4 +1,5 @@ {% extends "withnav_template.html" %} +{% from "components/table.html" import table, field %} {% block page_title %} GOV.UK Notify | Notifications activity @@ -8,11 +9,25 @@ GOV.UK Notify | Notifications activity

Notifications activity

-

This page will be where we show the list of jobs that this service has processed

- -

- view a particular notification job -

+ {% call(item) table( + jobs, + caption="Recent activity", + caption_visible=False, + field_headings=['Job', 'File', 'Time', 'Status'] + ) %} + {% call field() %} + {{ item.file }} + {% endcall %} + {% call field() %} + {{ item.job }} + {% endcall %} + {% call field() %} + {{ item.time }} + {% endcall %} + {% call field() %} + {{ item.status }} + {% endcall %} + {% endcall %} {% endblock %} diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py new file mode 100644 index 000000000..2b134b39d --- /dev/null +++ b/tests/app/main/views/test_dashboard.py @@ -0,0 +1,6 @@ +def test_should_show_recent_jobs_on_dashboard(notifications_admin): + response = notifications_admin.test_client().get('/dashboard') + + assert response.status_code == 200 + assert 'Test message 1' in response.get_data(as_text=True) + assert 'Asdfgg' in response.get_data(as_text=True) diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 68cd7820b..be7354873 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -2,14 +2,16 @@ def test_should_return_list_of_all_jobs(notifications_admin): response = notifications_admin.test_client().get('/jobs') assert response.status_code == 200 - assert 'This page will be where we show the list of jobs that this service has processed' in response.get_data(as_text=True) # noqa + assert 'Test message 1' in response.get_data(as_text=True) + assert 'Final reminder' in response.get_data(as_text=True) def test_should_show_page_for_one_job(notifications_admin): response = notifications_admin.test_client().get('/jobs/job') assert response.status_code == 200 - assert 'contact-demo.csv sent with Reminder template' in response.get_data(as_text=True) + assert 'dispatch_20151114.csv' in response.get_data(as_text=True) + assert 'Test message 1' in response.get_data(as_text=True) def test_should_show_page_for_one_notification(notifications_admin): From 96c3291600d2f5507fb96c5e36f6517a49ae78b5 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 18 Dec 2015 15:54:29 +0000 Subject: [PATCH 7/9] =?UTF-8?q?=E2=80=98Messages=E2=80=99=20is=20a=20more?= =?UTF-8?q?=20human=20word=20than=20=E2=80=98notifications=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main/views/jobs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 3c5b81ccb..0800c751d 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -64,7 +64,7 @@ def showjob(): uploaded_file_name='dispatch_20151114.csv', uploaded_file_time=now, template_used='Test message 1', - flash_message='We’ve started sending your notifications' + flash_message='We’ve started sending your messages' ) From cad56987543c17999a9209d2acc69b0d2aa49af2 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 18 Dec 2015 16:36:24 +0000 Subject: [PATCH 8/9] Add big numbers to dashboard A suggestion of what high-level information users might need on the dashboard page. --- app/main/views/dashboard.py | 5 ++++- app/templates/views/dashboard.html | 20 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 1ddacc7d2..0e0275f45 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -8,5 +8,8 @@ from ._jobs import jobs @main.route("/dashboard") def dashboard(): return render_template( - 'views/dashboard.html', jobs=jobs + 'views/dashboard.html', + jobs=jobs, + free_text_messages_remaining=560, + spent_this_month='0.00' ) diff --git a/app/templates/views/dashboard.html b/app/templates/views/dashboard.html index ce672ad5f..3e6339605 100644 --- a/app/templates/views/dashboard.html +++ b/app/templates/views/dashboard.html @@ -1,5 +1,6 @@ {% extends "withnav_template.html" %} {% from "components/table.html" import table, field %} +{% from "components/big-number.html" import big_number %} {% block page_title %} GOV.UK Notify | Dashboard @@ -7,11 +8,26 @@ {% block maincolumn_content %} -

Dashboard

+

Service name

+ +
    +
  • + {{ big_number( + free_text_messages_remaining, + 'free text messages remaining' + )}} +
  • +
  • + {{ big_number( + '£' + spent_this_month, + 'spent this month' + )}} +
  • +
{% call(item) table( jobs[:3], - caption="Recent activity", + caption="Recent text messages", field_headings=['Job', 'File', 'Time', 'Status'] ) %} {% call field() %} From 450c7aaeaa13b31a16585b9f765494394bd05344 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 18 Dec 2015 17:03:49 +0000 Subject: [PATCH 9/9] Remove log of activity from single notification Having the full history of the message is more information than is necessary. We should only show what stage the message is at, and the time that it reached that stage. We can do research later on to find out if users understand or care about the different stages. --- .../stylesheets/components/sms-message.scss | 31 +++++++------------ app/main/views/jobs.py | 8 ++--- app/templates/components/sms-message.html | 24 +++++++------- app/templates/views/notification.html | 4 +-- 4 files changed, 26 insertions(+), 41 deletions(-) diff --git a/app/assets/stylesheets/components/sms-message.scss b/app/assets/stylesheets/components/sms-message.scss index 22d83cf6e..4fa727388 100644 --- a/app/assets/stylesheets/components/sms-message.scss +++ b/app/assets/stylesheets/components/sms-message.scss @@ -42,7 +42,7 @@ &-recipient { @include copy-19; color: $secondary-text-colour; - margin: 0; + margin: -$gutter-half 0 $gutter 0; } &-history { @@ -50,29 +50,20 @@ background: $turquoise; color: $white; padding: $gutter-half; - @include core-16; - margin-bottom: $gutter; - @extend %contain-floats; + @include bold-19; + margin: 0 0 $gutter 0; &-heading { - @include bold-16; - margin-bottom: 10px; - } - &-status { - float: left; - margin: 0 0 10px 0; - padding: 0; - width: 66%; - } + @include bold-19; + margin: 0; + + &-time { + @include inline-block; + margin-left: 10px; + font-weight: normal; + } - &-time { - float: left; - clear: left; - padding: 0; - width: 33%; - min-width: 3.2em; - max-width: 4.8em; } } diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 0800c751d..867bb0269 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -75,10 +75,6 @@ def shownotification(notification_id): message=[ message for message in messages if message['id'] == notification_id ][0], - history=[ - {'time': now, 'status': 'Delivered'}, - {'time': now, 'status': 'Received by handset'}, - {'time': now, 'status': 'Accepted by network'}, - {'time': now, 'status': 'Sent'}, - ] + delivered_at=now, + uploaded_at=now ) diff --git a/app/templates/components/sms-message.html b/app/templates/components/sms-message.html index d5f63909d..38d30b877 100644 --- a/app/templates/components/sms-message.html +++ b/app/templates/components/sms-message.html @@ -1,22 +1,20 @@ {% macro sms_message(body, recipient) %} - {% if recipient %} -

- {{ recipient }} -

- {% endif %}
{{ body|placeholders }}
+ {% if recipient %} +

+ {{ recipient }} +

+ {% endif %} {% endmacro %} -{% macro message_history(title, log, heading_level=2) %} -
- {{ title }} - {% for update in log %} -
{{ update.time }}
-
{{ update.status }}
- {% endfor %} -
+{% macro message_status(status, time) %} +
+

+ {{ status }} {{ time }} +

+
{% endmacro %} diff --git a/app/templates/views/notification.html b/app/templates/views/notification.html index c22cae954..1dcb034a2 100644 --- a/app/templates/views/notification.html +++ b/app/templates/views/notification.html @@ -1,5 +1,5 @@ {% extends "withnav_template.html" %} -{% from "components/sms-message.html" import sms_message, message_history %} +{% from "components/sms-message.html" import sms_message, message_status %} {% block page_title %} GOV.UK Notify | Notifications activity @@ -17,7 +17,7 @@ GOV.UK Notify | Notifications activity {{ sms_message(message.message, message.phone) }}
- {{ message_history("Message history", history) }} + {{ message_status(message.status, delivered_at) }}