diff --git a/frontend_tests/node_tests/templates.js b/frontend_tests/node_tests/templates.js
index 1831e4295c..2a549133cc 100644
--- a/frontend_tests/node_tests/templates.js
+++ b/frontend_tests/node_tests/templates.js
@@ -1006,6 +1006,7 @@ function render(template_name, args) {
enable_offline_push_notifications: true, enable_online_push_notifications: true,
enable_digest_emails: true,
default_desktop_notifications: true,
+ realm_name_in_notifications: true,
};
var page_params = $.extend(page_param_checkbox_options, {
full_name: "Alyssa P. Hacker", password_auth_enabled: true,
@@ -1018,7 +1019,8 @@ function render(template_name, args) {
"enable_sounds", "enable_offline_push_notifications",
"enable_online_push_notifications",
"enable_digest_emails",
- "default_desktop_notifications"];
+ "default_desktop_notifications",
+ "realm_name_in_notifications"];
// Render with all booleans set to true.
var html = render('settings_tab', {page_params: page_params});
diff --git a/static/js/notifications.js b/static/js/notifications.js
index 03f6f69e04..6cbdd15549 100644
--- a/static/js/notifications.js
+++ b/static/js/notifications.js
@@ -678,6 +678,8 @@ exports.handle_global_notification_updates = function (notification_name, settin
page_params.enable_digest_emails = setting;
} else if (notification_name === "pm_content_in_desktop_notifications") {
page_params.pm_content_in_desktop_notifications = setting;
+ } else if (notification_name === "realm_name_in_notifications") {
+ page_params.realm_name_in_notifications = setting;
}
};
diff --git a/static/js/settings_notifications.js b/static/js/settings_notifications.js
index 865f808433..e5854e68d1 100644
--- a/static/js/settings_notifications.js
+++ b/static/js/settings_notifications.js
@@ -13,6 +13,7 @@ var notification_settings = [
"enable_stream_push_notifications",
"enable_stream_sounds",
"pm_content_in_desktop_notifications",
+ "realm_name_in_notifications",
];
function maybe_bulk_update_stream_notification_setting(notification_checkbox,
@@ -36,7 +37,7 @@ exports.set_up = function () {
notify_settings_status.hide();
if (!page_params.realm_show_digest_email) {
- $("#other_notifications").hide();
+ $("#digest_container").hide();
}
_.each(notification_settings, function (setting) {
diff --git a/static/templates/settings/notification-settings.handlebars b/static/templates/settings/notification-settings.handlebars
index 7201bd4bac..ce6c59f5e7 100644
--- a/static/templates/settings/notification-settings.handlebars
+++ b/static/templates/settings/notification-settings.handlebars
@@ -153,9 +153,23 @@
{{t "Digest emails when I'm away" }}
- {{!-- If you add another control group here, make sure to change
- $("#other_notifications").hide(); in settings.js to
- $("#digest_container").hide();
+
+
+
+
+
+
+ {{!-- If we end up removing the last control group, make sure to change
+ $("#digest_container").hide(); in settings_notifications.js to
+ $("#other_notifications").hide();
--}}
diff --git a/templates/zerver/help/configure-email-digest-notifications.md b/templates/zerver/help/configure-email-digest-notifications.md
index ff0ad2f43a..403f98561d 100644
--- a/templates/zerver/help/configure-email-digest-notifications.md
+++ b/templates/zerver/help/configure-email-digest-notifications.md
@@ -7,7 +7,7 @@ conversations and new users, while you were away.
{!go-to-the.md!} [Notifications](/#settings/notifications)
{!settings.md!}
-2. Select the **Digest emails when I'm away** option under the
-**Other notifications I want** section.
+2. Select the **Send digest emails when I'm away** option under the
+**Other notification settings** section.
{!save-changes.md!} notification settings.
diff --git a/zerver/lib/notifications.py b/zerver/lib/notifications.py
index e4a62f5eac..705e03697f 100644
--- a/zerver/lib/notifications.py
+++ b/zerver/lib/notifications.py
@@ -297,6 +297,7 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile,
'message_count': message_count,
'mention': missed_messages[0].is_stream_message(),
'unsubscribe_link': unsubscribe_link,
+ 'realm_name_in_notifications': user_profile.realm_name_in_notifications,
})
# If this setting (email mirroring integration) is enabled, only then
diff --git a/zerver/lib/send_email.py b/zerver/lib/send_email.py
index 0cb1bc9701..1dab7e9c27 100644
--- a/zerver/lib/send_email.py
+++ b/zerver/lib/send_email.py
@@ -41,7 +41,6 @@ def build_email(template_prefix: str, to_user_id: Optional[int]=None,
context = {}
context.update({
- 'realm_name_in_notifications': False,
'support_email': FromAddress.SUPPORT,
'email_images_base_uri': settings.ROOT_DOMAIN_URI + '/static/images/emails',
'physical_address': settings.PHYSICAL_ADDRESS,
diff --git a/zerver/migrations/0138_userprofile_realm_name_in_notifications.py b/zerver/migrations/0138_userprofile_realm_name_in_notifications.py
new file mode 100644
index 0000000000..b4f9c4eae7
--- /dev/null
+++ b/zerver/migrations/0138_userprofile_realm_name_in_notifications.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.6 on 2018-01-21 08:47
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('zerver', '0137_realm_upload_quota_gb'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='userprofile',
+ name='realm_name_in_notifications',
+ field=models.BooleanField(default=False),
+ ),
+ ]
diff --git a/zerver/models.py b/zerver/models.py
index c3f59c578c..788ee9a2a4 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -561,6 +561,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin):
enable_online_push_notifications = models.BooleanField(default=False) # type: bool
enable_digest_emails = models.BooleanField(default=True) # type: bool
+ realm_name_in_notifications = models.BooleanField(default=False) # type: bool
# Old notification field superseded by existence of stream notification
# settings.
@@ -661,6 +662,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin):
enable_stream_push_notifications=bool,
enable_stream_sounds=bool,
pm_content_in_desktop_notifications=bool,
+ realm_name_in_notifications=bool,
)
class Meta:
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index 5c3334b7dc..4c2f6afa65 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -135,6 +135,7 @@ class HomeTest(ZulipTestCase):
"realm_message_retention_days",
"realm_name",
"realm_name_changes_disabled",
+ "realm_name_in_notifications",
"realm_non_active_users",
"realm_notifications_stream_id",
"realm_password_auth_enabled",
diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py
index 21ed56f973..2db995105d 100644
--- a/zerver/views/user_settings.py
+++ b/zerver/views/user_settings.py
@@ -169,8 +169,9 @@ def json_change_notify_settings(
enable_offline_push_notifications: Optional[bool]=REQ(validator=check_bool, default=None),
enable_online_push_notifications: Optional[bool]=REQ(validator=check_bool, default=None),
enable_digest_emails: Optional[bool]=REQ(validator=check_bool, default=None),
- pm_content_in_desktop_notifications: Optional[bool]=REQ(validator=check_bool, default=None)
-) -> HttpResponse:
+ pm_content_in_desktop_notifications: Optional[bool]=REQ(validator=check_bool, default=None),
+ realm_name_in_notifications: Optional[bool]=REQ(validator=check_bool, default=None)) \
+ -> HttpResponse:
result = {}
# Stream notification settings.