mirror of https://github.com/zulip/zulip.git
setting: Allow only owners to change "Who can invite users" setting.
This commit is contained in:
parent
ca0bb5b9d8
commit
c7e756f984
|
@ -45,6 +45,7 @@ export function maybe_disable_widgets() {
|
||||||
if (page_params.is_admin) {
|
if (page_params.is_admin) {
|
||||||
$("#deactivate_realm_button").prop("disabled", true);
|
$("#deactivate_realm_button").prop("disabled", true);
|
||||||
$("#org-message-retention").find("input, select").prop("disabled", true);
|
$("#org-message-retention").find("input, select").prop("disabled", true);
|
||||||
|
$("#id_realm_invite_to_realm_policy").prop("disabled", true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="m-10 inline-block organization-permissions-parent">
|
<div class="m-10 inline-block organization-permissions-parent">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label for="realm_invite_to_realm_policy" class="dropdown-title">{{t "Who can invite users to this organization" }}</label>
|
<label for="realm_invite_to_realm_policy" class="dropdown-title">{{t "Who can invite users to this organization" }}
|
||||||
|
<i class="fa fa-info-circle settings-info-icon realm_message_retention_tooltip tippy-zulip-tooltip" aria-hidden="true" data-tippy-content="{{t 'Only owners can change this setting.' }}"></i>
|
||||||
|
</label>
|
||||||
<select name="realm_invite_to_realm_policy" id="id_realm_invite_to_realm_policy" class="prop-element" data-setting-widget-type="number">
|
<select name="realm_invite_to_realm_policy" id="id_realm_invite_to_realm_policy" class="prop-element" data-setting-widget-type="number">
|
||||||
{{> dropdown_options_widget option_values=invite_to_realm_policy_values}}
|
{{> dropdown_options_widget option_values=invite_to_realm_policy_values}}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -868,6 +868,18 @@ class RealmAPITest(ZulipTestCase):
|
||||||
self.assertEqual(realm.allow_message_deleting, True)
|
self.assertEqual(realm.allow_message_deleting, True)
|
||||||
self.assertEqual(realm.message_content_delete_limit_seconds, 600)
|
self.assertEqual(realm.message_content_delete_limit_seconds, 600)
|
||||||
|
|
||||||
|
def test_change_invite_to_realm_policy_by_owners_only(self) -> None:
|
||||||
|
self.login("iago")
|
||||||
|
req = {"invite_to_realm_policy": Realm.POLICY_ADMINS_ONLY}
|
||||||
|
result = self.client_patch("/json/realm", req)
|
||||||
|
self.assert_json_error(result, "Must be an organization owner")
|
||||||
|
|
||||||
|
self.login("desdemona")
|
||||||
|
result = self.client_patch("/json/realm", req)
|
||||||
|
self.assert_json_success(result)
|
||||||
|
realm = get_realm("zulip")
|
||||||
|
self.assertEqual(realm.invite_to_realm_policy, Realm.POLICY_ADMINS_ONLY)
|
||||||
|
|
||||||
|
|
||||||
class ScrubRealmTest(ZulipTestCase):
|
class ScrubRealmTest(ZulipTestCase):
|
||||||
def test_scrub_realm(self) -> None:
|
def test_scrub_realm(self) -> None:
|
||||||
|
|
|
@ -150,6 +150,9 @@ def update_realm(
|
||||||
message_retention_days_raw, Realm.MESSAGE_RETENTION_SPECIAL_VALUES_MAP
|
message_retention_days_raw, Realm.MESSAGE_RETENTION_SPECIAL_VALUES_MAP
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if invite_to_realm_policy is not None and not user_profile.is_realm_owner:
|
||||||
|
raise OrganizationOwnerRequired()
|
||||||
|
|
||||||
# The user of `locals()` here is a bit of a code smell, but it's
|
# The user of `locals()` here is a bit of a code smell, but it's
|
||||||
# restricted to the elements present in realm.property_types.
|
# restricted to the elements present in realm.property_types.
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue