mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
Put data from job on job page
The main change is showing the finished time if the job is finished, rather than the start time.
This commit is contained in:
@@ -73,6 +73,7 @@ def create_app(config_name, config_overrides=None):
|
||||
|
||||
application.add_template_filter(nl2br)
|
||||
application.add_template_filter(format_datetime)
|
||||
application.add_template_filter(format_time)
|
||||
application.add_template_filter(syntax_highlight_json)
|
||||
application.add_template_filter(valid_phone_number)
|
||||
|
||||
@@ -149,6 +150,12 @@ def format_datetime(date):
|
||||
return native.strftime('%A %d %B %Y at %H:%M')
|
||||
|
||||
|
||||
def format_time(date):
|
||||
date = dateutil.parser.parse(date)
|
||||
native = date.replace(tzinfo=None)
|
||||
return native.strftime('%H:%M')
|
||||
|
||||
|
||||
def valid_phone_number(phone_number):
|
||||
try:
|
||||
validate_phone_number(phone_number)
|
||||
|
||||
@@ -42,23 +42,26 @@ def view_job(service_id, job_id):
|
||||
try:
|
||||
job = job_api_client.get_job(service_id, job_id)['data']
|
||||
notifications = notification_api_client.get_notifications_for_service(service_id, job_id)
|
||||
finished = job['status'] == 'finished'
|
||||
return render_template(
|
||||
'views/job.html',
|
||||
notifications=notifications['notifications'],
|
||||
counts={
|
||||
'total': len(notifications),
|
||||
'delivered': len(notifications),
|
||||
'queued': 0 if finished else job['notification_count'],
|
||||
'sent': job['notification_count'] if finished else 0,
|
||||
'failed': 0
|
||||
},
|
||||
uploaded_at=job['created_at'],
|
||||
finished_at=job['updated_at'] if finished else None,
|
||||
cost=u'£0.00',
|
||||
uploaded_file_name=job['original_file_name'],
|
||||
uploaded_file_time=job['created_at'],
|
||||
template=Template(
|
||||
templates_dao.get_service_template_or_404(service_id, job['template'])['data'],
|
||||
prefix=service['name']
|
||||
),
|
||||
service_id=service_id,
|
||||
service=service
|
||||
from_name=service['name'],
|
||||
job_id=job_id
|
||||
)
|
||||
except HTTPError as e:
|
||||
if e.status_code == 404:
|
||||
|
||||
@@ -28,23 +28,29 @@
|
||||
template.subject,
|
||||
template,
|
||||
from_address='{}@notifications.service.gov.uk'.format(service.email_from),
|
||||
from_name=service.name
|
||||
from_name=from_name
|
||||
)}}
|
||||
{% endif %}
|
||||
|
||||
<p class='heading-small'>
|
||||
Started {{ uploaded_file_time|format_datetime }}
|
||||
</p>
|
||||
{% if finished_at %}
|
||||
<p class='heading-small'>
|
||||
Finished {{ finished_at|format_datetime }}
|
||||
</p>
|
||||
{% else %}
|
||||
<p class='heading-small'>
|
||||
Started {{ uploaded_at|format_datetime }}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<ul class="grid-row job-totals">
|
||||
<li class="column-one-quarter">
|
||||
{{ big_number(
|
||||
0, 'queued'
|
||||
counts.queued, 'queued'
|
||||
)}}
|
||||
</li>
|
||||
<li class="column-one-quarter">
|
||||
{{ big_number(
|
||||
1, 'sent'
|
||||
counts.sent, 'sent'
|
||||
)}}
|
||||
</li>
|
||||
<li class="column-one-quarter">
|
||||
@@ -60,26 +66,32 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{% call(item) list_table(
|
||||
notifications,
|
||||
caption=uploaded_file_name,
|
||||
caption_visible=False,
|
||||
empty_message="Messages go here",
|
||||
field_headings=[
|
||||
'Recipient',
|
||||
'Template',
|
||||
right_aligned_field_heading('Status')
|
||||
]
|
||||
) %}
|
||||
{% call field() %}
|
||||
{{ item.to }}
|
||||
{% endcall %}
|
||||
{% call field(
|
||||
align='right',
|
||||
status='error' if item.status == 'Failed' else 'default'
|
||||
|
||||
{% if notifications %}
|
||||
{% call(item) list_table(
|
||||
notifications,
|
||||
caption=uploaded_file_name,
|
||||
caption_visible=False,
|
||||
empty_message="Messages go here",
|
||||
field_headings=[
|
||||
'Recipient',
|
||||
right_aligned_field_heading('Status')
|
||||
]
|
||||
) %}
|
||||
{{ item.status }}
|
||||
{% call field() %}
|
||||
{{ item.to }}
|
||||
{% endcall %}
|
||||
{% call field(
|
||||
align='right',
|
||||
status='error' if item.status == 'Failed' else 'default'
|
||||
) %}
|
||||
{{ item.status|title }} at {{ item.sent_at|format_time }}
|
||||
{% endcall %}
|
||||
{% endcall %}
|
||||
{% endcall %}
|
||||
{% else %}
|
||||
<p>
|
||||
<a href="{{ url_for(".view_job", service_id=service_id, job_id=job_id) }}">Refresh</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user