From 7f2936a9859ef90c32488686f8728ed66a99cb47 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 15 Nov 2013 10:52:31 -0500 Subject: [PATCH] Allow enterprise customers to disable name changes (imported from commit 1f2039f3e88a4ec0cc48dba75f714563c1de4af8) --- static/js/settings.js | 6 +++++- zerver/views/__init__.py | 7 ++++++- zproject/local_settings_template.py | 4 ++++ zproject/settings.py | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/static/js/settings.js b/static/js/settings.js index e435b04977..1ab61ed30a 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -55,12 +55,16 @@ $(function () { avatar.build_user_avatar_widget(upload_avatar); - if (page_params.domain === "users.customer4.invalid") { + if (page_params.domain === "users.customer4.invalid" || + page_params.name_changes_disabled) { // At the request of the facilitators, CUSTOMER4 users // can't change their names, so don't show that as a settings // option. This is also disabled through the JSON UI. Once we // have the infrastructure for administrative policies, we can // handle this more gracefully. + // + // Additionally, if this install has disabled name changes, hide the + // container $("#name_change_container").hide(); } diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index 032c50811e..97b6471950 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -725,6 +725,7 @@ def home(request): muted_topics = register_ret['muted_topics'], show_admin = user_profile.show_admin, notify_for_streams_by_default = notify_for_streams_by_default(user_profile), + name_changes_disabled = settings.NAME_CHANGES_DISABLED, has_mobile_devices = num_push_devices_for_user(user_profile) > 0 )) @@ -1745,11 +1746,15 @@ def json_change_settings(request, user_profile, result = {} if user_profile.full_name != full_name and full_name.strip() != "": - if user_profile.realm.domain == "users.customer4.invalid": + if settings.NAME_CHANGES_DISABLED or \ + user_profile.realm.domain == "users.customer4.invalid": # At the request of the facilitators, CUSTOMER4 # students can't change their names. Failingly silently is # fine -- they can't do it through the UI, so they'd have # to be trying to break the rules. + # + # Additionally, if this install has disabled name changes altogether, + # ignore name changes as well pass else: new_full_name = full_name.strip() diff --git a/zproject/local_settings_template.py b/zproject/local_settings_template.py index dac22f184f..5e7ec8edef 100644 --- a/zproject/local_settings_template.py +++ b/zproject/local_settings_template.py @@ -71,6 +71,10 @@ INLINE_IMAGE_PREVIEW = True # setting up the appropriate integration. LOCAL_UPLOADS_DIR = "/home/zulip/uploads" +# Controls whether name changes are completely disabled for this installation +# This is useful in settings where you're syncing names from an integrated LDAP/Active Directory +NAME_CHANGES_DISABLED = False + ### TWITTER INTEGRATION # Zulip supports showing inline Tweet previews when a tweet is linked diff --git a/zproject/settings.py b/zproject/settings.py index 225c0629e1..7a7324bedd 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -246,6 +246,7 @@ DEFAULT_SETTINGS = {'TWITTER_CONSUMER_KEY': '', 'LOCAL_UPLOADS_DIR': None, 'DROPBOX_APP_KEY': '', 'ERROR_REPORTING': True, + 'NAME_CHANGES_DISABLED': False, 'DEPLOYMENT_ROLE_NAME': ADMIN_DOMAIN, # The following bots only exist in non-ENTERPRISE installs 'ERROR_BOT': None,