From 0634f75582e3c17b83eb6632c2814c2202ec7ab3 Mon Sep 17 00:00:00 2001 From: Shubham Padia Date: Thu, 3 Oct 2024 06:18:50 +0000 Subject: [PATCH] settings: Rearrange group settings in alphabetical order. --- web/src/settings_components.ts | 6 +-- web/src/settings_org.js | 2 +- web/src/state_data.ts | 2 +- zerver/lib/event_schema.py | 2 +- zerver/models/realms.py | 78 +++++++++++++++++----------------- zerver/models/users.py | 2 +- zerver/tests/test_home.py | 2 +- zerver/views/realm.py | 4 +- 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/web/src/settings_components.ts b/web/src/settings_components.ts index 62c8adaa2d..db75bfd134 100644 --- a/web/src/settings_components.ts +++ b/web/src/settings_components.ts @@ -483,12 +483,12 @@ const dropdown_widget_map = new Map([ ["realm_can_access_all_users_group", null], ["can_mention_group", null], ["realm_can_create_groups", null], - ["realm_can_manage_all_groups", null], ["realm_can_create_public_channel_group", null], ["realm_can_create_private_channel_group", null], ["realm_can_create_web_public_channel_group", null], ["realm_can_delete_any_message_group", null], ["realm_can_delete_own_message_group", null], + ["realm_can_manage_all_groups", null], ["realm_direct_message_initiator_group", null], ["realm_direct_message_permission_group", null], ]); @@ -808,12 +808,12 @@ export function check_realm_settings_property_changed(elem: HTMLElement): boolea case "realm_create_multiuse_invite_group": case "realm_can_access_all_users_group": case "realm_can_create_groups": - case "realm_can_manage_all_groups": case "realm_can_create_public_channel_group": case "realm_can_create_private_channel_group": case "realm_can_create_web_public_channel_group": case "realm_can_delete_any_message_group": case "realm_can_delete_own_message_group": + case "realm_can_manage_all_groups": case "realm_direct_message_initiator_group": case "realm_direct_message_permission_group": proposed_val = get_dropdown_list_widget_setting_value($elem); @@ -1046,10 +1046,10 @@ export function populate_data_for_realm_settings_request( const realm_group_settings_using_new_api_format = new Set([ "can_create_groups", - "can_manage_all_groups", "can_create_private_channel_group", "can_create_public_channel_group", "can_create_web_public_channel_group", + "can_manage_all_groups", "can_delete_any_message_group", "can_delete_own_message_group", "direct_message_initiator_group", diff --git a/web/src/settings_org.js b/web/src/settings_org.js index a5d9f8e34b..b2fa84cc83 100644 --- a/web/src/settings_org.js +++ b/web/src/settings_org.js @@ -511,12 +511,12 @@ export function discard_realm_property_element_changes(elem) { case "realm_direct_message_permission_group": case "realm_can_access_all_users_group": case "realm_can_create_groups": - case "realm_can_manage_all_groups": case "realm_can_create_public_channel_group": case "realm_can_create_private_channel_group": case "realm_can_create_web_public_channel_group": case "realm_can_delete_any_message_group": case "realm_can_delete_own_message_group": + case "realm_can_manage_all_groups": settings_components.set_dropdown_list_widget_setting_value( property_name, property_value, diff --git a/web/src/state_data.ts b/web/src/state_data.ts index 7c2d4ceac4..e5d2ea6e0f 100644 --- a/web/src/state_data.ts +++ b/web/src/state_data.ts @@ -286,12 +286,12 @@ const realm_schema = z.object({ realm_bot_domain: z.string(), realm_can_access_all_users_group: z.number(), realm_can_create_groups: z.number(), - realm_can_manage_all_groups: z.number(), realm_can_create_public_channel_group: z.number(), realm_can_create_private_channel_group: z.number(), realm_can_create_web_public_channel_group: z.number(), realm_can_delete_any_message_group: z.number(), realm_can_delete_own_message_group: z.number(), + realm_can_manage_all_groups: z.number(), realm_create_multiuse_invite_group: z.number(), realm_create_private_stream_policy: z.number(), realm_date_created: z.number(), diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.py index a59b3aa293..62e146532c 100644 --- a/zerver/lib/event_schema.py +++ b/zerver/lib/event_schema.py @@ -1075,12 +1075,12 @@ group_setting_update_data_type = DictType( ("create_multiuse_invite_group", int), ("can_access_all_users_group", int), ("can_create_groups", group_setting_type), - ("can_manage_all_groups", group_setting_type), ("can_create_public_channel_group", group_setting_type), ("can_create_private_channel_group", group_setting_type), ("can_create_web_public_channel_group", group_setting_type), ("can_delete_any_message_group", group_setting_type), ("can_delete_own_message_group", group_setting_type), + ("can_manage_all_groups", group_setting_type), ("direct_message_initiator_group", group_setting_type), ("direct_message_permission_group", group_setting_type), ], diff --git a/zerver/models/realms.py b/zerver/models/realms.py index 6ba3177d93..8870bd0349 100644 --- a/zerver/models/realms.py +++ b/zerver/models/realms.py @@ -704,6 +704,15 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub id_field_name="can_access_all_users_group_id", allowed_system_groups=[SystemGroups.EVERYONE, SystemGroups.MEMBERS], ), + can_create_groups=GroupPermissionSetting( + require_system_group=False, + allow_internet_group=False, + allow_owners_group=True, + allow_nobody_group=False, + allow_everyone_group=False, + default_group_name=SystemGroups.MEMBERS, + id_field_name="can_create_groups_id", + ), can_create_public_channel_group=GroupPermissionSetting( require_system_group=False, allow_internet_group=False, @@ -722,6 +731,21 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub default_group_name=SystemGroups.MEMBERS, id_field_name="can_create_private_channel_group_id", ), + can_create_web_public_channel_group=GroupPermissionSetting( + require_system_group=True, + allow_internet_group=False, + allow_owners_group=True, + allow_nobody_group=True, + allow_everyone_group=False, + default_group_name=SystemGroups.OWNERS, + id_field_name="can_create_web_public_channel_group_id", + allowed_system_groups=[ + SystemGroups.MODERATORS, + SystemGroups.ADMINISTRATORS, + SystemGroups.OWNERS, + SystemGroups.NOBODY, + ], + ), can_delete_any_message_group=GroupPermissionSetting( require_system_group=False, allow_internet_group=False, @@ -740,6 +764,15 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub default_group_name=SystemGroups.EVERYONE, id_field_name="can_delete_own_message_group_id", ), + can_manage_all_groups=GroupPermissionSetting( + require_system_group=False, + allow_internet_group=False, + allow_owners_group=True, + allow_nobody_group=False, + allow_everyone_group=False, + default_group_name=SystemGroups.OWNERS, + id_field_name="can_manage_all_groups_id", + ), direct_message_initiator_group=GroupPermissionSetting( require_system_group=False, allow_internet_group=False, @@ -758,51 +791,18 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub default_group_name=SystemGroups.EVERYONE, id_field_name="direct_message_permission_group_id", ), - can_create_web_public_channel_group=GroupPermissionSetting( - require_system_group=True, - allow_internet_group=False, - allow_owners_group=True, - allow_nobody_group=True, - allow_everyone_group=False, - default_group_name=SystemGroups.OWNERS, - id_field_name="can_create_web_public_channel_group_id", - allowed_system_groups=[ - SystemGroups.MODERATORS, - SystemGroups.ADMINISTRATORS, - SystemGroups.OWNERS, - SystemGroups.NOBODY, - ], - ), - can_create_groups=GroupPermissionSetting( - require_system_group=False, - allow_internet_group=False, - allow_owners_group=True, - allow_nobody_group=False, - allow_everyone_group=False, - default_group_name=SystemGroups.MEMBERS, - id_field_name="can_create_groups_id", - ), - can_manage_all_groups=GroupPermissionSetting( - require_system_group=False, - allow_internet_group=False, - allow_owners_group=True, - allow_nobody_group=False, - allow_everyone_group=False, - default_group_name=SystemGroups.OWNERS, - id_field_name="can_manage_all_groups_id", - ), ) REALM_PERMISSION_GROUP_SETTINGS_WITH_NEW_API_FORMAT = [ + "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", "direct_message_initiator_group", "direct_message_permission_group", - "can_create_groups", - "can_manage_all_groups", ] DIGEST_WEEKDAY_VALUES = [0, 1, 2, 3, 4, 5, 6] @@ -1166,6 +1166,8 @@ def get_realm_with_settings(realm_id: int) -> Realm: return Realm.objects.select_related( "can_access_all_users_group", "can_access_all_users_group__named_user_group", + "can_create_groups", + "can_create_groups__named_user_group", "can_create_public_channel_group", "can_create_public_channel_group__named_user_group", "can_create_private_channel_group", @@ -1176,14 +1178,12 @@ def get_realm_with_settings(realm_id: int) -> Realm: "can_delete_any_message_group__named_user_group", "can_delete_own_message_group", "can_delete_own_message_group__named_user_group", + "can_manage_all_groups", + "can_manage_all_groups__named_user_group", "direct_message_initiator_group", "direct_message_initiator_group__named_user_group", "direct_message_permission_group", "direct_message_permission_group__named_user_group", - "can_create_groups", - "can_create_groups__named_user_group", - "can_manage_all_groups", - "can_manage_all_groups__named_user_group", "new_stream_announcements_stream", "signup_announcements_stream", "zulip_update_announcements_stream", diff --git a/zerver/models/users.py b/zerver/models/users.py index 2748ddf87c..61b92e588b 100644 --- a/zerver/models/users.py +++ b/zerver/models/users.py @@ -788,12 +788,12 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings): if policy_name not in [ "add_custom_emoji_policy", "can_create_groups", - "can_manage_all_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", "create_multiuse_invite_group", "direct_message_initiator_group", "direct_message_permission_group", diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py index 89c7feebe3..78cae0bdf5 100644 --- a/zerver/tests/test_home.py +++ b/zerver/tests/test_home.py @@ -131,12 +131,12 @@ class HomeTest(ZulipTestCase): "realm_bots", "realm_can_access_all_users_group", "realm_can_create_groups", - "realm_can_manage_all_groups", "realm_can_create_private_channel_group", "realm_can_create_public_channel_group", "realm_can_create_web_public_channel_group", "realm_can_delete_any_message_group", "realm_can_delete_own_message_group", + "realm_can_manage_all_groups", "realm_create_multiuse_invite_group", "realm_create_private_stream_policy", "realm_create_public_stream_policy", diff --git a/zerver/views/realm.py b/zerver/views/realm.py index 01ea28dbe1..e7ae8f809b 100644 --- a/zerver/views/realm.py +++ b/zerver/views/realm.py @@ -140,13 +140,13 @@ def update_realm( digest_emails_enabled: Json[bool] | None = None, message_content_allowed_in_email_notifications: Json[bool] | None = None, bot_creation_policy: Json[BotCreationPolicyEnum] | None = None, + can_create_groups: Json[GroupSettingChangeRequest] | None = None, can_create_public_channel_group: Json[GroupSettingChangeRequest] | None = None, can_create_private_channel_group: Json[GroupSettingChangeRequest] | None = None, can_create_web_public_channel_group: Json[GroupSettingChangeRequest] | None = None, + can_manage_all_groups: Json[GroupSettingChangeRequest] | None = None, direct_message_initiator_group: Json[GroupSettingChangeRequest] | None = None, direct_message_permission_group: Json[GroupSettingChangeRequest] | None = None, - can_create_groups: Json[GroupSettingChangeRequest] | None = None, - can_manage_all_groups: Json[GroupSettingChangeRequest] | None = None, invite_to_stream_policy: Json[CommonPolicyEnum] | None = None, move_messages_between_streams_policy: Json[MoveMessagesBetweenStreamsPolicyEnum] | None = None, wildcard_mention_policy: Json[WildcardMentionPolicyEnum] | None = None,