mirror of
https://github.com/zulip/zulip.git
synced 2025-10-26 17:43:58 +00:00
org settings: Handle NEW_USER_BOT not being set.
If NEW_USER_BOT is not configured in organization, then disable setting for selecting stream for new user notification.
This commit is contained in:
@@ -588,6 +588,11 @@ function test_change_allow_subdomains(change_allow_subdomains) {
|
||||
assert.equal(stream_id, 75);
|
||||
return { name: 'some_stream' };
|
||||
};
|
||||
page_params.new_user_bot_configured = false;
|
||||
settings_org.render_signup_notifications_stream_ui(75);
|
||||
assert.equal(elem.text(), 'translated: Disabled');
|
||||
assert(elem.hasClass('text-warning'));
|
||||
page_params.new_user_bot_configured = true;
|
||||
settings_org.render_signup_notifications_stream_ui(75);
|
||||
assert.equal(elem.text(), '#some_stream');
|
||||
assert(!elem.hasClass('text-warning'));
|
||||
|
||||
@@ -50,6 +50,7 @@ function _setup_page() {
|
||||
realm_message_retention_days: page_params.realm_message_retention_days,
|
||||
realm_allow_edit_history: page_params.realm_allow_edit_history,
|
||||
language_list: page_params.language_list,
|
||||
new_user_bot_configured: page_params.new_user_bot_configured,
|
||||
realm_default_language: page_params.realm_default_language,
|
||||
realm_waiting_period_threshold: page_params.realm_waiting_period_threshold,
|
||||
realm_notifications_stream_id: page_params.realm_notifications_stream_id,
|
||||
|
||||
@@ -198,7 +198,7 @@ exports.render_signup_notifications_stream_ui = function (stream_id) {
|
||||
|
||||
var name = stream_data.maybe_get_stream_name(stream_id);
|
||||
|
||||
if (!name) {
|
||||
if (!name || !page_params.new_user_bot_configured) {
|
||||
elem.text(i18n.t("Disabled"));
|
||||
elem.addClass("text-warning");
|
||||
return;
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
{{t "New user notifications:" }}
|
||||
<span class="dropup actual-dropdown-menu" id="id_realm_signup_notifications_stream"
|
||||
name="realm_signup_notifications_stream" aria-labelledby="realm_signup_notifications_stream_label">
|
||||
<button class="button small rounded dropdown-toggle" data-toggle="dropdown">
|
||||
<button class="button small rounded dropdown-toggle" data-toggle="dropdown" {{#unless new_user_bot_configured }} disabled="disabled" {{/unless}}>
|
||||
<span id="realm_signup_notifications_stream_name"></span>
|
||||
<i class="fa fa-pencil"></i>
|
||||
</button>
|
||||
@@ -184,8 +184,13 @@
|
||||
</span>
|
||||
</label>
|
||||
{{#if is_admin }}
|
||||
<a class="signup-notifications-stream-disable">{{t "[Disable]" }}</a>
|
||||
{{#if new_user_bot_configured }}
|
||||
<a class="signup-notifications-stream-disable">{{t "[Disable]" }}</a>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
<i class="icon-vector-question-sign signup_notification_stream_tooltip" data-toggle="tooltip"
|
||||
{{#if new_user_bot_configured}}style="display:none" {{/if}}
|
||||
title="{{t 'You must configured new user bot before setting a stream.' }}"/>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
@@ -93,6 +93,7 @@ class HomeTest(ZulipTestCase):
|
||||
"narrow_stream",
|
||||
"needs_tutorial",
|
||||
"never_subscribed",
|
||||
"new_user_bot_configured",
|
||||
"night_mode",
|
||||
"password_min_guesses",
|
||||
"password_min_length",
|
||||
|
||||
@@ -216,6 +216,10 @@ class RealmTest(ZulipTestCase):
|
||||
|
||||
new_signup_notifications_stream_id = 4
|
||||
req = dict(signup_notifications_stream_id = ujson.dumps(new_signup_notifications_stream_id))
|
||||
with self.settings(NEW_USER_BOT=None):
|
||||
result = self.client_patch("/json/realm", req)
|
||||
self.assert_json_error(result, 'NEW_USER_BOT must configured first.')
|
||||
|
||||
result = self.client_patch('/json/realm', req)
|
||||
self.assert_json_success(result)
|
||||
realm = get_realm('zulip')
|
||||
|
||||
@@ -173,6 +173,7 @@ def home_real(request: HttpRequest) -> HttpResponse:
|
||||
# These end up in a global JavaScript Object named 'page_params'.
|
||||
page_params = dict(
|
||||
# Server settings.
|
||||
new_user_bot_configured = settings.NEW_USER_BOT is not None,
|
||||
development_environment = settings.DEVELOPMENT,
|
||||
debug_mode = settings.DEBUG,
|
||||
test_suite = settings.TEST_SUITE,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
from typing import Any, Dict, Optional, List, Text
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from django.conf import settings
|
||||
from zerver.decorator import require_realm_admin, to_non_negative_int, to_not_negative_int_or_none
|
||||
from zerver.lib.actions import (
|
||||
do_set_realm_message_editing,
|
||||
@@ -59,6 +59,8 @@ def update_realm(
|
||||
return json_error(_("Realm name is too long."))
|
||||
if authentication_methods is not None and True not in list(authentication_methods.values()):
|
||||
return json_error(_("At least one authentication method must be enabled."))
|
||||
if signup_notifications_stream_id is not None and settings.NEW_USER_BOT is None:
|
||||
return json_error(_("NEW_USER_BOT must configured first."))
|
||||
|
||||
# The user of `locals()` here is a bit of a code smell, but it's
|
||||
# restricted to the elements present in realm.property_types.
|
||||
|
||||
Reference in New Issue
Block a user