Skip to content

Commit

Permalink
Merge branch 'main' into 2741_boolean_attributes_as_string
Browse files Browse the repository at this point in the history
  • Loading branch information
hjanott authored Dec 3, 2024
2 parents 28b8eae + eb967ae commit c1a2255
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 5 deletions.
12 changes: 10 additions & 2 deletions openslides_backend/action/actions/meeting/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
CheckUniqueInContextMixin,
)

from ....i18n.translator import Translator
from ....i18n.translator import translate as _
from ....models.models import Meeting
from ....permissions.management_levels import (
CommitteeManagementLevel,
Expand Down Expand Up @@ -214,9 +216,15 @@ def update_instance(self, instance: dict[str, Any]) -> dict[str, Any]:
set_as_template = instance.pop("set_as_template", None)
db_meeting = self.datastore.get(
fqid_from_collection_and_id("meeting", instance["id"]),
["template_for_organization_id", "locked_from_inside", "admin_group_id"],
[
"template_for_organization_id",
"locked_from_inside",
"admin_group_id",
"language",
],
lock_result=False,
)
Translator.set_translation_language(db_meeting["language"])
lock_meeting = (
instance.get("locked_from_inside")
if instance.get("locked_from_inside") is not None
Expand Down Expand Up @@ -311,7 +319,7 @@ def update_instance(self, instance: dict[str, Any]) -> dict[str, Any]:
if instance.get("enable_anonymous") and not anonymous_group_id:
group_result = self.execute_other_action(
GroupCreate,
[{"name": "Public", "weight": 0, "meeting_id": instance["id"]}],
[{"name": _("Public"), "weight": 0, "meeting_id": instance["id"]}],
)
instance["anonymous_group_id"] = anonymous_group_id = cast(
list[dict[str, Any]], group_result
Expand Down
1 change: 1 addition & 0 deletions tests/system/action/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def create_meeting(self, base: int = 1) -> None:
"motions_default_workflow_id": base,
"committee_id": committee_id,
"is_active_in_organization_id": 1,
"language": "en",
},
f"group/{base}": {
"meeting_id": base,
Expand Down
10 changes: 7 additions & 3 deletions tests/system/action/meeting/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def test_group_ids(self) -> None:
"meeting/1": {
"motion_poll_default_group_ids": [1],
"is_active_in_organization_id": 1,
"language": "en",
},
"group/1": {"used_as_motion_poll_default_id": 1},
"group/2": {"name": "2", "used_as_motion_poll_default_id": None},
Expand All @@ -29,7 +30,8 @@ def test_group_ids(self) -> None:

def test_html_field_iframe(self) -> None:
self.create_model(
"meeting/1", {"welcome_text": "Hi", "is_active_in_organization_id": 1}
"meeting/1",
{"welcome_text": "Hi", "is_active_in_organization_id": 1, "language": "en"},
)
response = self.request(
"meeting.update", {"id": 1, "welcome_text": '<iframe allow="yes">'}
Expand All @@ -43,7 +45,8 @@ def test_html_field_iframe(self) -> None:

def test_html_field_iframe_attributes(self) -> None:
self.create_model(
"meeting/1", {"welcome_text": "Hi", "is_active_in_organization_id": 1}
"meeting/1",
{"welcome_text": "Hi", "is_active_in_organization_id": 1, "language": "en"},
)
response = self.request(
"meeting.update",
Expand All @@ -61,7 +64,8 @@ def test_html_field_iframe_attributes(self) -> None:

def test_html_field_script(self) -> None:
self.create_model(
"meeting/1", {"welcome_text": "Hi", "is_active_in_organization_id": 1}
"meeting/1",
{"welcome_text": "Hi", "is_active_in_organization_id": 1, "language": "en"},
)
response = self.request(
"meeting.update",
Expand Down
22 changes: 22 additions & 0 deletions tests/system/action/meeting/test_update.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Any

from openslides_backend.i18n.translator import Translator
from openslides_backend.i18n.translator import translate as _
from openslides_backend.models.models import Meeting
from openslides_backend.permissions.management_levels import OrganizationManagementLevel
from openslides_backend.permissions.permissions import Permissions
Expand All @@ -22,6 +24,7 @@ def setUp(self) -> None:
"admin_group_id": 1,
"projector_ids": [1],
"reference_projector_id": 1,
"language": "en",
**{field: [1] for field in Meeting.all_default_projectors()},
},
"projector/1": {
Expand Down Expand Up @@ -51,6 +54,7 @@ def basic_test(
"default_group_id": 1,
"projector_ids": [1],
"reference_projector_id": 1,
"language": "en",
**{field: [1] for field in Meeting.all_default_projectors()},
},
"projector/1": {
Expand Down Expand Up @@ -353,6 +357,7 @@ def test_update_only_one_time_one_removal_from_db(self) -> None:
"is_active_in_organization_id": 1,
"start_time": 160000,
"end_time": 170000,
"language": "en",
},
}
)
Expand Down Expand Up @@ -630,6 +635,7 @@ def test_update_with_user(self) -> None:
"committee_id": 1,
"group_ids": [11],
"admin_group_id": 11,
"language": "en",
},
"group/11": {"meeting_id": 3, "admin_group_for_meeting_id": 3},
"user/4": {},
Expand Down Expand Up @@ -684,6 +690,7 @@ def test_update_anonymous_if_disabled_in_orga(self) -> None:
"committee_id": 1,
"group_ids": [11],
"admin_group_id": 11,
"language": "en",
},
"group/11": {"meeting_id": 3, "admin_group_for_meeting_id": 3},
}
Expand Down Expand Up @@ -875,6 +882,7 @@ def test_update_external_id_self(self) -> None:
"committee_id": 1,
"external_id": external_id,
"is_active_in_organization_id": 1,
"language": "en",
},
}
)
Expand Down Expand Up @@ -1073,3 +1081,17 @@ def test_anonymous_in_topic_poll_default_group_ids(self) -> None:
self.base_anonymous_group_in_poll_default_field_test(
"topic_poll_default_group_ids"
)

def test_update_enable_anonymous_check_language(self) -> None:
self.test_models["meeting/1"]["language"] = "de"
self.set_models(self.test_models)
response = self.request(
"meeting.update",
{
"id": 1,
"enable_anonymous": True,
},
)
self.assert_status_code(response, 200)
Translator.set_translation_language("de")
self.assert_model_exists("group/2", {"name": _("Public")})
4 changes: 4 additions & 0 deletions tests/system/action/test_action_command_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,14 @@ def test_update_2_actions(self) -> None:
"committee_id": 1,
"welcome_title": "t",
"is_active_in_organization_id": 1,
"language": "en",
},
"meeting/2": {
"name": "name2",
"committee_id": 1,
"welcome_title": "t",
"is_active_in_organization_id": 1,
"language": "en",
},
"committee/1": {"name": "test_committee"},
}
Expand Down Expand Up @@ -216,12 +218,14 @@ def test_update_1_2_events(self) -> None:
"committee_id": 1,
"welcome_title": "t",
"is_active_in_organization_id": 1,
"language": "en",
},
"meeting/2": {
"name": "name2",
"committee_id": 1,
"welcome_title": "t",
"is_active_in_organization_id": 1,
"language": "en",
},
"committee/1": {"name": "test_committee"},
}
Expand Down

0 comments on commit c1a2255

Please sign in to comment.