From 6ba47333903c6f7ca34e6cc6b4dce36ca76be186 Mon Sep 17 00:00:00 2001 From: katrinan029 Date: Tue, 24 Sep 2024 19:16:25 +0000 Subject: [PATCH] Revert "feat: add username query" This reverts commit 276379e275463f99d5f4856fffeb078ad14048ad. --- .../api/v1/views/enterprise_customer_support.py | 6 ++---- tests/test_enterprise/api/test_views.py | 13 ++----------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/enterprise/api/v1/views/enterprise_customer_support.py b/enterprise/api/v1/views/enterprise_customer_support.py index 2141ca38c..b01474c7f 100644 --- a/enterprise/api/v1/views/enterprise_customer_support.py +++ b/enterprise/api/v1/views/enterprise_customer_support.py @@ -73,10 +73,8 @@ def filter_queryset_by_user_query(self, queryset, is_pending_user=False): if user_query: if not is_pending_user: - queryset = models.EnterpriseCustomerUser.objects.filter( - user_id__in=User.objects.filter( - Q(email__icontains=user_query) | Q(username__icontains=user_query) - ) + queryset = queryset.filter( + user_id__in=User.objects.filter(Q(email__icontains=user_query)) ) else: queryset = queryset.filter(user_email=user_query) diff --git a/tests/test_enterprise/api/test_views.py b/tests/test_enterprise/api/test_views.py index 9f72da821..e62fba6dc 100644 --- a/tests/test_enterprise/api/test_views.py +++ b/tests/test_enterprise/api/test_views.py @@ -9737,17 +9737,8 @@ def test_list_users_filtered(self): 'role_assignments': [ENTERPRISE_LEARNER_ROLE], 'is_admin': False }] - # search by email - user_query_email = f'?user_query={enterprise_customer_user.user_email}' - url = reverse(self.ECS_ENDPOINT, kwargs={self.ECS_KWARG: enterprise_customer.uuid}) + user_query_email - response = self.client.get(settings.TEST_SERVER + url) - - assert expected_json == response.json().get('results') - assert response.json().get('count') == 1 - - # search by username - user_query_username = f'?user_query={enterprise_customer_user.username}' - url = reverse(self.ECS_ENDPOINT, kwargs={self.ECS_KWARG: enterprise_customer.uuid}) + user_query_username + user_query_string = f'?user_query={enterprise_customer_user.user_email}' + url = reverse(self.ECS_ENDPOINT, kwargs={self.ECS_KWARG: enterprise_customer.uuid}) + user_query_string response = self.client.get(settings.TEST_SERVER + url) assert expected_json == response.json().get('results')