Skip to content

Commit

Permalink
Fix participant import re-upload structure_level error (OpenSlides#2313)
Browse files Browse the repository at this point in the history
  • Loading branch information
luisa-beerboom authored and peb-adr committed Mar 19, 2024
1 parent a9aa076 commit 55032b0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def update_instance(self, instance: dict[str, Any]) -> dict[str, Any]:
return instance

def update_models_to_create(self, model_name: str, field_name: str) -> None:
self.models_to_create[field_name] = []
to_create: set[str] = {
entry["value"]
for row in self.rows
Expand Down
41 changes: 41 additions & 0 deletions tests/system/action/user/test_participant_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,3 +1051,44 @@ def test_json_upload_legacy_username(self) -> None:
self.json_upload_legacy_username()
response = self.request("participant.import", {"id": 1, "import": True})
self.assert_status_code(response, 200)

def test_reupload_with_structure_level(self) -> None:
import_data = {
"username": "test",
"default_password": "secret",
"is_active": "1",
"is_physical_person": "F",
"number": "strange number",
"structure_level": ["testlevel", "notfound"],
"vote_weight": "1.12",
"comment": "my comment",
"is_present": "0",
"groups": ["testgroup", "notfound_group1", "notfound_group2"],
"wrong": 15,
}
response = self.request(
"participant.json_upload",
{
"meeting_id": 1,
"data": [import_data.copy()],
},
)
self.assert_status_code(response, 200)
response = self.request(
"participant.import",
{"id": response.json["results"][0][0].get("id"), "import": True},
)
self.assert_status_code(response, 200)
response = self.request(
"participant.json_upload",
{
"meeting_id": 1,
"data": [import_data],
},
)
self.assert_status_code(response, 200)
response = self.request(
"participant.import",
{"id": response.json["results"][0][0].get("id"), "import": True},
)
self.assert_status_code(response, 200)

0 comments on commit 55032b0

Please sign in to comment.