mirror of https://github.com/zulip/zulip.git
user_groups: Rename has_user_group_access.
This commit renames has_user_group_access function to has_user_group_access_for_subgroup, since the function is only used to check access for using a group as subgroup.
This commit is contained in:
parent
0c89621fa6
commit
233775d257
|
@ -74,7 +74,7 @@ class LockedUserGroupContext:
|
|||
recursive_subgroups: list[NamedUserGroup]
|
||||
|
||||
|
||||
def has_user_group_access(
|
||||
def has_user_group_access_for_subgroup(
|
||||
user_group: NamedUserGroup,
|
||||
user_profile: UserProfile,
|
||||
*,
|
||||
|
@ -282,8 +282,8 @@ def lock_subgroups_with_respect_to_supergroup(
|
|||
# At this time, we only do a check on the realm ID of the subgroup and
|
||||
# whether the group is deactivated or not. Realm ID error would be caught
|
||||
# above and in case the user group is deactivated the error will be raised
|
||||
# in has_user_group_access itself, so there is no coverage here.
|
||||
if not has_user_group_access(subgroup, acting_user):
|
||||
# in has_user_group_access_for_subgroup itself, so there is no coverage here.
|
||||
if not has_user_group_access_for_subgroup(subgroup, acting_user):
|
||||
raise JsonableError(_("Insufficient permission")) # nocoverage
|
||||
|
||||
yield LockedUserGroupContext(
|
||||
|
@ -393,8 +393,8 @@ def update_or_create_user_group_for_setting(
|
|||
# At this time, we only do a check on the realm ID of the subgroup and
|
||||
# whether the group is deactivated or not. Realm ID error would be caught
|
||||
# above and in case the user group is deactivated the error will be raised
|
||||
# in has_user_group_access itself, so there is no coverage here.
|
||||
if not has_user_group_access(subgroup, user_profile):
|
||||
# in has_user_group_access_for_subgroup itself, so there is no coverage here.
|
||||
if not has_user_group_access_for_subgroup(subgroup, user_profile):
|
||||
raise JsonableError(_("Insufficient permission")) # nocoverage
|
||||
|
||||
user_group.direct_subgroups.set(group_ids_found)
|
||||
|
|
|
@ -43,7 +43,7 @@ from zerver.lib.user_groups import (
|
|||
get_role_based_system_groups_dict,
|
||||
get_subgroup_ids,
|
||||
get_user_group_member_ids,
|
||||
has_user_group_access,
|
||||
has_user_group_access_for_subgroup,
|
||||
is_any_user_in_group,
|
||||
is_user_in_group,
|
||||
user_groups_in_realm_serialized,
|
||||
|
@ -395,7 +395,7 @@ class UserGroupTestCase(ZulipTestCase):
|
|||
self.assertFalse(is_any_user_in_group(moderators_group, [hamlet, polonius]))
|
||||
self.assertFalse(is_any_user_in_group(moderators_group, [hamlet], direct_member_only=True))
|
||||
|
||||
def test_has_user_group_access_to_subgroup(self) -> None:
|
||||
def test_has_user_group_access_for_subgroup(self) -> None:
|
||||
iago = self.example_user("iago")
|
||||
zulip_realm = get_realm("zulip")
|
||||
zulip_group = check_add_user_group(zulip_realm, "zulip", [], acting_user=None)
|
||||
|
@ -406,9 +406,9 @@ class UserGroupTestCase(ZulipTestCase):
|
|||
lear_realm = get_realm("lear")
|
||||
lear_group = check_add_user_group(lear_realm, "test", [], acting_user=None)
|
||||
|
||||
self.assertFalse(has_user_group_access(lear_group, iago))
|
||||
self.assertTrue(has_user_group_access(zulip_group, iago))
|
||||
self.assertTrue(has_user_group_access(moderators_group, iago))
|
||||
self.assertFalse(has_user_group_access_for_subgroup(lear_group, iago))
|
||||
self.assertTrue(has_user_group_access_for_subgroup(zulip_group, iago))
|
||||
self.assertTrue(has_user_group_access_for_subgroup(moderators_group, iago))
|
||||
|
||||
|
||||
class UserGroupAPITestCase(UserGroupTestCase):
|
||||
|
|
Loading…
Reference in New Issue