Files
notifications-admin/app/main/views/jobs.py
T
Chris Hill-Scott 31e6e53d46 Make data consistent from dashboard -> job
- 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’
2016-01-05 13:31:54 +00:00

85 lines
2.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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': 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': 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': 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': now,
'id': '3'
}
]
@main.route("/jobs")
def showjobs():
return render_template(
'views/jobs.html',
jobs=jobs
)
@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='dispatch_20151114.csv',
uploaded_file_time=now,
template_used='Test message 1',
flash_message='Weve started sending your notifications'
)
@main.route("/jobs/job/notification/<string:notification_id>")
def shownotification(notification_id):
return render_template(
'views/notification.html',
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'},
]
)