diff --git a/static/js/settings.js b/static/js/settings.js index 7e4e879add..5ff45d1404 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -71,8 +71,8 @@ $(function () { $("#name_change_container").hide(); } - channel.post({ - url: '/json/get_bots', + channel.get({ + url: '/json/bots', idempotent: true, success: function (data) { $('#bot_table_error').hide(); diff --git a/tools/stress-test/stress-test.coffee b/tools/stress-test/stress-test.coffee index ffb38a7902..4274ed0696 100644 --- a/tools/stress-test/stress-test.coffee +++ b/tools/stress-test/stress-test.coffee @@ -42,7 +42,7 @@ class ZulipSession extends Session @parse_page_params() @update_active_status() - @post '/json/get_bots' + @get '/json/bots' @post '/json/get_old_messages', { anchor: @pointer num_before: 200 diff --git a/zerver/tests.py b/zerver/tests.py index 2f511c6964..33467bb616 100644 --- a/zerver/tests.py +++ b/zerver/tests.py @@ -334,7 +334,7 @@ class ActivateTest(AuthedTestCase): class BotTest(AuthedTestCase): def assert_num_bots_equal(self, count): - result = self.client.post("/json/get_bots") + result = self.client.get("/json/bots") self.assert_json_success(result) json = ujson.loads(result.content) self.assertEqual(count, len(json['bots'])) @@ -417,7 +417,7 @@ class BotTest(AuthedTestCase): self.assert_json_error(result, 'Insufficient permission') def get_bot(self): - result = self.client.post("/json/get_bots") + result = self.client.get("/json/bots") bots = ujson.loads(result.content)['bots'] return bots[0] diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index 39ae37fa4e..ee61055bf5 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -1955,8 +1955,7 @@ def json_create_bot(request, user_profile, full_name=REQ, short_name=REQ): ) return json_success(json_result) -@authenticated_json_post_view -def json_get_bots(request, user_profile): +def get_bots_backend(request, user_profile): bot_profiles = UserProfile.objects.filter(is_bot=True, is_active=True, bot_owner=user_profile) bot_profiles = bot_profiles.order_by('date_joined') diff --git a/zproject/urls.py b/zproject/urls.py index c1a279d6dc..0197184387 100644 --- a/zproject/urls.py +++ b/zproject/urls.py @@ -136,7 +136,6 @@ urlpatterns += patterns('zerver.views', url(r'^json/upload_file$', 'json_upload_file'), url(r'^json/messages_in_narrow$', 'messages.json_messages_in_narrow'), url(r'^json/create_bot$', 'json_create_bot'), - url(r'^json/get_bots$', 'json_get_bots'), url(r'^json/update_message$', 'messages.json_update_message'), url(r'^json/fetch_raw_message$', 'messages.json_fetch_raw_message'), url(r'^json/refer_friend$', 'json_refer_friend'), @@ -222,6 +221,8 @@ v1_api_and_json_patterns = patterns('zerver.views', url(r'^users/(?P.*)$', 'rest_dispatch', {'PATCH': 'update_user_backend', 'DELETE': 'deactivate_user_backend'}), + url(r'^bots$', 'rest_dispatch', + {'GET': 'get_bots_backend'}), url(r'^bots/(?P.*)/api_key/regenerate$', 'rest_dispatch', {'POST': 'regenerate_bot_api_key'}), url(r'^bots/(?P.*)$', 'rest_dispatch',