Give the job CSV a helpful filename

If you’re downloading a bunch of reports from your jobs then it’s useful to be
able to differentiate between them. This commit makes it easy to do so by naming
the file with:
- the name of the template
- when the job was created
This commit is contained in:
Chris Hill-Scott
2016-05-24 09:52:43 +01:00
parent 8a30a5bf51
commit dd25eb0fe1
3 changed files with 10 additions and 2 deletions

View File

@@ -18,7 +18,8 @@ from app import (
job_api_client,
notification_api_client,
service_api_client,
current_service)
current_service,
format_datetime_short)
from app.main import main
from app.utils import (
get_page_from_request,
@@ -81,7 +82,10 @@ def view_job(service_id, job_id):
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"'
'Content-Disposition': 'inline; filename="{} - {}.csv"'.format(
template['name'],
format_datetime_short(job['created_at'])
)
}
return render_template(
'views/jobs/job.html',