Job notification download now includes all notifications.

Get row number to match excel format.

Fix for no job_row_number.
This commit is contained in:
Nicholas Staples
2016-05-31 10:21:40 +01:00
parent 01884655c7
commit 5ef5920c17
2 changed files with 7 additions and 2 deletions

View File

@@ -79,7 +79,11 @@ def view_job(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'])
notification_api_client.get_notifications_for_service(
service_id,
job_id,
page_size=job['notification_count']
)['notifications'])
return csv_content, 200, {
'Content-Type': 'text/csv; charset=utf-8',
'Content-Disposition': 'inline; filename="{} - {}.csv"'.format(

View File

@@ -98,9 +98,10 @@ def generate_notifications_csv(json_list):
retval = None
with content as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerow(['Recipient', 'Template', 'Type', 'Job', 'Status', 'Time'])
csvwriter.writerow(['Row number', 'Recipient', 'Template', 'Type', 'Job', 'Status', 'Time'])
for x in json_list:
csvwriter.writerow([
int(x['job_row_number']) + 2 if 'job_row_number' in x and x['job_row_number'] else '',
x['to'],
x['template']['name'],
x['template']['template_type'],