Skip to content

Commit

Permalink
Add equal_fields to motion/supporter_meeting_user_ids (#2128)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsangmeister authored Jan 19, 2024
1 parent b575697 commit 2bf802a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions global/meta/models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2353,6 +2353,7 @@ motion:
supporter_meeting_user_ids:
type: relation-list
to: meeting_user/supported_motion_ids
equal_fields: meeting_id
restriction_mode: C
poll_ids:
type: relation-list
Expand Down
2 changes: 1 addition & 1 deletion openslides_backend/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ class Motion(Model):
equal_fields="meeting_id",
)
supporter_meeting_user_ids = fields.RelationListField(
to={"meeting_user": "supported_motion_ids"}
to={"meeting_user": "supported_motion_ids"}, equal_fields="meeting_id"
)
poll_ids = fields.RelationListField(
to={"poll": "content_object_id"},
Expand Down
19 changes: 18 additions & 1 deletion tests/system/action/motion/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MotionUpdateActionTest(BaseActionTestCase):
def setUp(self) -> None:
super().setUp()
self.permission_test_models: Dict[str, Dict[str, Any]] = {
"meeting/1": {"meeting_user_ids": [1]},
"meeting/1": {"meeting_user_ids": [1], "is_active_in_organization_id": 1},
"motion/111": {
"meeting_id": 1,
"title": "title_srtgb123",
Expand Down Expand Up @@ -454,6 +454,23 @@ def test_reset_recommendation_extension(self) -> None:
"motion/2", {"referenced_in_motion_recommendation_extension_ids": []}
)

def test_set_supporter_other_meeting(self) -> None:
self.create_meeting(2)
self.permission_test_models["meeting_user/1"]["meeting_id"] = 2
self.set_models(self.permission_test_models)
response = self.request(
"motion.update",
{
"id": 111,
"supporter_meeting_user_ids": [1],
},
)
self.assert_status_code(response, 400)
self.assertIn(
"The following models do not belong to meeting 1: ['meeting_user/1']",
response.json["message"],
)

def test_update_no_permissions(self) -> None:
self.create_meeting()
self.user_id = self.create_user("user")
Expand Down

0 comments on commit 2bf802a

Please sign in to comment.