From b9e0575829f8f7a5a76953b95e6645bfee91c44e Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Thu, 29 Jul 2021 13:27:58 +0530 Subject: [PATCH] realm: Allow only owners to change waiting_period_threshold setting. We allow only owners to change the waiting period setting to become full member. This commit contains only backend changes, frontend changes will be done separately. --- zerver/tests/test_realm.py | 2 ++ zerver/views/realm.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py index dc32066c2a..9393d01a71 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 83565a4221..8c9660b819 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()