diff --git a/teknologr/members/models.py b/teknologr/members/models.py index e8a04d60..311e99dd 100644 --- a/teknologr/members/models.py +++ b/teknologr/members/models.py @@ -57,7 +57,8 @@ def search_by_name(self, queries, staff_search=False): Q(preferred_name__icontains=q) | Q(surname__icontains=q) | Q(comment__icontains=q) | - Q(email__icontains=q) + Q(email__icontains=q) | + Q(username__icontains=q) ) for q in queries] else: filters = [( diff --git a/teknologr/members/tests_models.py b/teknologr/members/tests_models.py index d0429748..8ef1530e 100644 --- a/teknologr/members/tests_models.py +++ b/teknologr/members/tests_models.py @@ -161,8 +161,9 @@ def test_str(self): def test_search_by_name(self): Member.objects.create(given_names='Bar Foo', surname='von Test', allow_publish_info=False) Member.objects.create(given_names='Test', surname='Test', allow_publish_info=False, comment="foo") + Member.objects.create(given_names='Test', surname='Test', allow_publish_info=False, username="afood") self.assertEqual(3, len(Member.objects.search_by_name(["foo"], False))) - self.assertEqual(5, len(Member.objects.search_by_name(["foo"], True))) + self.assertEqual(6, len(Member.objects.search_by_name(["foo"], True))) self.assertEqual(1, len(Member.objects.search_by_name(["foo", "von"], False))) self.assertEqual(2, len(Member.objects.search_by_name(["foo", "von"], True)))