mirror of https://github.com/zulip/zulip.git
Include timezone in user_dict fields.
Tweaked by tabbott to avoid adding timezone to bot dicts, since bots don't need a timezone.
This commit is contained in:
parent
2a0a84b229
commit
bf3b2ac673
|
@ -59,6 +59,10 @@ exports.update_person = function update(person) {
|
|||
|
||||
message_live_update.update_avatar(person_obj.user_id, person.avatar_url);
|
||||
}
|
||||
|
||||
if (_.has(person, 'timezone')) {
|
||||
person_obj.timezone = person.timezone;
|
||||
}
|
||||
};
|
||||
|
||||
return exports;
|
||||
|
|
|
@ -362,6 +362,7 @@ def notify_created_user(user_profile):
|
|||
is_admin=user_profile.is_realm_admin,
|
||||
full_name=user_profile.full_name,
|
||||
avatar_url=avatar_url(user_profile),
|
||||
timezone=user_profile.timezone,
|
||||
is_bot=user_profile.is_bot))
|
||||
send_event(event, active_user_ids(user_profile.realm))
|
||||
|
||||
|
@ -2235,6 +2236,14 @@ def do_set_user_display_setting(user_profile, setting_name, setting_value):
|
|||
'setting': setting_value}
|
||||
send_event(event, [user_profile.id])
|
||||
|
||||
# Updates to the timezone display setting are sent to all users
|
||||
if setting_name == "timezone":
|
||||
payload = dict(email=user_profile.email,
|
||||
user_id=user_profile.id,
|
||||
timezone=user_profile.timezone)
|
||||
send_event(dict(type='realm_user', op='update', person=payload),
|
||||
active_user_ids(user_profile.realm))
|
||||
|
||||
def set_default_streams(realm, stream_dict):
|
||||
# type: (Realm, Dict[Text, Dict[Text, Any]]) -> None
|
||||
DefaultStream.objects.filter(realm=realm).delete()
|
||||
|
|
|
@ -316,7 +316,7 @@ def user_profile_by_id_cache_key(user_profile_id):
|
|||
active_user_dict_fields = [
|
||||
'id', 'full_name', 'short_name', 'email',
|
||||
'avatar_source', 'avatar_version',
|
||||
'is_realm_admin', 'is_bot'] # type: List[str]
|
||||
'is_realm_admin', 'is_bot', 'timezone'] # type: List[str]
|
||||
|
||||
def active_user_dicts_in_realm_cache_key(realm):
|
||||
# type: (Realm) -> Text
|
||||
|
|
|
@ -50,7 +50,8 @@ def get_realm_user_dicts(user_profile):
|
|||
'avatar_url': avatar_url(userdict),
|
||||
'is_admin': userdict['is_realm_admin'],
|
||||
'is_bot': userdict['is_bot'],
|
||||
'full_name': userdict['full_name']}
|
||||
'full_name': userdict['full_name'],
|
||||
'timezone': userdict['timezone']}
|
||||
for userdict in get_active_user_dicts_in_realm(user_profile.realm)]
|
||||
|
||||
# Fetch initial data. When event_types is not specified, clients want
|
||||
|
|
|
@ -881,21 +881,36 @@ class EventsRegisterTest(ZulipTestCase):
|
|||
else:
|
||||
raise AssertionError("Unexpected property type %s" % (property_type,))
|
||||
|
||||
num_events = 1
|
||||
if setting_name == "timezone":
|
||||
num_events = 2
|
||||
if property_type == bool:
|
||||
do_set_user_display_setting(self.user_profile, setting_name, False)
|
||||
for value in values_list:
|
||||
events = self.do_test(lambda: do_set_user_display_setting(
|
||||
self.user_profile, setting_name, value), num_events=num_events)
|
||||
|
||||
schema_checker = check_dict([
|
||||
('type', equals('update_display_settings')),
|
||||
('setting_name', equals(setting_name)),
|
||||
('user', check_string),
|
||||
('setting', validator),
|
||||
])
|
||||
|
||||
if property_type == bool:
|
||||
do_set_user_display_setting(self.user_profile, setting_name, False)
|
||||
for value in values_list:
|
||||
events = self.do_test(lambda: do_set_user_display_setting(
|
||||
self.user_profile, setting_name, value))
|
||||
error = schema_checker('events[0]', events[0])
|
||||
self.assert_on_error(error)
|
||||
|
||||
timezone_schema_checker = check_dict([
|
||||
('type', equals('realm_user')),
|
||||
('op', equals('update')),
|
||||
('person', check_dict([
|
||||
('email', check_string),
|
||||
('user_id', check_int),
|
||||
('timezone', check_string),
|
||||
])),
|
||||
])
|
||||
if setting_name == "timezone":
|
||||
error = timezone_schema_checker('events[1]', events[1])
|
||||
|
||||
def test_change_twenty_four_hour_time(self):
|
||||
# type: () -> None
|
||||
self.do_set_user_display_settings_test("twenty_four_hour_time", [True, False])
|
||||
|
|
Loading…
Reference in New Issue