mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 11:23:48 -05: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',
|
||||
'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"'
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user