mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Functionality added to download all on activity page. All tests passing.
This commit is contained in:
@@ -140,7 +140,14 @@ def view_notifications(service_id):
|
|||||||
'Next page',
|
'Next page',
|
||||||
'page {}'.format(page + 1))
|
'page {}'.format(page + 1))
|
||||||
if 'download' in request.args and request.args['download'] == 'csv':
|
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, {
|
return csv_content, 200, {
|
||||||
'Content-Type': 'text/csv; charset=utf-8',
|
'Content-Type': 'text/csv; charset=utf-8',
|
||||||
'Content-Disposition': 'inline; filename="notifications.csv"'
|
'Content-Disposition': 'inline; filename="notifications.csv"'
|
||||||
|
|||||||
@@ -21,10 +21,18 @@ class NotificationApiClient(BaseAPIClient):
|
|||||||
params=params
|
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 = {}
|
params = {}
|
||||||
if page is not None:
|
if page is not None:
|
||||||
params['page'] = page
|
params['page'] = page
|
||||||
|
if page_size is not None:
|
||||||
|
params['page_size'] = page_size
|
||||||
if template_type is not None:
|
if template_type is not None:
|
||||||
params['template_type'] = template_type
|
params['template_type'] = template_type
|
||||||
if status is not None:
|
if status is not None:
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ def notification_json(service_id,
|
|||||||
'status': status,
|
'status': status,
|
||||||
'created_at': created_at
|
'created_at': created_at
|
||||||
} for i in range(5)],
|
} for i in range(5)],
|
||||||
|
'total': 5,
|
||||||
|
'page_size': 50,
|
||||||
'links': links
|
'links': links
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -674,6 +674,7 @@ def mock_get_notifications(mocker):
|
|||||||
def _get_notifications(service_id,
|
def _get_notifications(service_id,
|
||||||
job_id=None,
|
job_id=None,
|
||||||
page=1,
|
page=1,
|
||||||
|
page_size=50,
|
||||||
template_type=None,
|
template_type=None,
|
||||||
status=None):
|
status=None):
|
||||||
return notification_json(service_id)
|
return notification_json(service_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user