Updates to display of jobs

This commit:
- adds the template to the jobs page (and puts it at the top of the send SMS
  page) so that it consistently appears in the same place throughout the
  journey
- put the real data about a job on the jobs page and on the dashboard
This commit is contained in:
Chris Hill-Scott
2016-02-03 14:43:16 +00:00
parent 3e7bb42323
commit 856296df5d
13 changed files with 63 additions and 50 deletions

View File

@@ -13,7 +13,8 @@
}
.banner-with-tick {
.banner-with-tick,
.banner-default-with-tick {
@extend %banner;
padding: $gutter-half ($gutter + $gutter-half);

View File

@@ -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;
}

View File

@@ -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/<service_id>/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),

View File

@@ -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="Weve accepted {} for processing".format(job['original_file_name']),
template=template,
service_id=service_id
)
except HTTPError as e:

View File

@@ -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 %}
<p class="table-empty-message">
{{ empty_message }}
</p>
{% 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() %}
<td class="table-empty-message" colspan="10">
{{ empty_message }}
</td>
{% endcall %}
{% endif %}
{%- endcall %}
{%- endmacro %}

View File

@@ -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 %}

View File

@@ -10,7 +10,7 @@
{% block maincolumn_content %}
<h1 class="heading-large">Send text messages</h1>
<h1 class="heading-large">Check and confirm</h1>
{% if upload_result.rejects %}
<h3 class="heading-small">The following numbers are invalid</h3>
@@ -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])
)}}
<form method="POST" enctype="multipart/form-data">

View File

@@ -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 %}
<h1 class="heading-large">
{{ uploaded_file_name }}
Sent text messages
</h1>
<p>
{{ banner(flash_message, with_tick=True) }}
{{ sms_message(
template['content'],
)}}
<p class='heading-small'>
Started {{ uploaded_file_time|format_datetime }}
</p>
<ul class="grid-row job-totals">
<li class="column-one-third">
<li class="column-one-quarter">
{{ big_number(
counts.total, 'queued'
)}}
</li>
<li class="column-one-quarter">
{{ big_number(
counts.total,
'text message' if 1 == counts.total else 'text messages'
@@ -27,7 +37,7 @@ GOV.UK Notify | Notifications activity
<li class="column-one-third">
{{ big_number(
counts.failed,
'failed delivery' if 1 == counts.failed else 'failed deliveries'
'failed'
)}}
</li>
<li class="column-one-third">
@@ -37,14 +47,10 @@ GOV.UK Notify | Notifications activity
</li>
</ul>
<p>
Sent with template <a href="{{ url_for('.edit_service_template', service_id=service_id, template_id=template_used) }}">{{ template_used }}</a> on {{ uploaded_file_time | format_datetime}}
</p>
{% call(item) list_table(
messages,
caption='Messages',
caption_visible=False,
caption=uploaded_file_name,
empty_message="Messages go here",
field_headings=[
'To',
'Message',

View File

@@ -8,9 +8,12 @@
{% endblock %}
{% block maincolumn_content %}
<h1 class="heading-large">Send text messages</h1>
<form method="POST" enctype="multipart/form-data">
<h1 class="heading-large">Send text messages</h1>
{{ sms_message(template.content) }}
{{ banner(
'You can only send notifications to yourself',

View File

@@ -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(
'<a href="{}">Try sending a text message</a>'.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 havent sent any text messages yet',
field_headings=['Job', 'File', 'Time', 'Status']
field_headings=['Job', 'Created', right_aligned_field_heading('Status')]
) %}
{% call field() %}
<a href="{{ url_for('.view_job', service_id=service_id, job_id=456) }}">{{ item.file }}</a>
<a href="{{ url_for('.view_job', service_id=service_id, job_id=item.id) }}">{{ item.original_file_name }}</a>
{% endcall %}
{% call field() %}
<a href="{{ url_for('.view_job', service_id=service_id, job_id=456) }}">{{ item.job }}</a>
{{ item.created_at|format_datetime }}
{% endcall %}
{% call field() %}
{{ item.time }}
{% endcall %}
{% call field() %}
{% call field(align='right') %}
{{ item.status }}
{% endcall %}
{% endcall %}

View File

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

View File

@@ -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']

View File

@@ -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!'