diff --git a/static/js/settings.js b/static/js/settings.js index accd820231..5c606a3e05 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -408,7 +408,7 @@ function _setup_page() { } channel.patch({ - url: '/json/left_side_userlist', + url: '/json/settings/display', data: data, success: function () { ui.report_success(i18n.t("User list will appear on the __side__ hand side! You will need to reload the window for your changes to take effect.", context), diff --git a/zerver/tests/tests.py b/zerver/tests/tests.py index 28b8d9b7cb..11817102a2 100644 --- a/zerver/tests/tests.py +++ b/zerver/tests/tests.py @@ -1638,7 +1638,7 @@ class ChangeSettingsTest(ZulipTestCase): def test_toggling_left_side_userlist(self): # type: () -> None - self.check_for_toggle_param("/json/left_side_userlist", "left_side_userlist") + self.check_for_toggle_param_patch("/json/settings/display", "left_side_userlist") def test_time_setting(self): # type: () -> None diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py index bf29c75185..ec98eb7625 100644 --- a/zerver/views/user_settings.py +++ b/zerver/views/user_settings.py @@ -95,27 +95,12 @@ def json_change_settings(request, user_profile, return json_success(result) -@authenticated_json_post_view -@has_request_variables -def json_left_side_userlist(request, user_profile, left_side_userlist=REQ(validator=check_bool, default=None)): - # type: (HttpRequest, UserProfile, Optional[bool]) -> HttpResponse - result = {} - if (left_side_userlist is not None and - user_profile.left_side_userlist != left_side_userlist): - - do_change_left_side_userlist(user_profile, left_side_userlist) - - result['left_side_userlist'] = left_side_userlist - - return json_success(result) - -# TODO: Merge json_left_side_userlist endpoint -# into this one; it should be straightforward @has_request_variables def update_display_settings_backend(request, user_profile, twenty_four_hour_time=REQ(validator=check_bool, default=None), - default_language=REQ(validator=check_string, default=None)): - # type: (HttpRequest, UserProfile, Optional[bool], Optional[str]) -> HttpResponse + default_language=REQ(validator=check_string, default=None), + left_side_userlist=REQ(validator=check_bool, default=None)): + # type: (HttpRequest, UserProfile, Optional[bool], Optional[str], Optional[bool]) -> HttpResponse if (default_language is not None and default_language not in get_available_language_codes()): raise JsonableError(_("Invalid language '%s'" % (default_language,))) @@ -131,6 +116,11 @@ def update_display_settings_backend(request, user_profile, do_change_twenty_four_hour_time(user_profile, twenty_four_hour_time) result['twenty_four_hour_time'] = twenty_four_hour_time + elif (left_side_userlist is not None and + user_profile.left_side_userlist != left_side_userlist): + do_change_left_side_userlist(user_profile, left_side_userlist) + result['left_side_userlist'] = left_side_userlist + return json_success(result) @authenticated_json_post_view diff --git a/zproject/legacy_urls.py b/zproject/legacy_urls.py index 8166d74115..2274e3eea1 100644 --- a/zproject/legacy_urls.py +++ b/zproject/legacy_urls.py @@ -42,5 +42,4 @@ legacy_urls = [ url(r'^json/messages_in_narrow$', zerver.views.messages.json_messages_in_narrow), url(r'^json/update_message$', zerver.views.messages.json_update_message), url(r'^json/set_muted_topics$', zerver.views.json_set_muted_topics), - url(r'^json/left_side_userlist$', zerver.views.user_settings.json_left_side_userlist), ]