Skip to content

Commit

Permalink
Merge pull request #189 from Teknologforeningen/feature/add-username-…
Browse files Browse the repository at this point in the history
…to-serach-query

Added Member username as part of the search space for staff. This is …
  • Loading branch information
filiptypjeu authored Jan 6, 2024
2 parents 987a6f6 + facf94a commit ee35cef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion teknologr/members/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [(
Expand Down
3 changes: 2 additions & 1 deletion teknologr/members/tests_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down

0 comments on commit ee35cef

Please sign in to comment.