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.

realm: Allow only owners to change waiting_period_threshold setting.

Sahil Batrab9e0575829f8
diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py
index dc32066c2a2..9393d01a710 100644
--- a/zerver/tests/test_realm.py
+++ b/zerver/tests/test_realm.py
@@ -1376,6 +1376,7 @@ class RealmAPITest(ZulipTestCase):
bool_tests: List[bool] = [False, True]
test_values: Dict[str, Any] = dict(
invite_to_realm_policy=[Realm.POLICY_MEMBERS_ONLY, Realm.POLICY_ADMINS_ONLY],
+ waiting_period_threshold=[10, 20],
)
vals = test_values.get(setting_name)
@@ -1404,6 +1405,7 @@ class RealmAPITest(ZulipTestCase):
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")
+ self.do_test_changing_settings_by_owners_only("waiting_period_threshold")
def test_enable_spectator_access_for_limited_plan_realms(self) -> None:
self.login("iago")
diff --git a/zerver/views/realm.py b/zerver/views/realm.py
index 83565a42218..8c9660b819c 100644
--- a/zerver/views/realm.py
+++ b/zerver/views/realm.py
@@ -187,6 +187,9 @@ def update_realm(
) and not user_profile.is_realm_owner:
raise OrganizationOwnerRequired()
+ if waiting_period_threshold is not None and not user_profile.is_realm_owner:
+ raise OrganizationOwnerRequired()
+
if enable_spectator_access:
realm.ensure_not_on_limited_plan()