Use get_prev_next_pagination_links when searching by to field

The only change in behaviour is that we are no longer including a
`last` pagination link.

This is OK because the frontend doesnt use it, just the prev and
next links as per
https://github.com/alphagov/notifications-admin/blob/master/app/main/views/jobs.py#L248
This commit is contained in:
David McDonald
2021-12-10 11:50:16 +00:00
parent 6ac4e67f78
commit edadeb9131
2 changed files with 3 additions and 7 deletions

View File

@@ -150,7 +150,6 @@ from app.utils import (
DATETIME_FORMAT_NO_TIMEZONE,
get_prev_next_pagination_links,
midnight_n_days_ago,
pagination_links,
)
service_blueprint = Blueprint('service', __name__)
@@ -533,11 +532,9 @@ def search_for_notification_by_to_field(service_id, search_term, statuses, notif
)
return jsonify(
notifications=notification_with_template_schema.dump(results.items, many=True).data,
# TODO: this may be a bug to include the pagination links as currently `search_for_notification_by_to_field`
# hardcodes the pages of results to always be the first page so not sure what benefit is to show a link to
# page 2 which would have the page parameter ignored
links=pagination_links(
results,
links=get_prev_next_pagination_links(
1,
results.has_next,
'.get_all_notifications_for_service',
statuses=statuses,
notification_type=notification_type,