Require data on search by name form

This lets us build leaner views when using this form.
This commit is contained in:
Pea Tyczynska
2019-08-15 12:41:46 +01:00
parent 035cb19568
commit a906552c25
2 changed files with 6 additions and 6 deletions

View File

@@ -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):

View File

@@ -1,4 +1,4 @@
from flask import render_template, request
from flask import render_template
from app import service_api_client
from app.main import main
@@ -11,13 +11,10 @@ from app.utils import user_is_platform_admin
def find_services_by_name():
form = SearchByNameForm()
services_found = None
status = 200
if form.validate_on_submit():
services_found = service_api_client.find_services_by_name(service_name=form.search.data)['data']
elif request.method == 'POST':
status = 400
return render_template(
'views/find-services/find-services-by-name.html',
form=form,
services_found=services_found
), status
)