mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
Support changing one's name without a reload.
(imported from commit 4e7aea017f016494e2674f11b96681e098816f2d)
This commit is contained in:
@@ -729,6 +729,15 @@ def do_change_full_name(user_profile, full_name, log=True):
|
||||
'user': user_profile.email,
|
||||
'full_name': full_name})
|
||||
|
||||
notice = dict(event=dict(type="realm_user", op="update",
|
||||
person=dict(email=user_profile.email,
|
||||
full_name=user_profile.full_name)),
|
||||
users=[up.id for up in
|
||||
UserProfile.objects.select_related().filter(realm=user_profile.realm,
|
||||
is_active=True)])
|
||||
tornado_callbacks.send_notification(notice)
|
||||
|
||||
|
||||
def do_create_realm(domain, restricted_to_domain=True):
|
||||
realm = get_realm(domain)
|
||||
created = not realm
|
||||
@@ -1101,12 +1110,14 @@ def do_events_register(user_profile, user_client, apply_markdown=True,
|
||||
elif event['type'] == "onboarding_steps":
|
||||
ret['onboarding_steps'] = event['steps']
|
||||
elif event['type'] == "realm_user":
|
||||
if event['op'] == "add":
|
||||
ret['realm_users'].append(event['person'])
|
||||
elif event['op'] == "remove":
|
||||
# We handle update by just removing the old value and
|
||||
# adding the new one.
|
||||
if event['op'] == "remove" or event['op'] == "update":
|
||||
person = event['person']
|
||||
ret['realm_users'] = filter(lambda p: p['email'] != person['email'],
|
||||
ret['realm_users'])
|
||||
if event['op'] == "add" or event['op'] == "update":
|
||||
ret['realm_users'].append(event['person'])
|
||||
elif event['type'] == "subscriptions":
|
||||
subscriptions_to_filter = set(sub.name.lower() for sub in event["subscriptions"])
|
||||
# We add the new subscriptions to the list of streams the
|
||||
|
||||
@@ -54,6 +54,28 @@ function remove_person(person) {
|
||||
delete people_dict[person.email];
|
||||
}
|
||||
|
||||
function update_person(person) {
|
||||
// Currently the only attribute that can change is full_name, so
|
||||
// we just push out changes to that field. As we add more things
|
||||
// that can change, this will need to either get complicated or be
|
||||
// replaced by MVC
|
||||
var i;
|
||||
people_dict[person.email].full_name = person.full_name;
|
||||
for (i = 0; i < page_params.people_list.length; i++) {
|
||||
if (page_params.people_list[i].email === person.email) {
|
||||
page_params.people_list[i].full_name = person.full_name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (person.email === page_params.email) {
|
||||
page_params.fullname = person.full_name;
|
||||
$("#my_information .my_fullname").text(person.full_name);
|
||||
}
|
||||
activity.set_user_statuses([]);
|
||||
|
||||
// TODO: update sender names on messages
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$.each(page_params.people_list, function (idx, person) {
|
||||
people_dict[person.email] = person;
|
||||
@@ -793,6 +815,8 @@ function get_updates_success(data) {
|
||||
add_person(event.person);
|
||||
} else if (event.op === 'remove') {
|
||||
remove_person(event.person);
|
||||
} else if (event.op === 'update') {
|
||||
update_person(event.person);
|
||||
}
|
||||
break;
|
||||
case 'subscriptions':
|
||||
|
||||
Reference in New Issue
Block a user