mirror of
https://github.com/zulip/zulip.git
synced 2025-11-21 15:09:34 +00:00
Simplify twenty-four-hour time logic to be more generic.
(imported from commit bda4972b32b17a36518eddef701748f3a548e376)
This commit is contained in:
@@ -363,15 +363,15 @@ exports.setup_page = function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#twenty_four_hour_time").change(function () {
|
$("#twenty_four_hour_time").change(function () {
|
||||||
var time_checkbox = $("#twenty_four_hour_time").is(":checked");
|
|
||||||
var data = {};
|
var data = {};
|
||||||
data.twenty_four_hour_time = JSON.stringify(time_checkbox);
|
var setting_value = $("#twenty_four_hour_time").is(":checked");
|
||||||
|
data.twenty_four_hour_time = JSON.stringify(setting_value);
|
||||||
|
|
||||||
channel.patch({
|
channel.patch({
|
||||||
url: '/json/time_setting',
|
url: '/json/time_setting',
|
||||||
data: data,
|
data: data,
|
||||||
success: function (resp, statusText, xhr, form) {
|
success: function (resp, statusText, xhr, form) {
|
||||||
ui.report_success("Updated display settings! You will need to reload for the changes to take effect",
|
ui.report_success("Updated display settings! You will need to reload the window for your changes to take effect",
|
||||||
$('#display-settings-status').expectOne());
|
$('#display-settings-status').expectOne());
|
||||||
},
|
},
|
||||||
error: function (xhr, error_type, xhn) {
|
error: function (xhr, error_type, xhn) {
|
||||||
|
|||||||
@@ -1718,13 +1718,13 @@ def do_change_default_desktop_notifications(user_profile, default_desktop_notifi
|
|||||||
user_profile.default_desktop_notifications = default_desktop_notifications
|
user_profile.default_desktop_notifications = default_desktop_notifications
|
||||||
user_profile.save(update_fields=["default_desktop_notifications"])
|
user_profile.save(update_fields=["default_desktop_notifications"])
|
||||||
|
|
||||||
def do_change_twenty_four_hour_time(user_profile, twenty_four_hour_time, log=True):
|
def do_change_twenty_four_hour_time(user_profile, setting_value, log=True):
|
||||||
user_profile.twenty_four_hour_time = twenty_four_hour_time
|
user_profile.twenty_four_hour_time = setting_value
|
||||||
user_profile.save(update_fields=["twenty_four_hour_time"])
|
user_profile.save(update_fields=["twenty_four_hour_time"])
|
||||||
event = {'type': 'update_display_settings',
|
event = {'type': 'update_display_settings',
|
||||||
'user': user_profile.email,
|
'user': user_profile.email,
|
||||||
'setting_name': 'twenty_four_hour_time',
|
'setting_name': 'twenty_four_hour_time',
|
||||||
'setting': twenty_four_hour_time}
|
'setting': setting_value}
|
||||||
if log:
|
if log:
|
||||||
log_event(event)
|
log_event(event)
|
||||||
send_event(event, [user_profile.id])
|
send_event(event, [user_profile.id])
|
||||||
|
|||||||
@@ -443,8 +443,8 @@ class EventsRegisterTest(AuthedTestCase):
|
|||||||
('setting', check_bool),
|
('setting', check_bool),
|
||||||
])
|
])
|
||||||
# The first False is probably a noop, then we get transitions in both directions.
|
# The first False is probably a noop, then we get transitions in both directions.
|
||||||
for twenty_four_hour_time in [False, True, False]:
|
for setting_value in [False, True, False]:
|
||||||
events = self.do_test(lambda: do_change_twenty_four_hour_time(self.user_profile, twenty_four_hour_time))
|
events = self.do_test(lambda: do_change_twenty_four_hour_time(self.user_profile, setting_value))
|
||||||
error = schema_checker('events[0]', events[0])
|
error = schema_checker('events[0]', events[0])
|
||||||
self.assert_on_error(error)
|
self.assert_on_error(error)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user