Don’t ask for data retention unless channel is known

If the user is looking at the notifications page for all message types
(which is what we show ‘caseworkers’) then it doesn’t make sense to ask
the API for the data retention period for that message type (because
it will be `None`). Doing so causes the API to return a `404`, which
then causes the admin app to return `404`.

Passing through `None` as the value of limit days will just cause the
API to return everything in the `notifications` table, which is fine
for us.
This commit is contained in:
Chris Hill-Scott
2018-11-15 17:04:11 +00:00
parent f47215ddc7
commit f3d1dc4a9c
2 changed files with 43 additions and 8 deletions

View File

@@ -216,10 +216,12 @@ def get_notifications(service_id, message_type, status_override=None):
abort(404)
filter_args = parse_filter_args(request.args)
filter_args['status'] = set_status_filters(filter_args)
service_data_retention_days = None
service_data_retention_days = service_api_client.get_service_data_retention_by_notification_type(
service_id, message_type
).get('days_of_retention', current_app.config['ACTIVITY_STATS_LIMIT_DAYS'])
if message_type is not None:
service_data_retention_days = service_api_client.get_service_data_retention_by_notification_type(
service_id, message_type
).get('days_of_retention', current_app.config['ACTIVITY_STATS_LIMIT_DAYS'])
if request.path.endswith('csv') and current_user.has_permissions('view_activity'):
return Response(