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