org-settings: Add setting to turn off welcome emails.

This adds an organization-level setting to provide an option to turn
off the welcome emails.

Fixes #8000.
This commit is contained in:
Aastha Gupta 2018-02-18 14:04:54 +05:30 committed by Tim Abbott
parent 71829f3373
commit d124597f4b
9 changed files with 45 additions and 2 deletions

View File

@ -59,6 +59,7 @@ function _setup_page() {
realm_icon_source: page_params.realm_icon_source,
realm_icon_url: page_params.realm_icon_url,
realm_mandatory_topics: page_params.realm_mandatory_topics,
realm_send_welcome_emails: page_params.realm_send_welcome_emails,
};
var admin_tab = templates.render('admin_tab', options);

View File

@ -70,6 +70,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
name: notifications.redraw_title,
name_changes_disabled: settings_org.toggle_name_change_display,
notifications_stream_id: noop,
send_welcome_emails: noop,
signup_notifications_stream_id: noop,
restricted_to_domain: noop,
waiting_period_threshold: noop,

View File

@ -281,6 +281,11 @@ function _set_up() {
type: 'text',
msg: i18n.t("Default language changed!"),
},
send_welcome_emails: {
type: 'bool',
checked_msg: i18n.t("Send emails to new users explaining how to use Zulip!"),
unchecked_msg: i18n.t("Don't send emails to new users explaining how to use Zulip!"),
},
allow_message_deleting: {
type: 'bool',
checked_msg: i18n.t("Users can delete their messages!"),

View File

@ -3,6 +3,7 @@
<div class="alert" id="admin-realm-notifications-stream-status"></div>
<div class="alert" id="admin-realm-signup-notifications-stream-status"></div>
<div class="alert" id="admin-realm-default-language-status"></div>
<div class="alert" id="admin-realm-send-welcome-emails-status"></div>
<div class="alert" id="admin-realm-inline-image-preview-status"></div>
<div class="alert" id="admin-realm-inline-url-embed-preview-status"></div>
@ -133,6 +134,16 @@
{{/each}}
</select>
</div>
<div class="input-group">
<label class="checkbox">
<input type="checkbox" id="id_realm_send_welcome_emails" name="realm_send_welcome_emails"
{{#if realm_send_welcome_emails}}checked="checked"{{/if}} />
<span></span>
</label>
<label for="id_realm_send_welcome_emails" id="id_realm_send_welcome_emails_label" class="inline-block">
{{t "Send emails introducing Zulip to new users" }}
</label>
</div>
{{#if is_admin }}
<div class="input-group organization-submission">
<button class="button rounded sea-green save-language-org-settings">

View File

@ -363,7 +363,8 @@ def process_new_human_user(user_profile: UserProfile,
PreregistrationUser.objects.filter(email__iexact=user_profile.email).update(status=0)
notify_new_user(user_profile)
enqueue_welcome_emails(user_profile)
if user_profile.realm.send_welcome_emails:
enqueue_welcome_emails(user_profile)
# We have an import loop here; it's intentional, because we want
# to keep all the onboarding code in zerver/lib/onboarding.py.

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2018-02-18 07:02
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('zerver', '0139_fill_last_message_id_in_subscription_logs'),
]
operations = [
migrations.AddField(
model_name='realm',
name='send_welcome_emails',
field=models.BooleanField(default=True),
),
]

View File

@ -150,6 +150,7 @@ class Realm(models.Model):
name_changes_disabled = models.BooleanField(default=False) # type: bool
email_changes_disabled = models.BooleanField(default=False) # type: bool
description = models.TextField(null=True) # type: Optional[Text]
send_welcome_emails = models.BooleanField(default=True) # type: bool
allow_message_deleting = models.BooleanField(default=False) # type: bool
allow_message_editing = models.BooleanField(default=True) # type: bool
@ -196,6 +197,7 @@ class Realm(models.Model):
name=Text,
name_changes_disabled=bool,
restricted_to_domain=bool,
send_welcome_emails=bool,
waiting_period_threshold=int,
) # type: Dict[str, Union[type, Tuple[type, ...]]]

View File

@ -141,6 +141,7 @@ class HomeTest(ZulipTestCase):
"realm_password_auth_enabled",
"realm_presence_disabled",
"realm_restricted_to_domain",
"realm_send_welcome_emails",
"realm_show_digest_email",
"realm_signup_notifications_stream_id",
"realm_uri",

View File

@ -49,7 +49,8 @@ def update_realm(
authentication_methods: Optional[Dict[Any, Any]]=REQ(validator=check_dict([]), default=None),
notifications_stream_id: Optional[int]=REQ(validator=check_int, default=None),
signup_notifications_stream_id: Optional[int]=REQ(validator=check_int, default=None),
message_retention_days: Optional[int]=REQ(converter=to_not_negative_int_or_none, default=None)
message_retention_days: Optional[int]=REQ(converter=to_not_negative_int_or_none, default=None),
send_welcome_emails: Optional[bool]=REQ(validator=check_bool, default=None)
) -> HttpResponse:
realm = user_profile.realm