2016-01-06 11:03:29 +00:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
2015-12-18 10:26:56 +00:00
|
|
|
|
import time
|
2015-12-17 11:14:19 +00:00
|
|
|
|
from flask import render_template
|
2016-01-11 16:03:41 +00:00
|
|
|
|
from flask_login import login_required
|
|
|
|
|
|
|
2015-12-17 11:14:19 +00:00
|
|
|
|
from app.main import main
|
|
|
|
|
|
|
2015-12-18 10:26:56 +00:00
|
|
|
|
from ._jobs import jobs
|
|
|
|
|
|
|
|
|
|
|
|
now = time.strftime('%H:%M')
|
2015-12-17 11:14:19 +00:00
|
|
|
|
|
|
|
|
|
|
messages = [
|
|
|
|
|
|
{
|
|
|
|
|
|
'phone': '+44 7700 900 579',
|
2015-12-17 14:58:37 +00:00
|
|
|
|
'message': 'Vehicle tax: Your vehicle tax for LV75 TDG expires on 18 January 2016. Renew at www.gov.uk/vehicletax', # noqa
|
2015-12-17 11:14:19 +00:00
|
|
|
|
'status': 'Delivered',
|
2015-12-18 10:26:56 +00:00
|
|
|
|
'time': now,
|
2015-12-17 11:14:19 +00:00
|
|
|
|
'id': '0'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
'phone': '+44 7700 900 306',
|
2015-12-17 14:58:37 +00:00
|
|
|
|
'message': 'Vehicle tax: Your vehicle tax for PL53 GBD expires on 18 January 2016. Renew at www.gov.uk/vehicletax', # noqa
|
2015-12-17 11:14:19 +00:00
|
|
|
|
'status': 'Delivered',
|
2015-12-18 10:26:56 +00:00
|
|
|
|
'time': now,
|
2015-12-17 11:14:19 +00:00
|
|
|
|
'id': '1'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
'phone': '+44 7700 900 454',
|
2015-12-17 14:58:37 +00:00
|
|
|
|
'message': 'Vehicle tax: Your vehicle tax for LV75 TDG expires on 18 January 2016. Renew at www.gov.uk/vehicletax', # noqa
|
2015-12-17 11:14:19 +00:00
|
|
|
|
'status': 'Delivered',
|
2015-12-18 10:26:56 +00:00
|
|
|
|
'time': now,
|
2015-12-17 11:14:19 +00:00
|
|
|
|
'id': '2'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
'phone': '+44 7700 900 522',
|
2015-12-17 14:58:37 +00:00
|
|
|
|
'message': 'Vehicle tax: Your vehicle tax for RE67 PLM expires on 18 January 2016. Renew at www.gov.uk/vehicletax', # noqa
|
2015-12-17 11:14:19 +00:00
|
|
|
|
'status': 'Failed',
|
2015-12-18 10:26:56 +00:00
|
|
|
|
'time': now,
|
2015-12-17 11:14:19 +00:00
|
|
|
|
'id': '3'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@main.route("/jobs")
|
2016-01-11 16:03:41 +00:00
|
|
|
|
@login_required
|
2015-12-17 11:14:19 +00:00
|
|
|
|
def showjobs():
|
2015-12-18 10:26:56 +00:00
|
|
|
|
return render_template(
|
|
|
|
|
|
'views/jobs.html',
|
|
|
|
|
|
jobs=jobs
|
|
|
|
|
|
)
|
2015-12-17 11:14:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
2015-12-17 16:21:34 +00:00
|
|
|
|
@main.route("/jobs/job")
|
2016-01-11 16:03:41 +00:00
|
|
|
|
@login_required
|
2015-12-17 11:14:19 +00:00
|
|
|
|
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'
|
|
|
|
|
|
])
|
|
|
|
|
|
},
|
2016-01-06 12:57:09 +00:00
|
|
|
|
cost=u'£0.00',
|
2015-12-18 10:26:56 +00:00
|
|
|
|
uploaded_file_name='dispatch_20151114.csv',
|
|
|
|
|
|
uploaded_file_time=now,
|
|
|
|
|
|
template_used='Test message 1',
|
2016-01-06 13:22:15 +00:00
|
|
|
|
flash_message=u'We’ve started sending your messages'
|
2015-12-17 11:14:19 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@main.route("/jobs/job/notification/<string:notification_id>")
|
2016-01-11 16:03:41 +00:00
|
|
|
|
@login_required
|
2015-12-17 11:14:19 +00:00
|
|
|
|
def shownotification(notification_id):
|
|
|
|
|
|
return render_template(
|
|
|
|
|
|
'views/notification.html',
|
|
|
|
|
|
message=[
|
|
|
|
|
|
message for message in messages if message['id'] == notification_id
|
2015-12-17 14:58:37 +00:00
|
|
|
|
][0],
|
2015-12-18 17:03:49 +00:00
|
|
|
|
delivered_at=now,
|
|
|
|
|
|
uploaded_at=now
|
2015-12-17 11:14:19 +00:00
|
|
|
|
)
|