mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 22:40:31 -04:00
Merge pull request #3089 from alphagov/search-services-by-name
Find services by name or partial name
This commit is contained in:
@@ -12,6 +12,7 @@ from app.main.views import ( # noqa isort:skip
|
||||
dashboard,
|
||||
email_branding,
|
||||
feedback,
|
||||
find_services,
|
||||
find_users,
|
||||
forgot_password,
|
||||
inbound_number,
|
||||
|
||||
@@ -1127,7 +1127,10 @@ class RequiredDateFilterForm(StripWhitespaceForm):
|
||||
|
||||
class SearchByNameForm(StripWhitespaceForm):
|
||||
|
||||
search = SearchField('Search by name')
|
||||
search = SearchField(
|
||||
'Search by name',
|
||||
validators=[DataRequired("You need to enter full or partial name to search by.")],
|
||||
)
|
||||
|
||||
|
||||
class SearchUsersByEmailForm(StripWhitespaceForm):
|
||||
|
||||
20
app/main/views/find_services.py
Normal file
20
app/main/views/find_services.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from flask import render_template
|
||||
|
||||
from app import service_api_client
|
||||
from app.main import main
|
||||
from app.main.forms import SearchByNameForm
|
||||
from app.utils import user_is_platform_admin
|
||||
|
||||
|
||||
@main.route("/find-services-by-name", methods=['GET', 'POST'])
|
||||
@user_is_platform_admin
|
||||
def find_services_by_name():
|
||||
form = SearchByNameForm()
|
||||
services_found = None
|
||||
if form.validate_on_submit():
|
||||
services_found = service_api_client.find_services_by_name(service_name=form.search.data)['data']
|
||||
return render_template(
|
||||
'views/find-services/find-services-by-name.html',
|
||||
form=form,
|
||||
services_found=services_found
|
||||
)
|
||||
@@ -14,16 +14,13 @@ from app.utils import user_is_platform_admin
|
||||
def find_users_by_email():
|
||||
form = SearchUsersByEmailForm()
|
||||
users_found = None
|
||||
status = 200
|
||||
if form.validate_on_submit():
|
||||
users_found = user_api_client.find_users_by_full_or_partial_email(form.search.data)['data']
|
||||
elif request.method == 'POST':
|
||||
status = 400
|
||||
return render_template(
|
||||
'views/find-users/find-users-by-email.html',
|
||||
form=form,
|
||||
users_found=users_found
|
||||
), status
|
||||
)
|
||||
|
||||
|
||||
@main.route("/users/<user_id>", methods=['GET'])
|
||||
|
||||
Reference in New Issue
Block a user