Skip to content

Commit

Permalink
Allow user to delete member_number (#2452)
Browse files Browse the repository at this point in the history
  • Loading branch information
luisa-beerboom authored May 29, 2024
1 parent 0ad86ba commit a319ec6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion openslides_backend/action/actions/user/user_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def check_existence(what: str) -> None:

check_existence("username")
check_existence("saml_id")
check_existence("member_number")
if instance.get("member_number") is not None:
check_existence("member_number")

self.check_meeting_and_users(
instance, fqid_from_collection_and_id("user", instance["id"])
Expand Down
8 changes: 8 additions & 0 deletions tests/system/action/user/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,14 @@ def test_member_number_already_exists(self) -> None:
== "A user with the member_number 14m4m3m832 already exists."
)

def test_member_number_none(self) -> None:
response = self.request(
"user.create",
{"username": "user2", "member_number": None},
)
self.assert_status_code(response, 200)
self.assert_model_exists("user/2", {"member_number": None})

def test_user_create_with_empty_vote_delegation_from_ids(self) -> None:
self.set_models(
{
Expand Down
6 changes: 6 additions & 0 deletions tests/system/action/user/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,12 @@ def test_member_number_already_given(self) -> None:
response.json["message"],
)

def test_clear_member_number(self) -> None:
self.create_model("user/222", {"member_number": "klmnopqrst"})
response = self.request("user.update", {"id": 222, "member_number": None})
self.assert_status_code(response, 200)
self.assert_model_exists("user/222", {"member_number": None})

def test_same_username(self) -> None:
response = self.request("user.update", {"id": 1, "username": "admin"})
self.assert_status_code(response, 200)
Expand Down

0 comments on commit a319ec6

Please sign in to comment.