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.

settings: Remove `invite_to_realm_policy` setting.

Vector73de44eb6a1b2c
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index 9e02e6d9c1f..097c2be5de2 100644
--- a/api_docs/changelog.md
+++ b/api_docs/changelog.md
@@ -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
with permission to send email invitations for inviting other users to the
organization.
+* `PATCH /realm`, [`GET /events`](/api/get-events): Removed
+ `invite_to_realm_policy` property, as the permission to send email invitations
+ for inviting other users to the organization is now controlled by
+ `can_invite_users_group` setting.
**Feature level 320**
diff --git a/zerver/migrations/0001_squashed_0569.py b/zerver/migrations/0001_squashed_0569.py
index 3c323e9dbcf..f431a4c8762 100644
--- a/zerver/migrations/0001_squashed_0569.py
+++ b/zerver/migrations/0001_squashed_0569.py
@@ -39,6 +39,14 @@ class LegacyEditTopicPolicyEnum(IntEnum):
NOBODY = 6
+class LegacyInviteToRealmPolicyEnum(IntEnum):
+ MEMBERS_ONLY = 1
+ ADMINS_ONLY = 2
+ FULL_MEMBERS_ONLY = 3
+ MODERATORS_ONLY = 4
+ NOBODY = 6
+
+
def get_fts_sql() -> str:
if settings.POSTGRESQL_MISSING_DICTIONARIES:
fts_sql = """
@@ -757,7 +765,7 @@ class Migration(migrations.Migration):
(
"invite_to_realm_policy",
models.PositiveSmallIntegerField(
- default=zerver.models.realms.InviteToRealmPolicyEnum["MEMBERS_ONLY"]
+ default=LegacyInviteToRealmPolicyEnum["MEMBERS_ONLY"]
),
),
(
diff --git a/zerver/migrations/0628_remove_realm_invite_to_realm_policy.py b/zerver/migrations/0628_remove_realm_invite_to_realm_policy.py
new file mode 100644
index 00000000000..da073f92ffe
--- /dev/null
+++ b/zerver/migrations/0628_remove_realm_invite_to_realm_policy.py
@@ -0,0 +1,16 @@
+# Generated by Django 5.0.9 on 2024-11-16 08:51
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("zerver", "0627_alter_realm_can_invite_users_group"),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name="realm",
+ name="invite_to_realm_policy",
+ ),
+ ]
diff --git a/zerver/models/realms.py b/zerver/models/realms.py
index 9a32181c6f7..fc2a2fc1ac8 100644
--- a/zerver/models/realms.py
+++ b/zerver/models/realms.py
@@ -106,14 +106,6 @@ class CommonPolicyEnum(IntEnum):
MODERATORS_ONLY = 4
-class InviteToRealmPolicyEnum(IntEnum):
- MEMBERS_ONLY = 1
- ADMINS_ONLY = 2
- FULL_MEMBERS_ONLY = 3
- MODERATORS_ONLY = 4
- NOBODY = 6
-
-
class CreateWebPublicStreamPolicyEnum(IntEnum):
# We don't allow granting roles less than Moderator access to
# create web-public streams, since it's a sensitive feature that
@@ -253,8 +245,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
COMMON_POLICY_TYPES = [field.value for field in CommonPolicyEnum]
- INVITE_TO_REALM_POLICY_TYPES = [field.value for field in InviteToRealmPolicyEnum]
-
CREATE_WEB_PUBLIC_STREAM_POLICY_TYPES = [
field.value for field in CreateWebPublicStreamPolicyEnum
]
@@ -300,11 +290,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
"UserGroup", on_delete=models.RESTRICT, related_name="+"
)
- # Who in the organization is allowed to invite other users to organization.
- invite_to_realm_policy = models.PositiveSmallIntegerField(
- default=InviteToRealmPolicyEnum.MEMBERS_ONLY
- )
-
# UserGroup whose members are allowed to invite other users to organization.
can_invite_users_group = models.ForeignKey(
"UserGroup", on_delete=models.RESTRICT, related_name="+"
@@ -654,7 +639,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
inline_image_preview=bool,
inline_url_embed_preview=bool,
invite_required=bool,
- invite_to_realm_policy=int,
invite_to_stream_policy=int,
jitsi_server_url=(str, type(None)),
mandatory_topics=bool,
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 2f1f4c3d8d6..bbb6596513e 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -4753,14 +4753,6 @@ paths:
type: boolean
description: |
Whether an invitation is required to join this organization.
- invite_to_realm_policy:
- type: integer
- description: |
- The [policy](/api/roles-and-permissions#permission-levels)
- for which users can invite other users to join the organization.
-
- **Changes**: New in Zulip 4.0 (feature level 50) replacing the
- previous `invite_by_admins_only` boolean.
invite_to_stream_policy:
type: integer
description: |
@@ -16666,26 +16658,6 @@ paths:
Present if `realm` is present in `fetch_event_types`.
Whether an invitation is required to join this organization.
- realm_invite_to_realm_policy:
- type: integer
- description: |
- Present if `realm` is present in `fetch_event_types`.
-
- [Policy][permission-level] for [who can invite new
- users](/help/restrict-account-creation#change-who-can-send-invitations)
- to join the organization:
-
- - 1 = Members only
- - 2 = Administrators only
- - 3 = [Full members][calc-full-member] only
- - 4 = Moderators only
- - 6 = Nobody
-
- **Changes**: New in Zulip 4.0 (feature level 50) replacing the
- previous `realm_invite_by_admins_only` boolean.
-
- [permission-level]: /api/roles-and-permissions#permission-levels
- [calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
realm_create_multiuse_invite_group:
allOf:
- $ref: "#/components/schemas/GroupSettingValue"
diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py
index f6e56475e7f..03f194a52de 100644
--- a/zerver/tests/test_events.py
+++ b/zerver/tests/test_events.py
@@ -3741,7 +3741,6 @@ class RealmPropertyActionTest(BaseAction):
],
default_code_block_language=["python", "javascript"],
message_content_delete_limit_seconds=[1000, 1100, 1200],
- invite_to_realm_policy=Realm.INVITE_TO_REALM_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],
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index ff411a2d143..1bcc4628e78 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -173,7 +173,6 @@ class HomeTest(ZulipTestCase):
"realm_inline_image_preview",
"realm_inline_url_embed_preview",
"realm_invite_required",
- "realm_invite_to_realm_policy",
"realm_invite_to_stream_policy",
"realm_is_zephyr_mirror_realm",
"realm_jitsi_server_url",
diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py
index be603d476fd..c735a6d4dd5 100644
--- a/zerver/tests/test_realm.py
+++ b/zerver/tests/test_realm.py
@@ -62,7 +62,7 @@ from zerver.models import (
)
from zerver.models.groups import SystemGroups
from zerver.models.realm_audit_logs import AuditLogEventType
-from zerver.models.realms import CommonPolicyEnum, InviteToRealmPolicyEnum, get_realm
+from zerver.models.realms import CommonPolicyEnum, get_realm
from zerver.models.streams import get_stream
from zerver.models.users import get_system_bot, get_user_profile_by_id
@@ -848,7 +848,6 @@ class RealmTest(ZulipTestCase):
digest_weekday=10,
message_content_delete_limit_seconds=-10,
wildcard_mention_policy=10,
- invite_to_realm_policy=10,
message_content_edit_limit_seconds=0,
move_messages_within_stream_limit_seconds=0,
move_messages_between_streams_limit_seconds=0,
@@ -1695,7 +1694,6 @@ class RealmAPITest(ZulipTestCase):
Realm.GIPHY_RATING_OPTIONS["r"]["id"],
],
message_content_delete_limit_seconds=[1000, 1100, 1200],
- invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES,
message_content_edit_limit_seconds=[1000, 1100, 1200],
move_messages_within_stream_limit_seconds=[1000, 1100, 1200],
move_messages_between_streams_limit_seconds=[1000, 1100, 1200],
@@ -2291,10 +2289,6 @@ class RealmAPITest(ZulipTestCase):
def do_test_changing_settings_by_owners_only(self, setting_name: str) -> None:
bool_tests: list[bool] = [False, True]
test_values: dict[str, Any] = dict(
- invite_to_realm_policy=[
- InviteToRealmPolicyEnum.MEMBERS_ONLY,
- InviteToRealmPolicyEnum.ADMINS_ONLY,
- ],
waiting_period_threshold=[10, 20],
)
@@ -2320,7 +2314,6 @@ class RealmAPITest(ZulipTestCase):
self.assertEqual(getattr(realm, setting_name), vals[1])
def test_changing_user_joining_settings_require_owners(self) -> None:
- self.do_test_changing_settings_by_owners_only("invite_to_realm_policy")
self.do_test_changing_settings_by_owners_only("invite_required")
self.do_test_changing_settings_by_owners_only("emails_restricted_to_domains")
self.do_test_changing_settings_by_owners_only("disallow_disposable_email_addresses")
diff --git a/zerver/views/realm.py b/zerver/views/realm.py
index 1bb3debca01..65f6a34a88c 100644
--- a/zerver/views/realm.py
+++ b/zerver/views/realm.py
@@ -52,7 +52,6 @@ from zerver.models.realms import (
BotCreationPolicyEnum,
CommonPolicyEnum,
DigestWeekdayEnum,
- InviteToRealmPolicyEnum,
OrgTypeEnum,
WildcardMentionPolicyEnum,
)
@@ -99,7 +98,6 @@ def update_realm(
emails_restricted_to_domains: Json[bool] | None = None,
disallow_disposable_email_addresses: Json[bool] | None = None,
invite_required: Json[bool] | None = None,
- invite_to_realm_policy: Json[InviteToRealmPolicyEnum] | None = None,
create_multiuse_invite_group: Json[GroupSettingChangeRequest] | None = None,
require_unique_names: Json[bool] | None = None,
name_changes_disabled: Json[bool] | None = None,
@@ -220,8 +218,7 @@ def update_realm(
)
if (
- invite_to_realm_policy is not None
- or invite_required is not None
+ invite_required is not None
or create_multiuse_invite_group is not None
or can_create_groups is not None
or can_invite_users_group is not None