models: Clean up CommonMessagePolicyEnum.

This is no longer used outside an old migration.
This commit is contained in:
Tim Abbott 2024-09-11 16:03:50 -07:00
parent 0cd51f2fea
commit cb53c60563
3 changed files with 11 additions and 12 deletions

View File

@ -2,6 +2,7 @@
import datetime import datetime
import uuid import uuid
from enum import IntEnum
import bitfield.models import bitfield.models
import django.contrib.auth.models import django.contrib.auth.models
@ -21,6 +22,14 @@ import zerver.models.realms
import zerver.models.streams import zerver.models.streams
class LegacyCommonMessagePolicyEnum(IntEnum):
MEMBERS_ONLY = 1
ADMINS_ONLY = 2
FULL_MEMBERS_ONLY = 3
MODERATORS_ONLY = 4
EVERYONE = 5
def get_fts_sql() -> str: def get_fts_sql() -> str:
if settings.POSTGRESQL_MISSING_DICTIONARIES: if settings.POSTGRESQL_MISSING_DICTIONARIES:
fts_sql = """ fts_sql = """
@ -729,7 +738,7 @@ class Migration(migrations.Migration):
( (
"delete_own_message_policy", "delete_own_message_policy",
models.PositiveSmallIntegerField( models.PositiveSmallIntegerField(
default=zerver.models.realms.CommonMessagePolicyEnum["EVERYONE"] default=LegacyCommonMessagePolicyEnum["EVERYONE"]
), ),
), ),
( (

View File

@ -106,14 +106,6 @@ class CommonPolicyEnum(IntEnum):
MODERATORS_ONLY = 4 MODERATORS_ONLY = 4
class CommonMessagePolicyEnum(IntEnum):
MEMBERS_ONLY = 1
ADMINS_ONLY = 2
FULL_MEMBERS_ONLY = 3
MODERATORS_ONLY = 4
EVERYONE = 5
class EditTopicPolicyEnum(IntEnum): class EditTopicPolicyEnum(IntEnum):
MEMBERS_ONLY = 1 MEMBERS_ONLY = 1
ADMINS_ONLY = 2 ADMINS_ONLY = 2
@ -270,8 +262,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
COMMON_POLICY_TYPES = [field.value for field in CommonPolicyEnum] COMMON_POLICY_TYPES = [field.value for field in CommonPolicyEnum]
COMMON_MESSAGE_POLICY_TYPES = [field.value for field in CommonMessagePolicyEnum]
INVITE_TO_REALM_POLICY_TYPES = [field.value for field in InviteToRealmPolicyEnum] INVITE_TO_REALM_POLICY_TYPES = [field.value for field in InviteToRealmPolicyEnum]
CREATE_WEB_PUBLIC_STREAM_POLICY_TYPES = [ CREATE_WEB_PUBLIC_STREAM_POLICY_TYPES = [

View File

@ -3497,7 +3497,7 @@ class RealmPropertyActionTest(BaseAction):
invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES, invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES,
move_messages_between_streams_policy=Realm.MOVE_MESSAGES_BETWEEN_STREAMS_POLICY_TYPES, move_messages_between_streams_policy=Realm.MOVE_MESSAGES_BETWEEN_STREAMS_POLICY_TYPES,
add_custom_emoji_policy=Realm.COMMON_POLICY_TYPES, add_custom_emoji_policy=Realm.COMMON_POLICY_TYPES,
edit_topic_policy=Realm.COMMON_MESSAGE_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],