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.
This commit is contained in:
Sahil Batra 2021-07-29 13:27:58 +05:30 committed by Tim Abbott
parent f23bfbd462
commit b9e0575829
2 changed files with 5 additions and 0 deletions

View File

@ -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")

View File

@ -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()