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

Fix meeting import spelling error #2816

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions docs/actions/meeting.import.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Import one meeting from a file. The file must only contain exactly one meeting.
- Imported usernames will be checked for uniqueness and adjusted in the case of collisions.
- All previously set user passwords will be replaced
- Genders will only be updated or imported if a new user needs to be created. Updated users will not have their genders updated.
- All references to other meetings and their models (like `motion/all_origin_ids` for example) will be removed


## Permissions
Expand Down
12 changes: 5 additions & 7 deletions openslides_backend/action/actions/meeting/import_.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,15 @@ def update_instance(self, instance: dict[str, Any]) -> dict[str, Any]:
mode="external",
repair=True,
fields_to_remove={
"meeting": [
"forwarded_motion_ids",
],
"motion": [
"origin_id",
"derived_motion_ids",
"all_origin_id",
"all_origin_ids",
"all_derived_motion_ids",
"origin_meeting_id",
],
"user": [
"password",
Expand All @@ -243,12 +247,6 @@ def update_instance(self, instance: dict[str, Any]) -> dict[str, Any]:
raise ActionException(str(ce))
self.allowed_collections = checker.allowed_collections

for entry in meeting_json.get("motion", {}).values():
if entry.get("all_origin_ids") or entry.get("all_derived_motion_ids"):
raise ActionException(
"Motion all_origin_ids and all_derived_motion_ids should be empty."
)

self.check_limit_of_meetings()
self.update_meeting_and_users(instance)

Expand Down
50 changes: 46 additions & 4 deletions tests/system/action/meeting/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,10 @@ def test_motion_all_derived_motion_ids(self) -> None:
)

def test_motion_all_origin_ids(self) -> None:
"""
This case is unrealistic, since usually you can't forward to the same meeting.
We should test it regardless, since json-files can be edited.
"""
request_data = self.create_request_data(
{
"motion": {
Expand Down Expand Up @@ -1494,10 +1498,48 @@ def test_motion_all_origin_ids(self) -> None:
request_data["meeting"]["meeting"]["1"]["list_of_speakers_ids"] = [1, 2]
request_data["meeting"]["motion_state"]["1"]["motion_ids"] = [1, 2]
response = self.request("meeting.import", request_data)
self.assert_status_code(response, 400)
assert (
"Motion all_origin_ids and all_derived_motion_ids should be empty."
in response.json["message"]
self.assert_status_code(response, 200)
motion = self.assert_model_exists("motion/2", {"meeting_id": 2})
assert motion.get("all_origin_ids") is None
motion = self.assert_model_exists("motion/3", {"meeting_id": 2})
assert motion.get("all_derived_motion_ids") is None

def test_foreign_motion_all_origin_ids(self) -> None:
request_data = self.create_request_data(
{
"motion": {
"2": self.get_motion_data(
2,
{
"all_origin_ids": [1],
"list_of_speakers_id": 2,
"state_id": 1,
"origin_meeting_id": 3,
},
),
},
"list_of_speakers": {
"2": {
"id": 2,
"meeting_id": 1,
"content_object_id": "motion/2",
"closed": False,
"sequential_number": 1,
"speaker_ids": [],
"projection_ids": [],
},
},
}
)
request_data["meeting"]["meeting"]["1"]["motion_ids"] = [2]
request_data["meeting"]["meeting"]["1"]["list_of_speakers_ids"] = [2]
request_data["meeting"]["motion_state"]["1"]["motion_ids"] = [2]
request_data["meeting"]["meeting"]["1"]["forwarded_motion_ids"] = [12, 13]
response = self.request("meeting.import", request_data)
self.assert_status_code(response, 200)
self.assert_model_exists(
"motion/2",
{"meeting_id": 2, "all_origin_ids": None, "origin_meeting_id": None},
)

def test_missing_required_field(self) -> None:
Expand Down