settings: Remove `edit_topic_policy` setting.

Removed `edit_topic_policy` property, as the permission
to move messages between topcis is now controlled by
`can_move_messages_between_topics_group` setting.
This commit is contained in:
Vector73 2024-10-27 22:04:34 +05:30 committed by Tim Abbott
parent ed5638ec3c
commit 1ba1408b01
13 changed files with 35 additions and 85 deletions

View File

@ -28,6 +28,10 @@ format used by the Zulip server that they are interacting with.
[group-setting value](/api/group-setting-values) describing the set of users [group-setting value](/api/group-setting-values) describing the set of users
with permission to move messages from one topic to another within a channel with permission to move messages from one topic to another within a channel
in the organization. in the organization.
* `PATCH /realm`, [`GET /events`](/api/get-events): Removed
`edit_topic_policy` property, as the permission to move messages between
topics in the organization is now controlled by
`can_move_messages_between_topics_group` setting.
**Feature level 315** **Feature level 315**

View File

@ -82,7 +82,6 @@ def do_set_realm_property(
# These settings have a different event format due to their history. # These settings have a different event format due to their history.
message_edit_settings = [ message_edit_settings = [
"allow_message_editing", "allow_message_editing",
"edit_topic_policy",
"message_content_edit_limit_seconds", "message_content_edit_limit_seconds",
] ]
if name in message_edit_settings: if name in message_edit_settings:

View File

@ -1039,12 +1039,6 @@ message_content_edit_limit_seconds_data = DictType(
] ]
) )
edit_topic_policy_data = DictType(
required_keys=[
("edit_topic_policy", int),
]
)
night_logo_data = DictType( night_logo_data = DictType(
required_keys=[ required_keys=[
("night_logo_url", str), ("night_logo_url", str),
@ -1096,7 +1090,6 @@ update_dict_data = UnionType(
[ [
allow_message_editing_data, allow_message_editing_data,
authentication_data, authentication_data,
edit_topic_policy_data,
icon_data, icon_data,
logo_data, logo_data,
message_content_edit_limit_seconds_data, message_content_edit_limit_seconds_data,
@ -1131,8 +1124,6 @@ def check_realm_update_dict(
sub_type = allow_message_editing_data sub_type = allow_message_editing_data
elif "message_content_edit_limit_seconds" in event["data"]: elif "message_content_edit_limit_seconds" in event["data"]:
sub_type = message_content_edit_limit_seconds_data sub_type = message_content_edit_limit_seconds_data
elif "edit_topic_policy" in event["data"]:
sub_type = edit_topic_policy_data
elif "authentication_methods" in event["data"]: elif "authentication_methods" in event["data"]:
sub_type = authentication_data sub_type = authentication_data
elif any( elif any(

View File

@ -96,7 +96,6 @@ from zerver.models.linkifiers import linkifiers_for_realm
from zerver.models.realm_emoji import get_all_custom_emoji_for_realm from zerver.models.realm_emoji import get_all_custom_emoji_for_realm
from zerver.models.realm_playgrounds import get_realm_playgrounds from zerver.models.realm_playgrounds import get_realm_playgrounds
from zerver.models.realms import ( from zerver.models.realms import (
EditTopicPolicyEnum,
get_corresponding_policy_value_for_group_setting, get_corresponding_policy_value_for_group_setting,
get_realm_domains, get_realm_domains,
get_realm_with_settings, get_realm_with_settings,
@ -332,9 +331,6 @@ def fetch_initial_state_data(
state["realm_allow_message_editing"] = ( state["realm_allow_message_editing"] = (
False if user_profile is None else realm.allow_message_editing False if user_profile is None else realm.allow_message_editing
) )
state["realm_edit_topic_policy"] = (
EditTopicPolicyEnum.ADMINS_ONLY if user_profile is None else realm.edit_topic_policy
)
# This setting determines whether to send presence and also # This setting determines whether to send presence and also
# whether to display of users list in the right sidebar; we # whether to display of users list in the right sidebar; we

View File

@ -30,6 +30,15 @@ class LegacyCommonMessagePolicyEnum(IntEnum):
EVERYONE = 5 EVERYONE = 5
class LegacyEditTopicPolicyEnum(IntEnum):
MEMBERS_ONLY = 1
ADMINS_ONLY = 2
FULL_MEMBERS_ONLY = 3
MODERATORS_ONLY = 4
EVERYONE = 5
NOBODY = 6
def get_fts_sql() -> str: def get_fts_sql() -> str:
if settings.POSTGRESQL_MISSING_DICTIONARIES: if settings.POSTGRESQL_MISSING_DICTIONARIES:
fts_sql = """ fts_sql = """
@ -743,9 +752,7 @@ class Migration(migrations.Migration):
), ),
( (
"edit_topic_policy", "edit_topic_policy",
models.PositiveSmallIntegerField( models.PositiveSmallIntegerField(default=LegacyEditTopicPolicyEnum["EVERYONE"]),
default=zerver.models.realms.EditTopicPolicyEnum["EVERYONE"]
),
), ),
( (
"invite_to_realm_policy", "invite_to_realm_policy",

View File

@ -0,0 +1,16 @@
# Generated by Django 5.0.9 on 2024-10-27 16:28
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("zerver", "0620_alter_realm_can_move_messages_between_topics_group"),
]
operations = [
migrations.RemoveField(
model_name="realm",
name="edit_topic_policy",
),
]

View File

@ -106,15 +106,6 @@ class CommonPolicyEnum(IntEnum):
MODERATORS_ONLY = 4 MODERATORS_ONLY = 4
class EditTopicPolicyEnum(IntEnum):
MEMBERS_ONLY = 1
ADMINS_ONLY = 2
FULL_MEMBERS_ONLY = 3
MODERATORS_ONLY = 4
EVERYONE = 5
NOBODY = 6
class InviteToRealmPolicyEnum(IntEnum): class InviteToRealmPolicyEnum(IntEnum):
MEMBERS_ONLY = 1 MEMBERS_ONLY = 1
ADMINS_ONLY = 2 ADMINS_ONLY = 2
@ -268,8 +259,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
field.value for field in CreateWebPublicStreamPolicyEnum field.value for field in CreateWebPublicStreamPolicyEnum
] ]
EDIT_TOPIC_POLICY_TYPES = [field.value for field in EditTopicPolicyEnum]
DEFAULT_MOVE_MESSAGE_LIMIT_SECONDS = 7 * SECONDS_PER_DAY DEFAULT_MOVE_MESSAGE_LIMIT_SECONDS = 7 * SECONDS_PER_DAY
move_messages_within_stream_limit_seconds = models.PositiveIntegerField( move_messages_within_stream_limit_seconds = models.PositiveIntegerField(
@ -311,9 +300,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
"UserGroup", on_delete=models.RESTRICT, related_name="+" "UserGroup", on_delete=models.RESTRICT, related_name="+"
) )
# Who in the organization is allowed to edit topics of any message.
edit_topic_policy = models.PositiveSmallIntegerField(default=EditTopicPolicyEnum.EVERYONE)
# Who in the organization is allowed to invite other users to organization. # Who in the organization is allowed to invite other users to organization.
invite_to_realm_policy = models.PositiveSmallIntegerField( invite_to_realm_policy = models.PositiveSmallIntegerField(
default=InviteToRealmPolicyEnum.MEMBERS_ONLY default=InviteToRealmPolicyEnum.MEMBERS_ONLY
@ -654,7 +640,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
digest_emails_enabled=bool, digest_emails_enabled=bool,
digest_weekday=int, digest_weekday=int,
disallow_disposable_email_addresses=bool, disallow_disposable_email_addresses=bool,
edit_topic_policy=int,
email_changes_disabled=bool, email_changes_disabled=bool,
emails_restricted_to_domains=bool, emails_restricted_to_domains=bool,
enable_guest_user_indicator=bool, enable_guest_user_indicator=bool,

View File

@ -817,7 +817,6 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings):
from zerver.models import Realm from zerver.models import Realm
if policy_name not in Realm.REALM_PERMISSION_GROUP_SETTINGS and policy_name not in [ if policy_name not in Realm.REALM_PERMISSION_GROUP_SETTINGS and policy_name not in [
"edit_topic_policy",
"invite_to_stream_policy", "invite_to_stream_policy",
"invite_to_realm_policy", "invite_to_realm_policy",
]: ]:

View File

@ -4357,7 +4357,11 @@ paths:
description: | description: |
An object containing the properties that have changed. An object containing the properties that have changed.
**Changes**: In Zulip 7.0 (feature level 183), the **Changes**: In Zulip 10.0 (feature level 316), `edit_topic_policy`
property was removed and replaced by `can_move_messages_between_topics_group`
realm setting.
In Zulip 7.0 (feature level 183), the
`community_topic_editing_limit_seconds` property was removed. `community_topic_editing_limit_seconds` property was removed.
It was documented as potentially returned as a changed property It was documented as potentially returned as a changed property
in this event, but in fact it was only ever returned in the in this event, but in fact it was only ever returned in the
@ -4633,27 +4637,6 @@ paths:
description: | description: |
Whether the organization disallows disposable email Whether the organization disallows disposable email
addresses. addresses.
edit_topic_policy:
type: integer
description: |
The [policy][permission-level] for which users can edit topics of any message.
- 1 = Members only
- 2 = Admins only
- 3 = [Full members][calc-full-member] only
- 4 = Moderators only
- 5 = Everyone
- 6 = Nobody
See [`PATCH /messages/{message_id}`](/api/update-message) for details and history
of how message editing permissions work.
**Changes**: Nobody added as an option in Zulip 7.0 (feature level 159).
New in Zulip 5.0 (feature level 75).
[permission-level]: /api/roles-and-permissions#permission-levels
[calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
email_changes_disabled: email_changes_disabled:
type: boolean type: boolean
description: | description: |
@ -16928,29 +16911,6 @@ paths:
history of how message editing permissions work. history of how message editing permissions work.
[config-message-editing]: /help/restrict-message-editing-and-deletion [config-message-editing]: /help/restrict-message-editing-and-deletion
realm_edit_topic_policy:
type: integer
description: |
Present if `realm` is present in `fetch_event_types`.
The [policy][permission-level] for which users can edit topics of any message.
- 1 = Members only
- 2 = Admins only
- 3 = [Full members][calc-full-member] only
- 4 = Moderators only
- 5 = Everyone
- 6 = Nobody
See [`PATCH /messages/{message_id}`](/api/update-message) for details and
history of how message editing permissions work.
**Changes**: Nobody added as an option in Zulip 7.0 (feature level 159).
New in Zulip 5.0 (feature level 75).
[permission-level]: /api/roles-and-permissions#permission-levels
[calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
realm_message_content_edit_limit_seconds: realm_message_content_edit_limit_seconds:
type: integer type: integer
nullable: true nullable: true

View File

@ -3743,7 +3743,6 @@ class RealmPropertyActionTest(BaseAction):
default_code_block_language=["python", "javascript"], default_code_block_language=["python", "javascript"],
message_content_delete_limit_seconds=[1000, 1100, 1200], message_content_delete_limit_seconds=[1000, 1100, 1200],
invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES, invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES,
edit_topic_policy=Realm.EDIT_TOPIC_POLICY_TYPES,
message_content_edit_limit_seconds=[1000, 1100, 1200, None], message_content_edit_limit_seconds=[1000, 1100, 1200, None],
move_messages_within_stream_limit_seconds=[1000, 1100, 1200], move_messages_within_stream_limit_seconds=[1000, 1100, 1200],
move_messages_between_streams_limit_seconds=[1000, 1100, 1200], move_messages_between_streams_limit_seconds=[1000, 1100, 1200],
@ -3804,7 +3803,6 @@ class RealmPropertyActionTest(BaseAction):
if name in [ if name in [
"allow_message_editing", "allow_message_editing",
"edit_topic_policy",
"message_content_edit_limit_seconds", "message_content_edit_limit_seconds",
]: ]:
check_realm_update_dict("events[0]", events[0]) check_realm_update_dict("events[0]", events[0])

View File

@ -156,7 +156,6 @@ class HomeTest(ZulipTestCase):
"realm_direct_message_permission_group", "realm_direct_message_permission_group",
"realm_disallow_disposable_email_addresses", "realm_disallow_disposable_email_addresses",
"realm_domains", "realm_domains",
"realm_edit_topic_policy",
"realm_email_auth_enabled", "realm_email_auth_enabled",
"realm_email_changes_disabled", "realm_email_changes_disabled",
"realm_emails_restricted_to_domains", "realm_emails_restricted_to_domains",

View File

@ -849,7 +849,6 @@ class RealmTest(ZulipTestCase):
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,
edit_topic_policy=10,
message_content_edit_limit_seconds=0, message_content_edit_limit_seconds=0,
move_messages_within_stream_limit_seconds=0, move_messages_within_stream_limit_seconds=0,
move_messages_between_streams_limit_seconds=0, move_messages_between_streams_limit_seconds=0,
@ -1697,7 +1696,6 @@ class RealmAPITest(ZulipTestCase):
], ],
message_content_delete_limit_seconds=[1000, 1100, 1200], message_content_delete_limit_seconds=[1000, 1100, 1200],
invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES, invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES,
edit_topic_policy=Realm.EDIT_TOPIC_POLICY_TYPES,
message_content_edit_limit_seconds=[1000, 1100, 1200], message_content_edit_limit_seconds=[1000, 1100, 1200],
move_messages_within_stream_limit_seconds=[1000, 1100, 1200], move_messages_within_stream_limit_seconds=[1000, 1100, 1200],
move_messages_between_streams_limit_seconds=[1000, 1100, 1200], move_messages_between_streams_limit_seconds=[1000, 1100, 1200],

View File

@ -52,7 +52,6 @@ from zerver.models.realms import (
BotCreationPolicyEnum, BotCreationPolicyEnum,
CommonPolicyEnum, CommonPolicyEnum,
DigestWeekdayEnum, DigestWeekdayEnum,
EditTopicPolicyEnum,
InviteToRealmPolicyEnum, InviteToRealmPolicyEnum,
OrgTypeEnum, OrgTypeEnum,
WildcardMentionPolicyEnum, WildcardMentionPolicyEnum,
@ -116,7 +115,6 @@ def update_realm(
ApiParamConfig("message_content_delete_limit_seconds"), ApiParamConfig("message_content_delete_limit_seconds"),
] = None, ] = None,
allow_message_editing: Json[bool] | None = None, allow_message_editing: Json[bool] | None = None,
edit_topic_policy: Json[EditTopicPolicyEnum] | None = None,
mandatory_topics: Json[bool] | None = None, mandatory_topics: Json[bool] | None = None,
message_content_edit_limit_seconds_raw: Annotated[ message_content_edit_limit_seconds_raw: Annotated[
Json[int | str] | None, ApiParamConfig("message_content_edit_limit_seconds") Json[int | str] | None, ApiParamConfig("message_content_edit_limit_seconds")