mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
models: Use COMMON_POLICY_TYPES for user_group_edit_policy.
This commit adds moderators and full members options for user_group_edit_policy by using COMMON_POLICY_TYPES. Moderators do not require to be a member of user group in order to edit or remove the user group if they are allowed to do so according to user_group_edit_policy. But full members need to be a member of user group to edit or remove the user group.
This commit is contained in:
@@ -11,7 +11,11 @@ def access_user_group_by_id(user_group_id: int, user_profile: UserProfile) -> Us
|
||||
try:
|
||||
user_group = UserGroup.objects.get(id=user_group_id, realm=user_profile.realm)
|
||||
group_member_ids = get_user_group_members(user_group)
|
||||
if not user_profile.is_realm_admin and user_profile.id not in group_member_ids:
|
||||
if (
|
||||
not user_profile.is_realm_admin
|
||||
and not user_profile.is_moderator
|
||||
and user_profile.id not in group_member_ids
|
||||
):
|
||||
raise JsonableError(_("Insufficient permission"))
|
||||
except UserGroup.DoesNotExist:
|
||||
raise JsonableError(_("Invalid user group"))
|
||||
|
||||
Reference in New Issue
Block a user