bug fix: Fix error when admin renames a bot after reactivating it.

Fix administration page javascript issue of TypeError that occurs
due to undefined variable access in static/js/bot_data.js file.
Reactivating a bot was not updating the state in `bot_data`.
Sending an event on reactivating a bot fixes this issue.

Fixes: #2840
This commit is contained in:
Abhijeet Kaur
2017-02-16 01:36:07 +05:30
committed by Tim Abbott
parent 15d60fa7ed
commit f0121973d2
2 changed files with 47 additions and 12 deletions

View File

@@ -372,18 +372,24 @@ def notify_created_bot(user_profile):
default_sending_stream_name = stream_name(user_profile.default_sending_stream)
default_events_register_stream_name = stream_name(user_profile.default_events_register_stream)
event = dict(type="realm_bot", op="add",
bot=dict(email=user_profile.email,
user_id=user_profile.id,
full_name=user_profile.full_name,
is_active=user_profile.is_active,
api_key=user_profile.api_key,
default_sending_stream=default_sending_stream_name,
default_events_register_stream=default_events_register_stream_name,
default_all_public_streams=user_profile.default_all_public_streams,
avatar_url=avatar_url(user_profile),
owner=user_profile.bot_owner.email,
))
bot = dict(email=user_profile.email,
user_id=user_profile.id,
full_name=user_profile.full_name,
is_active=user_profile.is_active,
api_key=user_profile.api_key,
default_sending_stream=default_sending_stream_name,
default_events_register_stream=default_events_register_stream_name,
default_all_public_streams=user_profile.default_all_public_streams,
avatar_url=avatar_url(user_profile),
)
# Set the owner key only when the bot has an owner.
# The default bots don't have an owner. So don't
# set the owner key while reactivating them.
if user_profile.bot_owner is not None:
bot['owner'] = user_profile.bot_owner.email
event = dict(type="realm_bot", op="add", bot=bot)
send_event(event, bot_owner_userids(user_profile))
def do_create_user(email, password, realm, full_name, short_name,
@@ -1862,6 +1868,9 @@ def do_reactivate_user(user_profile):
notify_created_user(user_profile)
if user_profile.is_bot:
notify_created_bot(user_profile)
def do_change_password(user_profile, password, log=True, commit=True,
hashed_password=False):
# type: (UserProfile, Text, bool, bool, bool) -> None