Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

models: Clean up CommonMessagePolicyEnum.

Tim Abbottcb53c605637f
diff --git a/zerver/migrations/0001_squashed_0569.py b/zerver/migrations/0001_squashed_0569.py
index d4ca49080af..a09a1706d35 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 dfd530f089f..a2190f54223 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 ca4d9e0ed76..62afb2f7c40 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],