From c9db6b665830b2508872d5fbd8c5b94822e3acb5 Mon Sep 17 00:00:00 2001 From: anirudhjain75 Date: Thu, 22 Dec 2016 14:24:27 +0530 Subject: [PATCH] Clean up legacy language_settings endpoint. --- static/js/settings.js | 2 +- zerver/tests/tests.py | 4 ++-- zerver/views/user_settings.py | 1 - zproject/legacy_urls.py | 3 +-- zproject/urls.py | 2 ++ 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/static/js/settings.js b/static/js/settings.js index 3c31117af0..c97432ce4d 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -461,7 +461,7 @@ function _setup_page() { context.lang = new_language; channel.patch({ - url: '/json/language_setting', + url: '/json/settings/display', data: data, success: function () { ui.report_success(i18n.t("__lang__ is now the default language! 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 eebf423c77..4fd0241cd9 100644 --- a/zerver/tests/tests.py +++ b/zerver/tests/tests.py @@ -1677,7 +1677,7 @@ class ChangeSettingsTest(ZulipTestCase): self.login(email) german = "de" data = dict(default_language=ujson.dumps(german)) - result = self.client_post("/json/language_setting", data) + result = self.client_patch("/json/settings/display", data) self.assert_json_success(result) user_profile = get_user_profile_by_email(email) self.assertEqual(user_profile.default_language, german) @@ -1686,7 +1686,7 @@ class ChangeSettingsTest(ZulipTestCase): # and saved in the db. invalid_lang = "invalid_lang" data = dict(default_language=ujson.dumps(invalid_lang)) - result = self.client_post("/json/language_setting", data) + result = self.client_patch("/json/settings/display", data) self.assert_json_error(result, "Invalid language '%s'" % (invalid_lang,)) user_profile = get_user_profile_by_email(email) self.assertNotEqual(user_profile.default_language, invalid_lang) diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py index 11908923f3..b96c5f777d 100644 --- a/zerver/views/user_settings.py +++ b/zerver/views/user_settings.py @@ -122,7 +122,6 @@ def json_left_side_userlist(request, user_profile, left_side_userlist=REQ(valida return json_success(result) -@authenticated_json_post_view @has_request_variables def json_language_setting(request, user_profile, default_language=REQ(validator=check_string, default=None)): # type: (HttpRequest, UserProfile, Optional[str]) -> HttpResponse diff --git a/zproject/legacy_urls.py b/zproject/legacy_urls.py index ed57eed450..42bf0f20c8 100644 --- a/zproject/legacy_urls.py +++ b/zproject/legacy_urls.py @@ -45,5 +45,4 @@ legacy_urls = [ url(r'^json/set_muted_topics$', zerver.views.json_set_muted_topics), url(r'^json/time_setting$', zerver.views.user_settings.json_time_setting), url(r'^json/left_side_userlist$', zerver.views.user_settings.json_left_side_userlist), - url(r'^json/language_setting$', zerver.views.user_settings.json_language_setting), -] + ] diff --git a/zproject/urls.py b/zproject/urls.py index 9eace1f2c2..ac8104ef3f 100644 --- a/zproject/urls.py +++ b/zproject/urls.py @@ -246,6 +246,8 @@ v1_api_and_json_patterns = [ url(r'^users/me/avatar$', rest_dispatch, {'PUT': 'zerver.views.user_settings.set_avatar_backend', 'DELETE': 'zerver.views.user_settings.delete_avatar_backend'}), + url(r'^settings/display$', rest_dispatch, + {'PATCH': 'zerver.views.user_settings.json_language_setting'}), # users/me/alert_words -> zerver.views.alert_words url(r'^users/me/alert_words$', rest_dispatch,