urls: Remove legacy URL for left_side_userlist and move over to REST PATCH endpoint

This commit is contained in:
Sampriti Panda 2016-12-24 16:14:41 +05:30 committed by showell
parent acb02cbdd3
commit 87e7dc6799
4 changed files with 10 additions and 21 deletions

View File

@ -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),

View File

@ -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

View File

@ -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

View File

@ -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),
]