mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +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();
|
$("#name_change_container").hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.post({
|
channel.get({
|
||||||
url: '/json/get_bots',
|
url: '/json/bots',
|
||||||
idempotent: true,
|
idempotent: true,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
$('#bot_table_error').hide();
|
$('#bot_table_error').hide();
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class ZulipSession extends Session
|
|||||||
@parse_page_params()
|
@parse_page_params()
|
||||||
|
|
||||||
@update_active_status()
|
@update_active_status()
|
||||||
@post '/json/get_bots'
|
@get '/json/bots'
|
||||||
@post '/json/get_old_messages', {
|
@post '/json/get_old_messages', {
|
||||||
anchor: @pointer
|
anchor: @pointer
|
||||||
num_before: 200
|
num_before: 200
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ class ActivateTest(AuthedTestCase):
|
|||||||
|
|
||||||
class BotTest(AuthedTestCase):
|
class BotTest(AuthedTestCase):
|
||||||
def assert_num_bots_equal(self, count):
|
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)
|
self.assert_json_success(result)
|
||||||
json = ujson.loads(result.content)
|
json = ujson.loads(result.content)
|
||||||
self.assertEqual(count, len(json['bots']))
|
self.assertEqual(count, len(json['bots']))
|
||||||
@@ -417,7 +417,7 @@ class BotTest(AuthedTestCase):
|
|||||||
self.assert_json_error(result, 'Insufficient permission')
|
self.assert_json_error(result, 'Insufficient permission')
|
||||||
|
|
||||||
def get_bot(self):
|
def get_bot(self):
|
||||||
result = self.client.post("/json/get_bots")
|
result = self.client.get("/json/bots")
|
||||||
bots = ujson.loads(result.content)['bots']
|
bots = ujson.loads(result.content)['bots']
|
||||||
return bots[0]
|
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)
|
return json_success(json_result)
|
||||||
|
|
||||||
@authenticated_json_post_view
|
def get_bots_backend(request, user_profile):
|
||||||
def json_get_bots(request, user_profile):
|
|
||||||
bot_profiles = UserProfile.objects.filter(is_bot=True, is_active=True,
|
bot_profiles = UserProfile.objects.filter(is_bot=True, is_active=True,
|
||||||
bot_owner=user_profile)
|
bot_owner=user_profile)
|
||||||
bot_profiles = bot_profiles.order_by('date_joined')
|
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/upload_file$', 'json_upload_file'),
|
||||||
url(r'^json/messages_in_narrow$', 'messages.json_messages_in_narrow'),
|
url(r'^json/messages_in_narrow$', 'messages.json_messages_in_narrow'),
|
||||||
url(r'^json/create_bot$', 'json_create_bot'),
|
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/update_message$', 'messages.json_update_message'),
|
||||||
url(r'^json/fetch_raw_message$', 'messages.json_fetch_raw_message'),
|
url(r'^json/fetch_raw_message$', 'messages.json_fetch_raw_message'),
|
||||||
url(r'^json/refer_friend$', 'json_refer_friend'),
|
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',
|
url(r'^users/(?P<email>.*)$', 'rest_dispatch',
|
||||||
{'PATCH': 'update_user_backend',
|
{'PATCH': 'update_user_backend',
|
||||||
'DELETE': 'deactivate_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',
|
url(r'^bots/(?P<email>.*)/api_key/regenerate$', 'rest_dispatch',
|
||||||
{'POST': 'regenerate_bot_api_key'}),
|
{'POST': 'regenerate_bot_api_key'}),
|
||||||
url(r'^bots/(?P<email>.*)$', 'rest_dispatch',
|
url(r'^bots/(?P<email>.*)$', 'rest_dispatch',
|
||||||
|
|||||||
Reference in New Issue
Block a user