openslides_backend/permissions/permission_helper.py
def has_committee_management_level(
    datastore: DatastoreService,
    user_id: int,
    expected_level: CommitteeManagementLevel,
    committee_id: int,
) -> bool:
    """Checks wether a user has the minimum necessary CommitteeManagementLevel"""
    if user_id > 0:
        cml_field = f"committee_${committee_id}_management_level"
        user = datastore.get(
            FullQualifiedId(Collection("user"), user_id),
            ["organization_management_level", cml_field],
        )
        if user.get("organization_management_level") in (
            OrganizationManagementLevel.SUPERADMIN,
            OrganizationManagementLevel.CAN_MANAGE_ORGANIZATION,
        ):
            return True
        return expected_level <= CommitteeManagementLevel(user.get(cml_field))
    return False
Checks wether a user has the minimum necessary CommitteeManagementLevel
Checks wether a user has the minimum necessary CommitteeManagementLevel
Checks wether a user has the minimum necessary CommitteeManagementLevel
def has_committee_management_level(
    datastore: DatastoreService,
    user_id: int,
    expected_level: CommitteeManagementLevel,
    committee_id: int,
) -> bool:
    if user_id > 0:
        cml_field = f"committee_${committee_id}_management_level"
        user = datastore.get(
            FullQualifiedId(Collection("user"), user_id),
            ["organization_management_level", cml_field],
        )
        if user.get("organization_management_level") in (
            OrganizationManagementLevel.SUPERADMIN,
            OrganizationManagementLevel.CAN_MANAGE_ORGANIZATION,
        ):
            return True
        return expected_level <= CommitteeManagementLevel(user.get(cml_field))
    return False
def has_committee_management_level ( datastore : DatastoreService , user_id : int , expected_level : CommitteeManagementLevel , committee_id : int , ) -> bool : if user_id > 0 : cml_field = f"committee_${committee_id}_management_level" user = datastore . get ( FullQualifiedId ( Collection ( "user" ) , user_id ) , [ "organization_management_level" , cml_field ] , ) if user . get ( "organization_management_level" ) in ( OrganizationManagementLevel . SUPERADMIN , OrganizationManagementLevel . CAN_MANAGE_ORGANIZATION , ) : return True return expected_level <= CommitteeManagementLevel ( user . get ( cml_field ) ) return False
Checks wether a user has the minimum necessary CommitteeManagementLevel
Checks wether a user has the minimum necessary CommitteeManagementLevel
"""Checks wether a user has the minimum necessary CommitteeManagementLevel"""
datastore
DatastoreService
user_id
int
expected_level
CommitteeManagementLevel
committee_id
int