Skip to content

Commit a174d6b

Browse files
Magnus SchiederMagnus Schieder
authored andcommitted
Merge staging/4.2.29 into stable/4.2.x. Update 20260117
2 parents 022a823 + 3292f98 commit a174d6b

File tree

20 files changed

+360
-26
lines changed

20 files changed

+360
-26
lines changed

.github/workflows/pick-to-staging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
private_key: ${{ secrets.AUTOMATION_APP_PRIVATE_KEY }}
5454

5555
- name: Create or update PR
56-
uses: peter-evans/create-pull-request@v7
56+
uses: peter-evans/create-pull-request@v8
5757
with:
5858
token: ${{ steps.generate-token.outputs.token }}
5959
branch: apply/commit-${{ github.sha }}

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ coverage:
3434
pytest --cov --cov-report html
3535

3636
test-file:
37-
python -m debugpy --listen 0.0.0.0:5678 --wait-for-client /usr/local/bin/pytest $f
37+
# f= to pass the file name
38+
# k= to pass a test name
39+
# v=1 to run verbose test output
40+
# cap=1 to capture print to system out
41+
# cov=1 to run coverage report
42+
python -m debugpy --listen 0.0.0.0:5678 --wait-for-client /usr/local/bin/pytest $f $(if $(k),-k $k) $(if $(v),-vv) $(if $(cap),--capture=no) $(if $(cov),--cov --cov-report term-missing:skip-covered)
3843

3944
check-all: validate-models-yml check-models check-initial-data-json check-example-data-json check-permissions
4045

cli/generate_models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"string[]": "CharArrayField",
4646
"number[]": "NumberArrayField",
4747
"text": "TextField",
48+
"text[]": "TextArrayField",
4849
}
4950

5051
RELATION_FIELD_CLASSES = {

docs/actions/committee.create.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ Calculates `committee/all_parent_ids` from the `parent_id`.
2626
## Permissions
2727
The user needs to have the organization management level `can_manage_organization`.
2828
If a `parent_id` is given, CML `can_manage` for an ancestor committee will also suffice.
29+
If `organization/restrict_edit_forward_committees` is set, committee managers
30+
will not set `forward_to_committee_ids` or `receive_forwardings_from_committee_ids`.

docs/actions/committee.update.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
// Group C
2121
parent_id: Id;
22+
23+
// Group D
24+
manager_ids: Id[];
2225
}
2326
```
2427

@@ -30,5 +33,6 @@ Re-calculates `committee/all_parent_ids` from the new `parent_id` for this and a
3033

3134
## Permissions
3235
- Group A: The user needs the CML `can_manage` or the OML `can_manage_organization`
33-
- Group B: The user needs the OML `can_manage_organization` or the CML `can_manage` for all target committees that were added/removed from the list
36+
- Group B: The user needs the OML `can_manage_organization` or the CML `can_manage` for all target committees that were added/removed from the list and not `organization/restrict_edit_forward_committees` to be set.
3437
- Group C: The user needs the OML `can_manage_organization` or the CML `can_manage` for a committee that is an _ancestor_ of the intended child committee and either the intended parent committee or one of its ancestors. Only organization managers may set this field to `None`.
38+
- Group D: Like group A, except if `organization/restrict_editing_same_level_committee_admins` is true, the CML requirement will be further restricted to ancestor committee `can_manage`CMLs only. Users with no other admin permission than that of the edited committee will therefore not be allowed.

docs/actions/organization.update.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
users_email_body: text;
2020
require_duplicate_from: boolean;
2121
disable_forward_with_attachments: boolean;
22+
restrict_editing_same_level_committee_admins: boolean;
23+
restrict_edit_forward_committees: boolean;
2224

2325
// Group B
2426
enable_electronic_voting: boolean;

openslides_backend/action/actions/committee/committee_common_mixin.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
CommitteeManagementLevel,
1010
OrganizationManagementLevel,
1111
)
12-
from ....permissions.permission_helper import get_failing_committee_management_levels
12+
from ....permissions.permission_helper import (
13+
get_failing_committee_management_levels,
14+
has_organization_management_level,
15+
)
1316
from ....shared.exceptions import ActionException, MissingPermission
1417
from ....shared.patterns import fqid_from_collection_and_id
15-
from ....shared.util import ONE_ORGANIZATION_ID
18+
from ....shared.util import ONE_ORGANIZATION_FQID, ONE_ORGANIZATION_ID
1619

1720

1821
class CommitteeCommonCreateUpdateMixin(
@@ -31,9 +34,22 @@ def check_forwarding_fields(self, instance: dict[str, Any]) -> None:
3134
)
3235
else:
3336
committee = {}
37+
organization = self.datastore.get(
38+
ONE_ORGANIZATION_FQID, ["restrict_edit_forward_committees"]
39+
)
3440
field_difference: set[int] = set()
3541
for field in forwarding_fields:
3642
if field in instance:
43+
if organization.get(
44+
"restrict_edit_forward_committees"
45+
) and not has_organization_management_level(
46+
self.datastore,
47+
self.user_id,
48+
OrganizationManagementLevel.CAN_MANAGE_ORGANIZATION,
49+
):
50+
raise ActionException(
51+
"You are not allowed to set 'forward_to_committee_ids' and 'receive_forwardings_from_committee_ids', because it is restricted."
52+
)
3753
field_set = set(instance.get(field, []))
3854
field_difference.update(
3955
field_set.symmetric_difference(committee.get(field, []))

openslides_backend/action/actions/committee/update.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from ....services.datastore.commands import GetManyRequest
1313
from ....shared.exceptions import ActionException, MissingPermission
1414
from ....shared.patterns import fqid_from_collection_and_id
15+
from ....shared.util import ONE_ORGANIZATION_ID
1516
from ...generics.update import UpdateAction
1617
from ...util.default_schema import DefaultSchema
1718
from ...util.register import register_action
@@ -208,16 +209,42 @@ def check_permissions(self, instance: dict[str, Any]) -> None:
208209
}
209210
)
210211

212+
check_id: int = instance["id"]
213+
if "manager_ids" in instance:
214+
data = self.datastore.get_many(
215+
[
216+
GetManyRequest(
217+
"committee",
218+
[check_id],
219+
["parent_id"],
220+
),
221+
GetManyRequest(
222+
"organization",
223+
[ONE_ORGANIZATION_ID],
224+
["restrict_editing_same_level_committee_admins"],
225+
),
226+
],
227+
lock_result=False,
228+
)
229+
if data["organization"][ONE_ORGANIZATION_ID].get(
230+
"restrict_editing_same_level_committee_admins"
231+
):
232+
if not (parent_id := data["committee"][check_id].get("parent_id", 0)):
233+
raise MissingPermission(
234+
OrganizationManagementLevel.CAN_MANAGE_ORGANIZATION
235+
)
236+
check_id = parent_id
237+
211238
if has_committee_management_level(
212239
self.datastore,
213240
self.user_id,
214-
instance["id"],
241+
check_id,
215242
):
216243
return
217244

218245
raise MissingPermission(
219246
{
220247
OrganizationManagementLevel.CAN_MANAGE_ORGANIZATION: 1,
221-
CommitteeManagementLevel.CAN_MANAGE: instance["id"],
248+
CommitteeManagementLevel.CAN_MANAGE: check_id,
222249
}
223250
)

openslides_backend/action/actions/organization/update.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class OrganizationUpdate(
3838
"users_email_body",
3939
"require_duplicate_from",
4040
"disable_forward_with_attachments",
41+
"restrict_editing_same_level_committee_admins",
42+
"restrict_edit_forward_committees",
4143
)
4244

4345
group_B_fields = (

0 commit comments

Comments
 (0)