Functionality added to download all on activity page. All tests passing.

This commit is contained in:
Nicholas Staples
2016-04-19 11:45:36 +01:00
parent c2b96be247
commit f3210ea992
4 changed files with 20 additions and 2 deletions

View File

@@ -140,7 +140,14 @@ def view_notifications(service_id):
'Next page',
'page {}'.format(page + 1))
if 'download' in request.args and request.args['download'] == 'csv':
csv_content = generate_notifications_csv(notifications['notifications'])
csv_content = generate_notifications_csv(
notification_api_client.get_notifications_for_service(
service_id=service_id,
page=page,
page_size=notifications['total'],
template_type=filter_args.getlist('template_type') if 'template_type' in filter_args else None,
status=filter_args.getlist('status')
if 'status' in filter_args else ['delivered', 'failed'])['notifications'])
return csv_content, 200, {
'Content-Type': 'text/csv; charset=utf-8',
'Content-Disposition': 'inline; filename="notifications.csv"'

View File

@@ -21,10 +21,18 @@ class NotificationApiClient(BaseAPIClient):
params=params
)
def get_notifications_for_service(self, service_id, job_id=None, template_type=None, status=None, page=None):
def get_notifications_for_service(self,
service_id,
job_id=None,
template_type=None,
status=None,
page=None,
page_size=None):
params = {}
if page is not None:
params['page'] = page
if page_size is not None:
params['page_size'] = page_size
if template_type is not None:
params['template_type'] = template_type
if status is not None:

View File

@@ -149,6 +149,8 @@ def notification_json(service_id,
'status': status,
'created_at': created_at
} for i in range(5)],
'total': 5,
'page_size': 50,
'links': links
}
return data

View File

@@ -674,6 +674,7 @@ def mock_get_notifications(mocker):
def _get_notifications(service_id,
job_id=None,
page=1,
page_size=50,
template_type=None,
status=None):
return notification_json(service_id)