diff --git a/app/assets/stylesheets/components/banner.scss b/app/assets/stylesheets/components/banner.scss index ae237e56d..02c12dfc2 100644 --- a/app/assets/stylesheets/components/banner.scss +++ b/app/assets/stylesheets/components/banner.scss @@ -13,7 +13,8 @@ } -.banner-with-tick { +.banner-with-tick, +.banner-default-with-tick { @extend %banner; padding: $gutter-half ($gutter + $gutter-half); diff --git a/app/assets/stylesheets/components/table.scss b/app/assets/stylesheets/components/table.scss index a78886a13..97b14296c 100644 --- a/app/assets/stylesheets/components/table.scss +++ b/app/assets/stylesheets/components/table.scss @@ -57,7 +57,6 @@ .table-empty-message { @include core-16; color: $secondary-text-colour; - border-top: 1px solid $border-colour; border-bottom: 1px solid $border-colour; padding: 0.75em 0 0.5625em 0; } diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 9c25fb21f..2db8b620e 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -4,7 +4,7 @@ from app.main import main from app.main.dao.services_dao import get_service_by_id from app.main.dao import templates_dao from client.errors import HTTPError -from ._jobs import jobs +from app import job_api_client @main.route("/services//dashboard") @@ -12,6 +12,7 @@ from ._jobs import jobs def service_dashboard(service_id): try: templates = templates_dao.get_service_templates(service_id)['data'] + jobs = job_api_client.get_job(service_id)['data'] except HTTPError as e: if e.status_code == 404: abort(404) @@ -27,7 +28,7 @@ def service_dashboard(service_id): raise e return render_template( 'views/service_dashboard.html', - jobs=jobs, + jobs=reversed(jobs), free_text_messages_remaining='25,000', spent_this_month='0.00', template_count=len(templates), diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 413bd2491..f18fc4470 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -11,6 +11,7 @@ from client.errors import HTTPError from app import job_api_client from app.main import main +from app.main.dao import templates_dao now = time.strftime('%H:%M') @@ -37,6 +38,7 @@ def view_jobs(service_id): def view_job(service_id, job_id): try: job = job_api_client.get_job(service_id, job_id)['data'] + template = templates_dao.get_service_template(service_id, job['template'])['data'] messages = [] return render_template( 'views/job.html', @@ -53,8 +55,7 @@ def view_job(service_id, job_id): cost=u'£0.00', uploaded_file_name=job['original_file_name'], uploaded_file_time=job['created_at'], - template_used=job['template'], - flash_message="We’ve accepted {} for processing".format(job['original_file_name']), + template=template, service_id=service_id ) except HTTPError as e: diff --git a/app/templates/components/table.html b/app/templates/components/table.html index a37a5ef89..ed9b35902 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -25,19 +25,21 @@ {% macro list_table(items, caption='', empty_message='', field_headings=[], field_headings_visible=True, caption_visible=True) -%} {% set parent_caller = caller %} - {% if items %} - {% call mapping_table(caption, field_headings, field_headings_visible, caption_visible) %} - {% for item in items %} - {% call row() %} - {{ parent_caller(item) }} - {% endcall %} - {% endfor %} - {%- endcall %} - {% else %} -

- {{ empty_message }} -

- {% endif %} + + {% call mapping_table(caption, field_headings, field_headings_visible, caption_visible) %} + {% for item in items %} + {% call row() %} + {{ parent_caller(item) }} + {% endcall %} + {% endfor %} + {% if not items %} + {% call row() %} + + {{ empty_message }} + + {% endcall %} + {% endif %} + {%- endcall %} {%- endmacro %} diff --git a/app/templates/flash_messages.html b/app/templates/flash_messages.html index aa775c788..85be2d13d 100644 --- a/app/templates/flash_messages.html +++ b/app/templates/flash_messages.html @@ -4,8 +4,9 @@ {% for category, message in messages %} {{ banner( message, - 'default' if category == 'default' else 'dangerous', - delete_button="Yes, delete this template" if 'delete' == category else None + 'default' if category == 'default' or 'default_with_tick' else 'dangerous', + delete_button="Yes, delete this template" if 'delete' == category else None, + with_tick=True if category == 'default_with_tick' else False )}} {% endfor %} {% endif %} diff --git a/app/templates/views/check-sms.html b/app/templates/views/check-sms.html index 2d3f02093..556384867 100644 --- a/app/templates/views/check-sms.html +++ b/app/templates/views/check-sms.html @@ -10,7 +10,7 @@ {% block maincolumn_content %} -

Send text messages

+

Check and confirm

{% if upload_result.rejects %}

The following numbers are invalid

@@ -22,8 +22,7 @@ {% else %} {{ sms_message( - message_template|replace_placeholders(upload_result.valid[0]), - name='Preview' + message_template|replace_placeholders(upload_result.valid[0]) )}}
diff --git a/app/templates/views/job.html b/app/templates/views/job.html index 15435f040..e0dfd9473 100644 --- a/app/templates/views/job.html +++ b/app/templates/views/job.html @@ -2,23 +2,33 @@ {% from "components/table.html" import list_table, field, right_aligned_field_heading %} {% from "components/big-number.html" import big_number %} {% from "components/banner.html" import banner %} +{% from "components/sms-message.html" import sms_message %} {% block page_title %} -GOV.UK Notify | Notifications activity + GOV.UK Notify | Notifications activity {% endblock %} {% block maincolumn_content %}

- {{ uploaded_file_name }} + Sent text messages

-

- {{ banner(flash_message, with_tick=True) }} + {{ sms_message( + template['content'], + )}} + +

+ Started {{ uploaded_file_time|format_datetime }}

-

- Sent with template {{ template_used }} on {{ uploaded_file_time | format_datetime}} -

- {% call(item) list_table( messages, - caption='Messages', - caption_visible=False, + caption=uploaded_file_name, + empty_message="Messages go here", field_headings=[ 'To', 'Message', diff --git a/app/templates/views/send-sms.html b/app/templates/views/send-sms.html index 5ccbec5c1..e33d8fdc2 100644 --- a/app/templates/views/send-sms.html +++ b/app/templates/views/send-sms.html @@ -8,9 +8,12 @@ {% endblock %} {% block maincolumn_content %} + +

Send text messages

+ -

Send text messages

+ {{ sms_message(template.content) }} {{ banner( 'You can only send notifications to yourself', diff --git a/app/templates/views/service_dashboard.html b/app/templates/views/service_dashboard.html index 7caa0cb66..14bab0275 100644 --- a/app/templates/views/service_dashboard.html +++ b/app/templates/views/service_dashboard.html @@ -1,5 +1,5 @@ {% extends "withnav_template.html" %} -{% from "components/table.html" import list_table, field %} +{% from "components/table.html" import list_table, field, right_aligned_field_heading %} {% from "components/big-number.html" import big_number %} {% block page_title %} @@ -31,7 +31,7 @@ subhead='Get started', type="tip" )}} - {% else %} + {% elif not jobs %} {{ banner( 'Try sending a text message'.format( url_for(".choose_sms_template", service_id=service_id) @@ -41,23 +41,20 @@ )}} {% endif %} - {% if [] %} + {% if jobs %} {% call(item) list_table( - [], + jobs, caption="Recent text messages", empty_message='You haven’t sent any text messages yet', - field_headings=['Job', 'File', 'Time', 'Status'] + field_headings=['Job', 'Created', right_aligned_field_heading('Status')] ) %} {% call field() %} - {{ item.file }} + {{ item.original_file_name }} {% endcall %} {% call field() %} - {{ item.job }} + {{ item.created_at|format_datetime }} {% endcall %} - {% call field() %} - {{ item.time }} - {% endcall %} - {% call field() %} + {% call field(align='right') %} {{ item.status }} {% endcall %} {% endcall %} diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index 7a2a3ad67..d5b3386ea 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -7,7 +7,8 @@ def test_should_show_recent_jobs_on_dashboard(app_, mock_get_service_templates, mock_get_user, mock_get_user_by_email, - mock_login): + mock_login, + mock_get_jobs): with app_.test_request_context(): with app_.test_client() as client: diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 6b32dd549..98f99e514 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -27,6 +27,7 @@ def test_should_show_page_for_one_job(app_, mock_login, mock_get_user, mock_get_user_by_email, + mock_get_service_template, job_data, mock_get_job): service_id = job_data['service'] diff --git a/tests/app/main/views/test_sign_out.py b/tests/app/main/views/test_sign_out.py index 03f7edfb1..cf7b5a665 100644 --- a/tests/app/main/views/test_sign_out.py +++ b/tests/app/main/views/test_sign_out.py @@ -18,7 +18,8 @@ def test_sign_out_user(app_, mock_get_user, mock_get_user_by_email, mock_get_service_templates, - mock_login): + mock_login, + mock_get_jobs): with app_.test_request_context(): email = 'valid@example.gov.uk' password = 'val1dPassw0rd!'