Allow users of the API to search templates by ID

For someone who has retrieved a template ID from their system the only
way to find it in Notify is:
- hack the URL
- click through every template, visually inspecting the ID shown on the
  page until you find the right one

Neither of these is ideal.

This commit adds searching by ID, for those services who have an API
integration. This means we don’t need to confuse teams who aren’t using
the API by talking about IDs.

This is similar to how we let these teams search for notifications by
reference[1]

1. https://github.com/alphagov/notifications-admin/pull/3223/files
This commit is contained in:
Chris Hill-Scott
2021-04-13 13:59:51 +01:00
parent 69ed9e965a
commit c95b2ef8b3
10 changed files with 142 additions and 8 deletions

View File

@@ -1924,6 +1924,17 @@ class SearchNotificationsForm(StripWhitespaceForm):
)
class SearchTemplatesForm(StripWhitespaceForm):
search = GovukSearchField()
def __init__(self, api_keys, *args, **kwargs):
super().__init__(*args, **kwargs)
self.search.label.text = (
'Search by name or ID' if api_keys else 'Search by name'
)
class PlaceholderForm(StripWhitespaceForm):
pass