mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
Change get_bots API to use rest_dispatch
(imported from commit 921895dd636ba118a0f57e60a7bcb9dca1c7c605)
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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<email>.*)$', 'rest_dispatch',
|
||||
{'PATCH': 'update_user_backend',
|
||||
'DELETE': 'deactivate_user_backend'}),
|
||||
url(r'^bots$', 'rest_dispatch',
|
||||
{'GET': 'get_bots_backend'}),
|
||||
url(r'^bots/(?P<email>.*)/api_key/regenerate$', 'rest_dispatch',
|
||||
{'POST': 'regenerate_bot_api_key'}),
|
||||
url(r'^bots/(?P<email>.*)$', 'rest_dispatch',
|
||||
|
||||
Reference in New Issue
Block a user