From 8fc8717409f073f205e8c935d45e66dc09580ef7 Mon Sep 17 00:00:00 2001 From: Ashish Date: Sat, 2 Apr 2016 00:44:10 +0530 Subject: [PATCH] Replace json/set_alert_words with REST style route. --- static/js/alert_words_ui.js | 2 +- zerver/tests.py | 12 ++++++------ zproject/urls.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/static/js/alert_words_ui.js b/static/js/alert_words_ui.js index a259dd1b9b..4b363a20a5 100644 --- a/static/js/alert_words_ui.js +++ b/static/js/alert_words_ui.js @@ -11,7 +11,7 @@ function update_word_alerts() { }); channel.post({ - url: '/json/set_alert_words', + url: '/json/users/me/alert_words', idempotent: true, data: {alert_words: JSON.stringify(words)}}); } diff --git a/zerver/tests.py b/zerver/tests.py index 12f163092f..ec7876d4bc 100644 --- a/zerver/tests.py +++ b/zerver/tests.py @@ -1219,7 +1219,7 @@ class AlertWordTests(AuthedTestCase): params = { 'alert_words': ujson.dumps(['milk', 'cookies']) } - result = self.client.post('/json/set_alert_words', params) + result = self.client.post('/json/users/me/alert_words', params) self.assert_json_success(result) user = get_user_profile_by_email(email) words = user_alert_words(user) @@ -1303,7 +1303,7 @@ class AlertWordTests(AuthedTestCase): def test_json_list_add(self): self.login("hamlet@zulip.com") - result = self.client_patch('/json/users/me/alert_words', {'alert_words': ujson.dumps(['one', 'two', 'three'])}) + result = self.client_put('/json/users/me/alert_words', {'alert_words': ujson.dumps(['one', 'two', 'three'])}) self.assert_json_success(result) @@ -1315,7 +1315,7 @@ class AlertWordTests(AuthedTestCase): def test_json_list_remove(self): self.login("hamlet@zulip.com") - result = self.client_patch('/json/users/me/alert_words', {'alert_words': ujson.dumps(['one', 'two', 'three'])}) + result = self.client_put('/json/users/me/alert_words', {'alert_words': ujson.dumps(['one', 'two', 'three'])}) self.assert_json_success(result) result = self.client_delete('/json/users/me/alert_words', {'alert_words': ujson.dumps(['one'])}) @@ -1329,10 +1329,10 @@ class AlertWordTests(AuthedTestCase): def test_json_list_set(self): self.login("hamlet@zulip.com") - result = self.client_patch('/json/users/me/alert_words', {'alert_words': ujson.dumps(['one', 'two', 'three'])}) + result = self.client_put('/json/users/me/alert_words', {'alert_words': ujson.dumps(['one', 'two', 'three'])}) self.assert_json_success(result) - result = self.client_put('/json/users/me/alert_words', {'alert_words': ujson.dumps(['a', 'b', 'c'])}) + result = self.client.post('/json/users/me/alert_words', {'alert_words': ujson.dumps(['a', 'b', 'c'])}) self.assert_json_success(result) result = self.client.get('/json/users/me/alert_words') @@ -1350,7 +1350,7 @@ class AlertWordTests(AuthedTestCase): self.login("hamlet@zulip.com") user_profile_hamlet = get_user_profile_by_email("hamlet@zulip.com") - result = self.client_patch('/json/users/me/alert_words', {'alert_words': ujson.dumps(['one', 'two', 'three'])}) + result = self.client_put('/json/users/me/alert_words', {'alert_words': ujson.dumps(['one', 'two', 'three'])}) self.assert_json_success(result) result = self.client.get('/json/users/me/alert_words') diff --git a/zproject/urls.py b/zproject/urls.py index a6b36387c2..e30297d8b7 100644 --- a/zproject/urls.py +++ b/zproject/urls.py @@ -226,8 +226,8 @@ v1_api_and_json_patterns = patterns('zerver.views', ) + patterns('zerver.views.alert_words', url(r'^users/me/alert_words$', 'rest_dispatch', {'GET': 'list_alert_words', - 'PUT': 'set_alert_words', - 'PATCH': 'add_alert_words', + 'POST': 'set_alert_words', + 'PUT': 'add_alert_words', 'DELETE': 'remove_alert_words'}), ) + patterns('zerver.views.user_settings',