realm: Remove user_group_edit_policy from the backend.

Fixed #25929.
This commit is contained in:
Shubham Padia 2024-09-17 11:02:18 +00:00 committed by Tim Abbott
parent b7764eb6f0
commit 4d06626b6f
10 changed files with 23 additions and 42 deletions

View File

@ -30,6 +30,13 @@ format used by the Zulip server that they are interacting with.
[`GET /events`](/api/get-events): Added `can_manage_all_groups` [`GET /events`](/api/get-events): Added `can_manage_all_groups`
realm setting, which is a [group-setting value](/api/group-setting-values) realm setting, which is a [group-setting value](/api/group-setting-values)
describing the set of users with permission to manage all user groups. describing the set of users with permission to manage all user groups.
* `PATCH /realm`, [`GET /events`](/api/get-events): Removed
`user_group_edit_policy` property, as the permission to create user
groups is now controlled by `can_create_groups` setting and permission to
manage groups in now controlled by `can_manage_all_groups` setting.
* [`POST /register`](/api/register-queue): `user_group_edit_policy`
field is deprecated, having been replaced by `can_create_groups` for user
group creation and `can_manage_all_groups` for user group management.
**Feature level 298** **Feature level 298**

View File

@ -124,7 +124,6 @@ def set_realm_permissions_based_on_org_type(realm: Realm) -> None:
realm.invite_to_realm_policy = InviteToRealmPolicyEnum.ADMINS_ONLY realm.invite_to_realm_policy = InviteToRealmPolicyEnum.ADMINS_ONLY
# Don't allow members (students) to manage user groups or # Don't allow members (students) to manage user groups or
# stream subscriptions. # stream subscriptions.
realm.user_group_edit_policy = CommonPolicyEnum.MODERATORS_ONLY
realm.invite_to_stream_policy = CommonPolicyEnum.MODERATORS_ONLY realm.invite_to_stream_policy = CommonPolicyEnum.MODERATORS_ONLY
# Allow moderators (TAs?) to move topics between streams. # Allow moderators (TAs?) to move topics between streams.
realm.move_messages_between_streams_policy = ( realm.move_messages_between_streams_policy = (

View File

@ -0,0 +1,16 @@
# Generated by Django 5.0.8 on 2024-09-17 10:47
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("zerver", "0593_alter_realm_manage_all_groups"),
]
operations = [
migrations.RemoveField(
model_name="realm",
name="user_group_edit_policy",
),
]

View File

@ -359,8 +359,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
default=POLICY_MEMBERS_ONLY default=POLICY_MEMBERS_ONLY
) )
user_group_edit_policy = models.PositiveSmallIntegerField(default=CommonPolicyEnum.MEMBERS_ONLY)
# Global policy for who is allowed to use wildcard mentions in # Global policy for who is allowed to use wildcard mentions in
# streams with a large number of subscribers. Anyone can use # streams with a large number of subscribers. Anyone can use
# wildcard mentions in small streams regardless of this setting. # wildcard mentions in small streams regardless of this setting.
@ -680,7 +678,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
push_notifications_enabled=bool, push_notifications_enabled=bool,
require_unique_names=bool, require_unique_names=bool,
send_welcome_emails=bool, send_welcome_emails=bool,
user_group_edit_policy=int,
video_chat_provider=int, video_chat_provider=int,
waiting_period_threshold=int, waiting_period_threshold=int,
want_advertise_in_communities_directory=bool, want_advertise_in_communities_directory=bool,

View File

@ -801,7 +801,6 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings):
"invite_to_stream_policy", "invite_to_stream_policy",
"invite_to_realm_policy", "invite_to_realm_policy",
"move_messages_between_streams_policy", "move_messages_between_streams_policy",
"user_group_edit_policy",
]: ]:
raise AssertionError("Invalid policy") raise AssertionError("Invalid policy")

View File

@ -4779,20 +4779,6 @@ paths:
primarily relevant to clients containing UI for changing it. primarily relevant to clients containing UI for changing it.
**Changes**: New in Zulip 9.0 (feature level 242). **Changes**: New in Zulip 9.0 (feature level 242).
user_group_edit_policy:
type: integer
description: |
The organization's [policy][permission-level] for
[who can manage user groups][user-group-permissions].
- 1 = All members can create and edit user groups
- 2 = Only organization administrators can create and edit user groups
- 3 = Only [full members][calc-full-member] can create and edit user groups
- 4 = Only organization administrators and moderators can create and edit user groups
[user-group-permissions]: /help/user-groups#configure-who-can-create-and-manage-user-groups
[permission-level]: /api/roles-and-permissions#permission-levels
[calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
video_chat_provider: video_chat_provider:
type: integer type: integer
description: | description: |
@ -16609,22 +16595,6 @@ paths:
`private_message_policy` realm setting, which supported values of `private_message_policy` realm setting, which supported values of
1 (enabled) and 2 (disabled). 1 (enabled) and 2 (disabled).
- $ref: "#/components/schemas/GroupSettingValue" - $ref: "#/components/schemas/GroupSettingValue"
realm_user_group_edit_policy:
type: integer
description: |
Present if `realm` is present in `fetch_event_types`.
The organization's [policy][permission-level] for
[who can manage user groups][user-group-permissions].
- 1 = All members can create and edit user groups
- 2 = Only organization administrators can create and edit user groups
- 3 = Only [full members][calc-full-member] can create and edit user groups.
- 4 = Only organization administrators and moderators can create and edit user groups.
[user-group-permissions]: /help/user-groups#configure-who-can-create-and-manage-user-groups
[permission-level]: /api/roles-and-permissions#permission-levels
[calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
realm_default_code_block_language: realm_default_code_block_language:
type: string type: string
description: | description: |

View File

@ -3516,7 +3516,6 @@ class RealmPropertyActionTest(BaseAction):
name=["Zulip", "New Name"], name=["Zulip", "New Name"],
waiting_period_threshold=[1000, 2000], waiting_period_threshold=[1000, 2000],
invite_to_stream_policy=Realm.COMMON_POLICY_TYPES, invite_to_stream_policy=Realm.COMMON_POLICY_TYPES,
user_group_edit_policy=Realm.COMMON_POLICY_TYPES,
wildcard_mention_policy=Realm.WILDCARD_MENTION_POLICY_TYPES, wildcard_mention_policy=Realm.WILDCARD_MENTION_POLICY_TYPES,
bot_creation_policy=Realm.BOT_CREATION_POLICY_TYPES, bot_creation_policy=Realm.BOT_CREATION_POLICY_TYPES,
video_chat_provider=[ video_chat_provider=[

View File

@ -205,7 +205,6 @@ class HomeTest(ZulipTestCase):
"realm_upload_quota_mib", "realm_upload_quota_mib",
"realm_uri", "realm_uri",
"realm_url", "realm_url",
"realm_user_group_edit_policy",
"realm_user_groups", "realm_user_groups",
"realm_user_settings_defaults", "realm_user_settings_defaults",
"realm_users", "realm_users",

View File

@ -123,7 +123,6 @@ class RealmTest(ZulipTestCase):
realm.move_messages_between_streams_policy, realm.move_messages_between_streams_policy,
MoveMessagesBetweenStreamsPolicyEnum.MODERATORS_ONLY, MoveMessagesBetweenStreamsPolicyEnum.MODERATORS_ONLY,
) )
self.assertEqual(realm.user_group_edit_policy, CommonPolicyEnum.MODERATORS_ONLY)
self.assertEqual(realm.invite_to_stream_policy, CommonPolicyEnum.MODERATORS_ONLY) self.assertEqual(realm.invite_to_stream_policy, CommonPolicyEnum.MODERATORS_ONLY)
realm = get_realm("test_education_non_profit") realm = get_realm("test_education_non_profit")
moderators_group = NamedUserGroup.objects.get( moderators_group = NamedUserGroup.objects.get(
@ -148,7 +147,6 @@ class RealmTest(ZulipTestCase):
realm.move_messages_between_streams_policy, realm.move_messages_between_streams_policy,
MoveMessagesBetweenStreamsPolicyEnum.MODERATORS_ONLY, MoveMessagesBetweenStreamsPolicyEnum.MODERATORS_ONLY,
) )
self.assertEqual(realm.user_group_edit_policy, CommonPolicyEnum.MODERATORS_ONLY)
self.assertEqual(realm.invite_to_stream_policy, CommonPolicyEnum.MODERATORS_ONLY) self.assertEqual(realm.invite_to_stream_policy, CommonPolicyEnum.MODERATORS_ONLY)
realm = get_realm("test_education_for_profit") realm = get_realm("test_education_for_profit")
moderators_group = NamedUserGroup.objects.get( moderators_group = NamedUserGroup.objects.get(
@ -860,7 +858,6 @@ class RealmTest(ZulipTestCase):
giphy_rating=10, giphy_rating=10,
waiting_period_threshold=-10, waiting_period_threshold=-10,
digest_weekday=10, digest_weekday=10,
user_group_edit_policy=10,
message_content_delete_limit_seconds=-10, message_content_delete_limit_seconds=-10,
wildcard_mention_policy=10, wildcard_mention_policy=10,
invite_to_realm_policy=10, invite_to_realm_policy=10,
@ -1700,7 +1697,6 @@ class RealmAPITest(ZulipTestCase):
message_retention_days=[10, 20], message_retention_days=[10, 20],
name=["Zulip", "New Name"], name=["Zulip", "New Name"],
waiting_period_threshold=[10, 20], waiting_period_threshold=[10, 20],
user_group_edit_policy=Realm.COMMON_POLICY_TYPES,
invite_to_stream_policy=Realm.COMMON_POLICY_TYPES, invite_to_stream_policy=Realm.COMMON_POLICY_TYPES,
wildcard_mention_policy=Realm.WILDCARD_MENTION_POLICY_TYPES, wildcard_mention_policy=Realm.WILDCARD_MENTION_POLICY_TYPES,
bot_creation_policy=Realm.BOT_CREATION_POLICY_TYPES, bot_creation_policy=Realm.BOT_CREATION_POLICY_TYPES,

View File

@ -149,7 +149,6 @@ def update_realm(
can_manage_all_groups: Json[GroupSettingChangeRequest] | None = None, can_manage_all_groups: Json[GroupSettingChangeRequest] | None = None,
invite_to_stream_policy: Json[CommonPolicyEnum] | None = None, invite_to_stream_policy: Json[CommonPolicyEnum] | None = None,
move_messages_between_streams_policy: Json[MoveMessagesBetweenStreamsPolicyEnum] | None = None, move_messages_between_streams_policy: Json[MoveMessagesBetweenStreamsPolicyEnum] | None = None,
user_group_edit_policy: Json[CommonPolicyEnum] | None = None,
wildcard_mention_policy: Json[WildcardMentionPolicyEnum] | None = None, wildcard_mention_policy: Json[WildcardMentionPolicyEnum] | None = None,
video_chat_provider: Json[int] | None = None, video_chat_provider: Json[int] | None = None,
jitsi_server_url_raw: Annotated[ jitsi_server_url_raw: Annotated[