diff --git a/humbug/urls.py b/humbug/urls.py index bb9c04c686..abe02194c5 100644 --- a/humbug/urls.py +++ b/humbug/urls.py @@ -22,7 +22,7 @@ urlpatterns = patterns('', url(r'^json/subscriptions/list$', 'zephyr.views.json_list_subscriptions', name='json_list_subscriptions'), url(r'^json/subscriptions/remove$', 'zephyr.views.json_remove_subscription', name='json_remove_subscription'), url(r'^json/subscriptions/add$', 'zephyr.views.json_add_subscription', name='json_add_subscription'), - url(r'^json/subscriptions/exists/(?P.*)$', 'zephyr.views.json_stream_exists', name='json_stream_exists'), + url(r'^json/subscriptions/exists$', 'zephyr.views.json_stream_exists', name='json_stream_exists'), # These are json format views used by the API. They require an API key. url(r'^api/v1/get_messages$', 'zephyr.views.api_get_messages', name='api_get_messages'), diff --git a/zephyr/static/js/compose.js b/zephyr/static/js/compose.js index 4e479f63a0..69ada5211e 100644 --- a/zephyr/static/js/compose.js +++ b/zephyr/static/js/compose.js @@ -102,7 +102,8 @@ function check_stream_for_send(stream_name) { var okay = true; $.ajax({ type: "POST", - url: "/json/subscriptions/exists/" + stream_name, + url: "/json/subscriptions/exists", + data: {'stream': stream_name}, async: false, success: function (data) { if (data.exists === "False") { diff --git a/zephyr/tests.py b/zephyr/tests.py index f77447dd66..e0bf9f6c8b 100644 --- a/zephyr/tests.py +++ b/zephyr/tests.py @@ -123,7 +123,7 @@ class PublicURLTest(TestCase): "/json/settings/change/", "/json/subscriptions/list", "/json/subscriptions/remove", - "/json/subscriptions/exists/test", + "/json/subscriptions/exists", "/json/subscriptions/add"], } for status_code, url_set in urls.iteritems(): diff --git a/zephyr/views.py b/zephyr/views.py index 2cbb3cd8d4..9929f0dbb3 100644 --- a/zephyr/views.py +++ b/zephyr/views.py @@ -591,7 +591,10 @@ def json_change_settings(request): return json_success(result) @login_required_json_view -def json_stream_exists(request, stream): +def json_stream_exists(request): + if "stream" not in request.POST: + return json_error("Missing stream argument.") + stream = request.POST.get("stream") if not valid_stream_name(stream): return json_error("Invalid characters in stream name") exists = bool(get_stream(stream, UserProfile.objects.get(user=request.user).realm))