mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-02 20:40:51 -04:00
Merge pull request #2643 from alphagov/dont-count-pages-api-message-log
Don't request pagination links for API Message log page
This commit is contained in:
@@ -13,6 +13,7 @@ class NotificationApiClient(NotifyAdminAPIClient):
|
||||
status=None,
|
||||
page=None,
|
||||
page_size=None,
|
||||
count_pages=None,
|
||||
limit_days=None,
|
||||
include_jobs=None,
|
||||
include_from_test_key=None,
|
||||
@@ -20,25 +21,22 @@ class NotificationApiClient(NotifyAdminAPIClient):
|
||||
to=None,
|
||||
include_one_off=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:
|
||||
params['status'] = status
|
||||
if include_jobs is not None:
|
||||
params['include_jobs'] = include_jobs
|
||||
if include_from_test_key is not None:
|
||||
params['include_from_test_key'] = include_from_test_key
|
||||
if format_for_csv is not None:
|
||||
params['format_for_csv'] = format_for_csv
|
||||
if to is not None:
|
||||
params['to'] = to
|
||||
if include_one_off is not None:
|
||||
params['include_one_off'] = include_one_off
|
||||
|
||||
params = {
|
||||
'page': page,
|
||||
'page_size': page_size,
|
||||
'template_type': template_type,
|
||||
'status': status,
|
||||
'include_jobs': include_jobs,
|
||||
'include_from_test_key': include_from_test_key,
|
||||
'format_for_csv': format_for_csv,
|
||||
'to': to,
|
||||
'include_one_off': include_one_off,
|
||||
'count_pages': count_pages,
|
||||
}
|
||||
|
||||
params = {k: v for k, v in params.items() if v is not None}
|
||||
|
||||
if job_id:
|
||||
return self.get(
|
||||
url='/service/{}/job/{}/notifications'.format(service_id, job_id),
|
||||
@@ -71,7 +69,8 @@ class NotificationApiClient(NotifyAdminAPIClient):
|
||||
service_id,
|
||||
include_jobs=False,
|
||||
include_from_test_key=True,
|
||||
include_one_off=False
|
||||
include_one_off=False,
|
||||
count_pages=False
|
||||
)
|
||||
return self.map_letters_to_accepted(ret)
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
{% endfor %}
|
||||
{% if api_notifications.notifications %}
|
||||
<div class="api-notifications-item">
|
||||
{% if api_notifications.links %}
|
||||
{% if api_notifications.notifications|length == 50 %}
|
||||
<p class="api-notifications-item-meta">
|
||||
Only showing the first 50 messages.
|
||||
</p>
|
||||
|
||||
@@ -1898,6 +1898,7 @@ def mock_get_notifications(
|
||||
job_id=None,
|
||||
page=1,
|
||||
page_size=50,
|
||||
count_pages=None,
|
||||
template_type=None,
|
||||
status=None,
|
||||
limit_days=None,
|
||||
@@ -1931,6 +1932,7 @@ def mock_get_notifications(
|
||||
template=template,
|
||||
rows=rows,
|
||||
job=job,
|
||||
with_links=True if count_pages is None else count_pages,
|
||||
personalisation=personalisation,
|
||||
template_type=diff_template_type,
|
||||
client_reference=client_reference,
|
||||
@@ -1950,6 +1952,7 @@ def mock_get_notifications_with_previous_next(mocker):
|
||||
def _get_notifications(service_id,
|
||||
job_id=None,
|
||||
page=1,
|
||||
count_pages=None,
|
||||
template_type=None,
|
||||
status=None,
|
||||
limit_days=None,
|
||||
@@ -1958,7 +1961,7 @@ def mock_get_notifications_with_previous_next(mocker):
|
||||
to=None,
|
||||
include_one_off=None
|
||||
):
|
||||
return notification_json(service_id, with_links=True)
|
||||
return notification_json(service_id, rows=50, with_links=True if count_pages is None else count_pages)
|
||||
|
||||
return mocker.patch(
|
||||
'app.notification_api_client.get_notifications_for_service',
|
||||
@@ -1971,6 +1974,7 @@ def mock_get_notifications_with_no_notifications(mocker):
|
||||
def _get_notifications(service_id,
|
||||
job_id=None,
|
||||
page=1,
|
||||
count_pages=None,
|
||||
template_type=None,
|
||||
status=None,
|
||||
limit_days=None,
|
||||
|
||||
Reference in New Issue
Block a user