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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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):