Skip to content

Commit

Permalink
rough in page for uuid queries
Browse files Browse the repository at this point in the history
  • Loading branch information
sastels committed Oct 4, 2024
1 parent 3dae5ae commit a90cdf2
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/main/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
email_branding,
find_services,
find_users,
find_ids,
forgot_password,
inbound_number,
index,
Expand Down
10 changes: 8 additions & 2 deletions app/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."))],
)


Expand Down
17 changes: 17 additions & 0 deletions app/main/views/find_ids.py
Original file line number Diff line number Diff line change
@@ -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)

5 changes: 5 additions & 0 deletions app/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions app/notify_client/user_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions app/templates/partials/nav/gc_header_nav_mobile.html
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
63 changes: 63 additions & 0 deletions app/templates/views/find-ids/find-ids.html
Original file line number Diff line number Diff line change
@@ -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 %}

<h1 class="heading-large">
{{ _('Search for ids') }}
</h1>


{% call form_wrapper(
action=url_for('.find_ids'),
class='grid-row contain-floats'
) %}
{% set label_txt = _('Find records by uuid') %}
<div class="md:w-full float-left py-0 px-0 px-gutterHalf box-border">
{{ textbox_search(
form.search,
width='w-full',
label=label_txt
) }}
</div>
{% endcall %}

{% call form_wrapper(id='search-form' ) %}
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
{% endcall %}

{% if records %}
{% for record in records %}
<nav class="browse-list">
<ul>
<li class="browse-list-item">
{{ record.id }} :
{% if record.type == "notification" %}
<a href="{{url_for('.view_notification', service_id=record.service_id, notification_id=record.id)}}" class="browse-list-link">notification</a>
{% elif record.type == "template" %}
<a href="{{url_for('.view_template', service_id=record.service_id, template_id=record.id)}}" class="browse-list-link">{{ record.template_name }}</a>
{% elif record.type == "service" %}
<a href="{{url_for('.service_dashboard', service_id=record.id)}}" class="browse-list-link">{{ record.service_name}} </a>
{% elif record.type == "user" %}
<a href="{{url_for('.user_information', user_id=record.id)}}" class="browse-list-link">{{ record.user_name }}</a>
{% elif record.type == "job" %}
<a href="{{url_for('.view_job', service_id=record.service_id, job_id=record.id)}}" class="browse-list-link">job</a>
{% else %}
{{ record.type}}
{% endif %}
</li>
<hr>
</ul>
</nav>
{% endfor %}

{% elif records == [] %}
<p class="browse-list-hint">{{ _('No records found.') }}</p>
{% endif %}
{% endblock %}
1 change: 1 addition & 0 deletions app/templates/views/platform-admin/_base_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit a90cdf2

Please sign in to comment.