Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
hjanott committed Nov 22, 2024
1 parent 42eb249 commit 371d408
Showing 1 changed file with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from openslides_backend.shared.base_service_provider import BaseServiceProvider
from openslides_backend.shared.exceptions import (
ActionException,
AnyPermission,
MissingPermission,
PermissionDenied,
)
Expand Down Expand Up @@ -266,7 +267,7 @@ def check_group_A(self, fields: list[str], instance: dict[str, Any]) -> None:
):
return

missing_permissions = dict()
missing_permissions: dict[AnyPermission, int | set[int]] = dict()
if self.instance_user_scope == UserScope.Organization:
if not (
self.permstore.user_committees.intersection(
Expand Down Expand Up @@ -294,15 +295,19 @@ def check_group_A(self, fields: list[str], instance: dict[str, Any]) -> None:
CommitteeManagementLevel.CAN_MANAGE: meeting["committee_id"],
self.permission: self.instance_user_scope_id,
}
if missing_permissions and not self.check_for_admin_in_all_meetings(instance.get("id", 0)):
missing_permissions.update({
Permissions.User.CAN_UPDATE: {
meeting_id
for meeting_ids in self.instance_committee_meeting_ids.values()
if meeting_ids is not None
for meeting_id in meeting_ids
if meeting_id is not None
},}
if missing_permissions and not self.check_for_admin_in_all_meetings(
instance.get("id", 0)
):
missing_permissions.update(
{
Permissions.User.CAN_UPDATE: {
meeting_id
for meeting_ids in self.instance_committee_meeting_ids.values()
if meeting_ids is not None
for meeting_id in meeting_ids
if meeting_id is not None
},
}
)
raise MissingPermission(missing_permissions)

Expand Down Expand Up @@ -377,7 +382,7 @@ def check_group_F(self, fields: list[str], instance: dict[str, Any]) -> None:
):
return

missing_permissions = dict()
missing_permissions: dict[AnyPermission, int | set[int]] = dict()
if (
self.instance_user_oml_permission
or self.instance_user_scope == UserScope.Organization
Expand Down Expand Up @@ -418,15 +423,19 @@ def check_group_F(self, fields: list[str], instance: dict[str, Any]) -> None:
CommitteeManagementLevel.CAN_MANAGE: meeting["committee_id"],
self.permission: self.instance_user_scope_id,
}
if missing_permissions and not self.check_for_admin_in_all_meetings(instance.get("id", 0)):
missing_permissions.update({
Permissions.User.CAN_UPDATE: {
meeting_id
for meeting_ids in self.instance_committee_meeting_ids.values()
if meeting_ids is not None
for meeting_id in meeting_ids
if meeting_id is not None
},}
if missing_permissions and not self.check_for_admin_in_all_meetings(
instance.get("id", 0)
):
missing_permissions.update(
{
Permissions.User.CAN_UPDATE: {
meeting_id
for meeting_ids in self.instance_committee_meeting_ids.values()
if meeting_ids is not None
for meeting_id in meeting_ids
if meeting_id is not None
},
}
)
raise MissingPermission(missing_permissions)

Expand Down

0 comments on commit 371d408

Please sign in to comment.