Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add member_number to search users presenter #2586

Merged
merged 5 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion openslides_backend/presenter/search_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
from .base import BasePresenter
from .presenter import register_presenter

search_fields = [["username"], ["saml_id"], ["first_name", "last_name", "email"]]
search_fields = [
["username"],
["saml_id"],
["member_number"],
["first_name", "last_name", "email"],
]
all_fields = [field for fields in search_fields for field in fields]

search_users_schema = fastjsonschema.compile(
Expand Down
22 changes: 21 additions & 1 deletion tests/system/presenter/test_search_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def setUp(self) -> None:
"last_name": "last2",
"username": "user2",
"saml_id": None,
"member_number": None,
}
self.user3 = {
"id": 3,
Expand All @@ -25,6 +26,7 @@ def setUp(self) -> None:
"last_name": "last3",
"username": "user3",
"saml_id": None,
"member_number": None,
}
self.user4 = {
"id": 4,
Expand All @@ -33,6 +35,7 @@ def setUp(self) -> None:
"last_name": "last4",
"username": "user4",
"saml_id": None,
"member_number": None,
}
self.user5 = {
"id": 5,
Expand All @@ -41,6 +44,16 @@ def setUp(self) -> None:
"last_name": "last5",
"username": "user5",
"saml_id": "saml5",
"member_number": None,
}
self.user6 = {
"id": 6,
"email": "[email protected]",
"first_name": "first6",
"last_name": "last6",
"username": "user6",
"saml_id": "saml6",
"member_number": "member6",
}

self.set_models(
Expand All @@ -57,6 +70,9 @@ def setUp(self) -> None:
"user/5": {
**self.user5,
},
"user/6": {
**self.user6,
},
}
)

Expand Down Expand Up @@ -113,18 +129,22 @@ def test_search_fields_variations(self) -> None:
"username": "userX",
"saml_id": "saml5",
},
{
"member_number": "member6",
},
],
},
)
self.assertEqual(status_code, 200)
self.assertEqual(len(data), 7)
self.assertEqual(len(data), 8)
self.assertEqual(data[0], [self.user2])
self.assertEqual(data[1], [])
self.assertEqual(data[2], [self.user2])
self.assertEqual(data[3], [self.user4])
self.assertEqual(data[4], [self.user2])
self.assertEqual(data[5], [self.user5])
self.assertEqual(data[6], [])
self.assertEqual(data[7], [self.user6])

def test_search_ignore_case_strip(self) -> None:
status_code, data = self.request(
Expand Down