From 3844d050ffad7be63bc95766815a2f3fe028ff80 Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Fri, 16 Aug 2019 11:20:36 +0100 Subject: [PATCH] Simplify find users by email view - valdiation already done by form --- app/main/views/find_users.py | 5 +---- tests/app/main/views/test_find_users.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/main/views/find_users.py b/app/main/views/find_users.py index 11c1242f6..fa42b5a19 100644 --- a/app/main/views/find_users.py +++ b/app/main/views/find_users.py @@ -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/", methods=['GET']) diff --git a/tests/app/main/views/test_find_users.py b/tests/app/main/views/test_find_users.py index 345c10bef..5c64e8dd9 100644 --- a/tests/app/main/views/test_find_users.py +++ b/tests/app/main/views/test_find_users.py @@ -82,7 +82,7 @@ def test_find_users_by_email_validates_against_empty_search_submission( mocker ): client_request.login(platform_admin_user) - document = client_request.post('main.find_users_by_email', _data={"search": ""}, _expected_status=400) + document = client_request.post('main.find_users_by_email', _data={"search": ""}, _expected_status=200) expected_message = "You need to enter full or partial email address to search by." assert document.find('span', {'class': 'error-message'}).text.strip() == expected_message