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:
YJDave
2017-12-20 22:28:49 +05:30
committed by showell
parent 2ca0fb4128
commit 15dd94035c
8 changed files with 23 additions and 4 deletions

View File

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

View File

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

View File

@@ -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,

View File

@@ -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.