mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 02:48:00 +00:00
Factor out the check for whether name changes are disabled
(imported from commit 56ddd9cf53ec49e2e096abe82ed44f758912272e)
This commit is contained in:
@@ -444,16 +444,7 @@ exports.setup_page = function () {
|
|||||||
|
|
||||||
avatar.build_user_avatar_widget(upload_avatar);
|
avatar.build_user_avatar_widget(upload_avatar);
|
||||||
|
|
||||||
if (page_params.domain === "users.customer4.invalid" ||
|
if (page_params.name_changes_disabled) {
|
||||||
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();
|
$("#name_change_container").hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -202,6 +202,10 @@ def principal_to_user_profile(agent, principal):
|
|||||||
|
|
||||||
return principal_user_profile
|
return principal_user_profile
|
||||||
|
|
||||||
|
def name_changes_disabled(realm):
|
||||||
|
return (settings.NAME_CHANGES_DISABLED
|
||||||
|
or realm.domain in ('users.customer4.invalid'))
|
||||||
|
|
||||||
@require_post
|
@require_post
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
def beta_signup_submission(request, name=REQ, email=REQ,
|
def beta_signup_submission(request, name=REQ, email=REQ,
|
||||||
@@ -322,7 +326,7 @@ def accounts_register(request):
|
|||||||
form = RegistrationForm()
|
form = RegistrationForm()
|
||||||
else:
|
else:
|
||||||
postdata = request.POST.copy()
|
postdata = request.POST.copy()
|
||||||
if settings.NAME_CHANGES_DISABLED:
|
if name_changes_disabled(realm):
|
||||||
# If we populate profile information via LDAP and we have a
|
# If we populate profile information via LDAP and we have a
|
||||||
# verified name from you on file, use that. Otherwise, fall
|
# verified name from you on file, use that. Otherwise, fall
|
||||||
# back to the full name in the request.
|
# back to the full name in the request.
|
||||||
@@ -376,7 +380,7 @@ def accounts_register(request):
|
|||||||
'email': email,
|
'email': email,
|
||||||
'key': key,
|
'key': key,
|
||||||
'full_name': request.session.get('authenticated_full_name', None),
|
'full_name': request.session.get('authenticated_full_name', None),
|
||||||
'lock_name': name_validated and settings.NAME_CHANGES_DISABLED
|
'lock_name': name_validated and name_changes_disabled(realm)
|
||||||
},
|
},
|
||||||
context_instance=RequestContext(request))
|
context_instance=RequestContext(request))
|
||||||
|
|
||||||
@@ -914,7 +918,7 @@ def home(request):
|
|||||||
is_admin = user_profile.is_admin(),
|
is_admin = user_profile.is_admin(),
|
||||||
can_create_streams = user_profile.can_create_streams(),
|
can_create_streams = user_profile.can_create_streams(),
|
||||||
notify_for_streams_by_default = notify_for_streams_by_default(user_profile),
|
notify_for_streams_by_default = notify_for_streams_by_default(user_profile),
|
||||||
name_changes_disabled = settings.NAME_CHANGES_DISABLED,
|
name_changes_disabled = name_changes_disabled(user_profile.realm),
|
||||||
has_mobile_devices = num_push_devices_for_user(user_profile) > 0,
|
has_mobile_devices = num_push_devices_for_user(user_profile) > 0,
|
||||||
autoscroll_forever = user_profile.autoscroll_forever,
|
autoscroll_forever = user_profile.autoscroll_forever,
|
||||||
show_autoscroll_forever_option = user_profile.realm.domain in ("customer28.invalid", "zulip.com", "customer31.invalid"),
|
show_autoscroll_forever_option = user_profile.realm.domain in ("customer28.invalid", "zulip.com", "customer31.invalid"),
|
||||||
@@ -1414,15 +1418,9 @@ def json_change_settings(request, user_profile,
|
|||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
if user_profile.full_name != full_name and full_name.strip() != "":
|
if user_profile.full_name != full_name and full_name.strip() != "":
|
||||||
if settings.NAME_CHANGES_DISABLED or \
|
if name_changes_disabled(user_profile.realm.domain):
|
||||||
user_profile.realm.domain == "users.customer4.invalid":
|
# Failingly silently is fine -- they can't do it through the UI, so
|
||||||
# At the request of the facilitators, CUSTOMER4
|
# they'd have to be trying to break the rules.
|
||||||
# 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
|
pass
|
||||||
else:
|
else:
|
||||||
new_full_name = full_name.strip()
|
new_full_name = full_name.strip()
|
||||||
|
|||||||
Reference in New Issue
Block a user