From cb53c605637fbd2ca33830a9c54455794b0312cd Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 11 Sep 2024 16:03:50 -0700 Subject: [PATCH] models: Clean up CommonMessagePolicyEnum. This is no longer used outside an old migration. --- zerver/migrations/0001_squashed_0569.py | 11 ++++++++++- zerver/models/realms.py | 10 ---------- zerver/tests/test_events.py | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/zerver/migrations/0001_squashed_0569.py b/zerver/migrations/0001_squashed_0569.py index d4ca49080a..a09a1706d3 100644 --- a/zerver/migrations/0001_squashed_0569.py +++ b/zerver/migrations/0001_squashed_0569.py @@ -2,6 +2,7 @@ import datetime import uuid +from enum import IntEnum import bitfield.models import django.contrib.auth.models @@ -21,6 +22,14 @@ import zerver.models.realms 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: if settings.POSTGRESQL_MISSING_DICTIONARIES: fts_sql = """ @@ -729,7 +738,7 @@ class Migration(migrations.Migration): ( "delete_own_message_policy", models.PositiveSmallIntegerField( - default=zerver.models.realms.CommonMessagePolicyEnum["EVERYONE"] + default=LegacyCommonMessagePolicyEnum["EVERYONE"] ), ), ( diff --git a/zerver/models/realms.py b/zerver/models/realms.py index dfd530f089..a2190f5422 100644 --- a/zerver/models/realms.py +++ b/zerver/models/realms.py @@ -106,14 +106,6 @@ class CommonPolicyEnum(IntEnum): MODERATORS_ONLY = 4 -class CommonMessagePolicyEnum(IntEnum): - MEMBERS_ONLY = 1 - ADMINS_ONLY = 2 - FULL_MEMBERS_ONLY = 3 - MODERATORS_ONLY = 4 - EVERYONE = 5 - - class EditTopicPolicyEnum(IntEnum): MEMBERS_ONLY = 1 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_MESSAGE_POLICY_TYPES = [field.value for field in CommonMessagePolicyEnum] - INVITE_TO_REALM_POLICY_TYPES = [field.value for field in InviteToRealmPolicyEnum] CREATE_WEB_PUBLIC_STREAM_POLICY_TYPES = [ diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index ca4d9e0ed7..62afb2f7c4 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -3497,7 +3497,7 @@ class RealmPropertyActionTest(BaseAction): invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES, move_messages_between_streams_policy=Realm.MOVE_MESSAGES_BETWEEN_STREAMS_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], move_messages_within_stream_limit_seconds=[1000, 1100, 1200], move_messages_between_streams_limit_seconds=[1000, 1100, 1200],