Optionally get only notifications created by API

This commit adds the `include_jobs` filter to the
`GET /services/…/notifications` endpoint. It defaults to `True` (ie show
all notifications) but makes it possible to only return notifications
created by _any_ API key.

This is so that we can show a log of all notifications sent through the
API in the admin app.

It does not expose this list to the public `GET /notifications` endpoint
because this would violate our rules about keys only being able to get
notifications created with keys of the same type.
This commit is contained in:
Chris Hill-Scott
2016-09-21 09:46:34 +01:00
parent 0c5720108d
commit 4217bd2108
2 changed files with 23 additions and 1 deletions

View File

@@ -213,6 +213,7 @@ def get_all_notifications_for_service(service_id):
page = data['page'] if 'page' in data else 1
page_size = data['page_size'] if 'page_size' in data else current_app.config.get('PAGE_SIZE')
limit_days = data.get('limit_days')
include_jobs = data.get('include_jobs', True)
pagination = notifications_dao.get_notifications_for_service(
service_id,
@@ -220,7 +221,7 @@ def get_all_notifications_for_service(service_id):
page=page,
page_size=page_size,
limit_days=limit_days,
include_jobs=True)
include_jobs=include_jobs)
kwargs = request.args.to_dict()
kwargs['service_id'] = service_id
return jsonify(