mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-07 17:38:32 -04:00
Download csv for job added.
Removed check for notifications so download button is always there.
This commit is contained in:
@@ -76,6 +76,13 @@ def view_job(service_id, job_id):
|
||||
version=job['template_version'])['data']
|
||||
notifications = notification_api_client.get_notifications_for_service(service_id, job_id)
|
||||
finished = job['status'] == 'finished'
|
||||
if 'download' in request.args and request.args['download'] == 'csv':
|
||||
csv_content = generate_notifications_csv(
|
||||
notification_api_client.get_notifications_for_service(service_id, job_id)['notifications'])
|
||||
return csv_content, 200, {
|
||||
'Content-Type': 'text/csv; charset=utf-8',
|
||||
'Content-Disposition': 'inline; filename="job_notifications.csv"'
|
||||
}
|
||||
return render_template(
|
||||
'views/jobs/job.html',
|
||||
notifications=notifications['notifications'],
|
||||
|
||||
@@ -30,6 +30,12 @@
|
||||
)}}
|
||||
{% endif %}
|
||||
|
||||
<p class="bottom-gutter">
|
||||
<a href="{{ request.url }}?&download=csv" download class="heading-small">Download as a CSV file</a>
|
||||
 
|
||||
Delivery information is available for 7 days
|
||||
</p>
|
||||
|
||||
{% include 'partials/jobs/status.html' %}
|
||||
|
||||
{% include 'partials/jobs/count.html' %}
|
||||
|
||||
@@ -262,3 +262,27 @@ def test_should_download_notifications_for_a_service(app_,
|
||||
assert response.status_code == 200
|
||||
assert response.get_data(as_text=True) == csv_content
|
||||
assert 'text/csv' in response.headers['Content-Type']
|
||||
|
||||
|
||||
def test_should_download_notifications_for_a_job(app_,
|
||||
api_user_active,
|
||||
mock_login,
|
||||
mock_get_service,
|
||||
mock_get_job,
|
||||
mock_get_notifications,
|
||||
mock_get_template_version,
|
||||
mock_has_permissions,
|
||||
fake_uuid):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for(
|
||||
'main.view_job',
|
||||
service_id=fake_uuid,
|
||||
job_id=fake_uuid,
|
||||
download='csv'))
|
||||
csv_content = generate_notifications_csv(
|
||||
mock_get_notifications(fake_uuid, job_id=fake_uuid)['notifications'])
|
||||
assert response.status_code == 200
|
||||
assert response.get_data(as_text=True) == csv_content
|
||||
assert 'text/csv' in response.headers['Content-Type']
|
||||
|
||||
Reference in New Issue
Block a user