realm: Remove create_private_stream_policy setting.

This commit removes create_private_stream_policy setting as
we now use new group based setting.

The "/register" response includes realm_create_private_stream_policy
field to return a value representing superset of users who have the
permission to create private channels, as older clients still expect
this field.
This commit is contained in:
Sahil Batra 2024-06-17 21:12:08 +05:30 committed by Tim Abbott
parent e19524ba92
commit 6164a41864
10 changed files with 50 additions and 22 deletions

View File

@ -26,6 +26,14 @@ format used by the Zulip server that they are interacting with.
[`GET /events`](/api/get-events): Added `can_create_private_channel_group`
realm setting, which is a [group-setting value](/api/group-setting-values)
describing the set of users with permission to create private channels.
* `PATCH /realm`, [`GET /events`](/api/get-events): Removed
`create_private_stream_policy` property, as the permission to create private
channels is now controlled by `can_create_private_channel_group` setting.
* [`POST /register`](/api/register-queue): `realm_create_private_stream_policy`
field is deprecated, having been replaced by `can_create_private_channel_group`.
Notably, this backwards-compatible `realm_create_private_stream_policy` value
now contains the superset of the true value that best approximates the actual
permission setting.
**Feature level 265**

View File

@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
# Changes should be accompanied by documentation explaining what the
# new level means in api_docs/changelog.md, as well as "**Changes**"
# entries in the endpoint's documentation in `zulip.yaml`.
API_FEATURE_LEVEL = 265
API_FEATURE_LEVEL = 266
# Bump the minor PROVISION_VERSION to indicate that folks should provision
# only when going from an old version of the code to a newer version. Bump

View File

@ -294,6 +294,11 @@ def fetch_initial_state_data(
realm, "can_create_public_channel_group", Realm.COMMON_POLICY_TYPES
)
)
state["realm_create_private_stream_policy"] = (
get_corresponding_policy_value_for_group_setting(
realm, "can_create_private_channel_group", Realm.COMMON_POLICY_TYPES
)
)
# Most state is handled via the property_types framework;
# these manual entries are for those realm settings that don't
@ -1252,6 +1257,13 @@ def apply_event(
)
state["can_create_public_streams"] = user_profile.has_permission(key)
else:
state["realm_create_private_stream_policy"] = (
get_corresponding_policy_value_for_group_setting(
user_profile.realm,
"can_create_private_channel_group",
Realm.COMMON_POLICY_TYPES,
)
)
state["can_create_private_streams"] = user_profile.has_permission(key)
state["can_create_streams"] = (

View File

@ -0,0 +1,16 @@
# Generated by Django 5.0.6 on 2024-06-17 14:43
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("zerver", "0539_alter_realm_can_create_private_channel_group"),
]
operations = [
migrations.RemoveField(
model_name="realm",
name="create_private_stream_policy",
),
]

View File

@ -303,9 +303,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
)
# Who in the organization is allowed to create streams.
create_private_stream_policy = models.PositiveSmallIntegerField(
default=CommonPolicyEnum.MEMBERS_ONLY
)
create_web_public_stream_policy = models.PositiveSmallIntegerField(
default=CreateWebPublicStreamPolicyEnum.OWNERS_ONLY
)
@ -647,7 +644,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
allow_message_editing=bool,
avatar_changes_disabled=bool,
bot_creation_policy=int,
create_private_stream_policy=int,
create_web_public_stream_policy=int,
default_code_block_language=str,
default_language=str,

View File

@ -752,7 +752,6 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings):
"can_create_private_channel_group",
"can_create_public_channel_group",
"create_multiuse_invite_group",
"create_private_stream_policy",
"create_web_public_stream_policy",
"delete_own_message_policy",
"edit_topic_policy",

View File

@ -4259,14 +4259,6 @@ paths:
**Changes**: New in Zulip 9.0 (feature level 266). Previously
`realm_create_private_stream_policy` field used to control the
permission to create private channels.
create_private_stream_policy:
type: integer
description: |
The [policy](/api/roles-and-permissions#permission-levels)
for which users can create private channels in this organization.
**Changes**: Before Zulip 5.0 (feature level 102), permission to
create channels was controlled by the `create_stream_policy` setting.
create_web_public_stream_policy:
type: integer
description: |
@ -15309,17 +15301,28 @@ paths:
[calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
realm_create_private_stream_policy:
type: integer
deprecated: true
description: |
Present if `realm` is present in `fetch_event_types`.
The [policy][permission-level] for which users can create private channels
in this organization.
A deprecated representation of a superset of the users who
have permission to create private channels in the organization,
available for backwards-compatibility. Clients should use
`can_create_private_channel_group` instead.
It is an enum with the following possible values, corresponding
to roles/system groups:
- 1 = Members only
- 2 = Admins only
- 3 = [Full members][calc-full-member] only
- 4 = Admins and moderators only
**Changes**: Deprecated in Zulip 9.0 (feature level 266) and
replaced by `realm_can_create_private_channel_group`, which
supports finer resolution of configurations, resulting in this
property being inaccurate following that transition.
**Changes**: Before Zulip 5.0 (feature level 102), permission to
create channels was controlled by the `realm_create_stream_policy` setting.

View File

@ -3399,7 +3399,6 @@ class RealmPropertyActionTest(BaseAction):
message_retention_days=[10, 20],
name=["Zulip", "New Name"],
waiting_period_threshold=[1000, 2000],
create_private_stream_policy=Realm.COMMON_POLICY_TYPES,
create_web_public_stream_policy=Realm.CREATE_WEB_PUBLIC_STREAM_POLICY_TYPES,
invite_to_stream_policy=Realm.COMMON_POLICY_TYPES,
private_message_policy=Realm.PRIVATE_MESSAGE_POLICY_TYPES,

View File

@ -111,7 +111,6 @@ class RealmTest(ZulipTestCase):
)
self.assertEqual(realm.can_create_public_channel_group_id, admins_group.id)
self.assertEqual(realm.create_private_stream_policy, CommonPolicyEnum.MEMBERS_ONLY)
self.assertEqual(realm.invite_to_realm_policy, InviteToRealmPolicyEnum.ADMINS_ONLY)
self.assertEqual(
realm.move_messages_between_streams_policy,
@ -132,7 +131,6 @@ class RealmTest(ZulipTestCase):
)
self.assertEqual(realm.can_create_public_channel_group_id, admins_group.id)
self.assertEqual(realm.create_private_stream_policy, CommonPolicyEnum.MEMBERS_ONLY)
self.assertEqual(realm.invite_to_realm_policy, InviteToRealmPolicyEnum.ADMINS_ONLY)
self.assertEqual(
realm.move_messages_between_streams_policy,
@ -761,7 +759,6 @@ class RealmTest(ZulipTestCase):
invalid_values = dict(
bot_creation_policy=10,
create_private_stream_policy=10,
create_web_public_stream_policy=10,
invite_to_stream_policy=10,
message_retention_days=10,
@ -1480,7 +1477,6 @@ class RealmAPITest(ZulipTestCase):
message_retention_days=[10, 20],
name=["Zulip", "New Name"],
waiting_period_threshold=[10, 20],
create_private_stream_policy=Realm.COMMON_POLICY_TYPES,
create_web_public_stream_policy=Realm.CREATE_WEB_PUBLIC_STREAM_POLICY_TYPES,
user_group_edit_policy=Realm.COMMON_POLICY_TYPES,
private_message_policy=Realm.PRIVATE_MESSAGE_POLICY_TYPES,

View File

@ -149,7 +149,6 @@ def update_realm(
bot_creation_policy: Optional[Json[BotCreationPolicyEnum]] = None,
can_create_public_channel_group: Optional[Json[GroupSettingChangeRequest]] = None,
can_create_private_channel_group: Optional[Json[GroupSettingChangeRequest]] = None,
create_private_stream_policy: Optional[Json[CommonPolicyEnum]] = None,
create_web_public_stream_policy: Optional[Json[CreateWebPublicStreamPolicyEnum]] = None,
invite_to_stream_policy: Optional[Json[CommonPolicyEnum]] = None,
move_messages_between_streams_policy: Optional[