mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
Put uploaded files on the dashboard
This commit depends on and uses the data returned by: - [x] https://github.com/alphagov/notifications-api/pull/345 - [x] https://github.com/alphagov/notifications-api/pull/347 - [x] https://github.com/alphagov/notifications-admin/pull/612 It puts the last 5 jobs on the dashboard. This should be changed to all the jobs from the last 7 days when that parameter is available. It also: - links to the jobs page - makes the numbers on the jobs page consistent with the dashboard - makes the numbers on an individual job consistent with the appearance of the dashboard
This commit is contained in:
@@ -16,6 +16,7 @@ from flask_login import login_required
|
||||
|
||||
from app.main import main
|
||||
from app import (
|
||||
job_api_client,
|
||||
statistics_api_client,
|
||||
service_api_client,
|
||||
template_statistics_client
|
||||
@@ -217,4 +218,5 @@ def get_dashboard_statistics_for_service(service_id):
|
||||
'sms_allowance_remaining': max(0, (sms_free_allowance - sms_sent)),
|
||||
'sms_chargeable': max(0, sms_sent - sms_free_allowance),
|
||||
'sms_rate': sms_rate,
|
||||
'jobs': job_api_client.get_job(service_id, limit_days=7)['data']
|
||||
}
|
||||
|
||||
@@ -90,12 +90,13 @@ def view_job(service_id, job_id):
|
||||
return render_template(
|
||||
'views/jobs/job.html',
|
||||
notifications=notifications['notifications'],
|
||||
counts={
|
||||
'queued': 0 if finished else job['notification_count'],
|
||||
'sent': job['notification_count'] if finished else 0
|
||||
},
|
||||
job=job,
|
||||
uploaded_at=job['created_at'],
|
||||
finished_at=job['updated_at'] if finished else None,
|
||||
finished=job.get('notifications_sent', 0) and ((
|
||||
job.get('notifications_sent', 0) -
|
||||
job.get('notifications_delivered', 0) -
|
||||
job.get('notifications_failed', 0)
|
||||
) == 0),
|
||||
uploaded_file_name=job['original_file_name'],
|
||||
first_email_template=[
|
||||
template for template in service_api_client.get_service_templates(service_id)['data']
|
||||
@@ -104,9 +105,7 @@ def view_job(service_id, job_id):
|
||||
template=Template(
|
||||
template,
|
||||
prefix=current_service['name']
|
||||
),
|
||||
job_id=job_id,
|
||||
created_by=job['created_by']['name']
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -116,24 +115,27 @@ def view_job(service_id, job_id):
|
||||
def view_job_updates(service_id, job_id):
|
||||
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'
|
||||
finished = (
|
||||
job.get('notifications_sent', 0) -
|
||||
job.get('notifications_delivered', 0) -
|
||||
job.get('notifications_failed', 0)
|
||||
) == 0
|
||||
return jsonify(**{
|
||||
'counts': render_template(
|
||||
'partials/jobs/count.html',
|
||||
counts={
|
||||
'queued': 0 if finished else job['notification_count'],
|
||||
'sent': job['notification_count'] if finished else 0
|
||||
}
|
||||
job=job,
|
||||
finished=finished
|
||||
),
|
||||
'notifications': render_template(
|
||||
'partials/jobs/notifications.html',
|
||||
notifications=notifications['notifications']
|
||||
job=job,
|
||||
notifications=notifications['notifications'],
|
||||
finished=finished
|
||||
),
|
||||
'status': render_template(
|
||||
'partials/jobs/status.html',
|
||||
uploaded_at=job['created_at'],
|
||||
finished_at=job['updated_at'] if finished else None,
|
||||
created_by=job['created_by']['name']
|
||||
job=job,
|
||||
finished=finished
|
||||
),
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user