From a90cdf2f83a55ac84acd6a8b1bd86c03134f970d Mon Sep 17 00:00:00 2001 From: Stephen Astels Date: Fri, 4 Oct 2024 13:18:31 -0400 Subject: [PATCH] rough in page for uuid queries --- app/main/__init__.py | 1 + app/main/forms.py | 10 ++- app/main/views/find_ids.py | 17 +++++ app/navigation.py | 5 ++ app/notify_client/user_api_client.py | 3 + .../partials/nav/gc_header_nav_mobile.html | 1 + app/templates/views/find-ids/find-ids.html | 63 +++++++++++++++++++ .../views/platform-admin/_base_template.html | 1 + 8 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 app/main/views/find_ids.py create mode 100644 app/templates/views/find-ids/find-ids.html diff --git a/app/main/__init__.py b/app/main/__init__.py index ba12be41a1..31912ad5ca 100644 --- a/app/main/__init__.py +++ b/app/main/__init__.py @@ -12,6 +12,7 @@ email_branding, find_services, find_users, + find_ids, forgot_password, inbound_number, index, diff --git a/app/main/forms.py b/app/main/forms.py index d890972398..5b7ea309ef 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -1324,8 +1324,14 @@ class SearchByNameForm(StripWhitespaceForm): class SearchUsersByEmailForm(StripWhitespaceForm): search = SearchField( - _l("Search by name or email address"), - validators=[DataRequired(_l("You need to enter full or partial email address to search by."))], + _l("zzzzzSearch by name or email address"), + validators=[DataRequired(_l("zzzzzzYou need to enter full or partial email address to search by."))], + ) + +class SearchIds(StripWhitespaceForm): + search = SearchField( + _l("List of IDs"), + validators=[DataRequired(_l("You need to enter one or more uuids to search by."))], ) diff --git a/app/main/views/find_ids.py b/app/main/views/find_ids.py new file mode 100644 index 0000000000..de268be2cd --- /dev/null +++ b/app/main/views/find_ids.py @@ -0,0 +1,17 @@ +from flask import render_template + +from app import user_api_client +from app.main import main +from app.main.forms import SearchIds +from app.utils import user_is_platform_admin + + +@main.route("/find-ids", methods=["GET", "POST"]) +@user_is_platform_admin +def find_ids(): + form = SearchIds() + records = None + if form.validate_on_submit(): + records = user_api_client.find_ids(form.search.data) + return render_template("views/find-ids/find-ids.html", form=form, records=records) + diff --git a/app/navigation.py b/app/navigation.py index 95d2e5fb5f..8f769fbfcb 100644 --- a/app/navigation.py +++ b/app/navigation.py @@ -59,6 +59,9 @@ class AdminNavigation(Navigation): "find_users_by_email": { "find_users_by_email", }, + "find_ids": { + "find_ids", + }, "platform_admin_list_complaints": { "platform_admin_list_complaints", }, @@ -506,6 +509,7 @@ class MainNavigation(Navigation): "template_categories", "find_services_by_name", "find_users_by_email", + "find_ids", "letter_branding", "live_api_keys", "live_services", @@ -630,6 +634,7 @@ class OrgNavigation(Navigation): "contact", "find_services_by_name", "find_users_by_email", + "find_ids", "forgot_password", "forced-password-reset", "get_example_csv", diff --git a/app/notify_client/user_api_client.py b/app/notify_client/user_api_client.py index 6cbd930f63..b7354473dc 100644 --- a/app/notify_client/user_api_client.py +++ b/app/notify_client/user_api_client.py @@ -94,6 +94,9 @@ def verify_password(self, user_id, password, login_data={}): if e.status_code == 400 or e.status_code == 404: return False + def find_ids(self, ids): + return self.get("/support/find-ids", params={"ids": ids}) + def send_verify_code(self, user_id, code_type, to, next_string=None): data = {"to": to} if next_string: diff --git a/app/templates/partials/nav/gc_header_nav_mobile.html b/app/templates/partials/nav/gc_header_nav_mobile.html index a935e71914..a40b6b0844 100644 --- a/app/templates/partials/nav/gc_header_nav_mobile.html +++ b/app/templates/partials/nav/gc_header_nav_mobile.html @@ -56,6 +56,7 @@ ('Template categories', 'template_categories'), ('Search for service', 'find_services_by_name'), ('Search for user', 'find_users_by_email'), + ('Search for ids', 'find_ids'), ('Email complaints', 'platform_admin_list_complaints'), ('Reports', 'platform_admin_reports'), ('Inbound SMS numbers', 'inbound_sms_admin'), diff --git a/app/templates/views/find-ids/find-ids.html b/app/templates/views/find-ids/find-ids.html new file mode 100644 index 0000000000..35c99aae98 --- /dev/null +++ b/app/templates/views/find-ids/find-ids.html @@ -0,0 +1,63 @@ +{% extends "views/platform-admin/_base_template.html" %} +{% from "components/form.html" import form_wrapper %} +{% from "components/page-footer.html" import page_footer %} +{% from "components/textbox.html" import textbox_search %} + +{% block per_page_title %} + {{ _('Search for uuids') }} +{% endblock %} + +{% block platform_admin_content %} + +

+ {{ _('Search for ids') }} +

+ + + {% call form_wrapper( + action=url_for('.find_ids'), + class='grid-row contain-floats' + ) %} + {% set label_txt = _('Find records by uuid') %} +
+ {{ textbox_search( + form.search, + width='w-full', + label=label_txt + ) }} +
+ {% endcall %} + + {% call form_wrapper(id='search-form' ) %} + + {% endcall %} + + {% if records %} + {% for record in records %} + + {% endfor %} + + {% elif records == [] %} +

{{ _('No records found.') }}

+ {% endif %} +{% endblock %} diff --git a/app/templates/views/platform-admin/_base_template.html b/app/templates/views/platform-admin/_base_template.html index 621c902afd..3786162842 100644 --- a/app/templates/views/platform-admin/_base_template.html +++ b/app/templates/views/platform-admin/_base_template.html @@ -17,6 +17,7 @@ ('Template categories', 'template_categories'), ('Search for service', 'find_services_by_name'), ('Search for user', 'find_users_by_email'), + ('Search for ids', 'find_ids'), ('Email complaints', 'platform_admin_list_complaints'), ('Reports', 'platform_admin_reports'), ('Inbound SMS numbers', 'inbound_sms_admin'),