From 68dc914b6e420240ed98091337ff0b2041fd4894 Mon Sep 17 00:00:00 2001 From: Vector73 Date: Thu, 17 Oct 2024 01:53:07 +0530 Subject: [PATCH] users: Refactor `has_permission` function. Refactored `has_permission` function to programmatically check if the `policy_name` is a group-based setting. --- zerver/models/users.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/zerver/models/users.py b/zerver/models/users.py index 9a1149cb31..b32e3efe4c 100644 --- a/zerver/models/users.py +++ b/zerver/models/users.py @@ -814,19 +814,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings): from zerver.lib.user_groups import user_has_permission_for_group_setting from zerver.models import Realm - if policy_name not in [ - "can_add_custom_emoji_group", - "can_create_groups", - "can_create_private_channel_group", - "can_create_public_channel_group", - "can_create_web_public_channel_group", - "can_delete_any_message_group", - "can_delete_own_message_group", - "can_manage_all_groups", - "can_move_messages_between_channels_group", - "create_multiuse_invite_group", - "direct_message_initiator_group", - "direct_message_permission_group", + if policy_name not in Realm.REALM_PERMISSION_GROUP_SETTINGS and policy_name not in [ "edit_topic_policy", "invite_to_stream_policy", "invite_to_realm_policy",