mirror of https://github.com/zulip/zulip.git
urls: Move the json/tutorial_status endpoint to be an API-style route.
This commit is contained in:
parent
0e653d198d
commit
79560e21bf
|
@ -4,7 +4,7 @@ var exports = {};
|
||||||
|
|
||||||
function set_tutorial_status(status, callback) {
|
function set_tutorial_status(status, callback) {
|
||||||
return channel.post({
|
return channel.post({
|
||||||
url: '/json/tutorial_status',
|
url: '/json/users/me/tutorial_status',
|
||||||
data: {status: JSON.stringify(status)},
|
data: {status: JSON.stringify(status)},
|
||||||
success: callback,
|
success: callback,
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,7 +18,7 @@ class TutorialTests(ZulipTestCase):
|
||||||
]
|
]
|
||||||
for incoming_status, expected_db_status in cases:
|
for incoming_status, expected_db_status in cases:
|
||||||
params = dict(status=ujson.dumps(incoming_status))
|
params = dict(status=ujson.dumps(incoming_status))
|
||||||
result = self.client_post('/json/tutorial_status', params)
|
result = self.client_post('/json/users/me/tutorial_status', params)
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
user = self.example_user('hamlet')
|
user = self.example_user('hamlet')
|
||||||
self.assertEqual(user.tutorial_status, expected_db_status)
|
self.assertEqual(user.tutorial_status, expected_db_status)
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
|
|
||||||
from django.http import HttpRequest, HttpResponse
|
from django.http import HttpRequest, HttpResponse
|
||||||
|
|
||||||
from zerver.decorator import authenticated_json_post_view, has_request_variables, REQ
|
from zerver.decorator import has_request_variables, REQ
|
||||||
from zerver.lib.response import json_success
|
from zerver.lib.response import json_success
|
||||||
from zerver.lib.validator import check_string
|
from zerver.lib.validator import check_string
|
||||||
from zerver.models import UserProfile
|
from zerver.models import UserProfile
|
||||||
|
|
||||||
@authenticated_json_post_view
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
def json_tutorial_status(request, user_profile,
|
def set_tutorial_status(request, user_profile,
|
||||||
status=REQ(validator=check_string)):
|
status=REQ(validator=check_string)):
|
||||||
# type: (HttpRequest, UserProfile, str) -> HttpResponse
|
# type: (HttpRequest, UserProfile, str) -> HttpResponse
|
||||||
if status == 'started':
|
if status == 'started':
|
||||||
user_profile.tutorial_status = UserProfile.TUTORIAL_STARTED
|
user_profile.tutorial_status = UserProfile.TUTORIAL_STARTED
|
||||||
|
|
|
@ -18,8 +18,7 @@ legacy_urls = [
|
||||||
url(r'^json/subscriptions/exists$', zerver.views.streams.json_stream_exists),
|
url(r'^json/subscriptions/exists$', zerver.views.streams.json_stream_exists),
|
||||||
|
|
||||||
url(r'^json/fetch_api_key$', zerver.views.auth.json_fetch_api_key),
|
url(r'^json/fetch_api_key$', zerver.views.auth.json_fetch_api_key),
|
||||||
# This old-style tutorial is due to be eliminated soon.
|
|
||||||
url(r'^json/tutorial_status$', zerver.views.tutorial.json_tutorial_status),
|
|
||||||
# A version of these reporting views may make sense to support in
|
# A version of these reporting views may make sense to support in
|
||||||
# the API for getting mobile analytics, but we may want something
|
# the API for getting mobile analytics, but we may want something
|
||||||
# totally different.
|
# totally different.
|
||||||
|
|
|
@ -356,6 +356,10 @@ v1_api_and_json_patterns = [
|
||||||
url(r'^users/me/hotspots$', rest_dispatch,
|
url(r'^users/me/hotspots$', rest_dispatch,
|
||||||
{'POST': 'zerver.views.hotspots.mark_hotspot_as_read'}),
|
{'POST': 'zerver.views.hotspots.mark_hotspot_as_read'}),
|
||||||
|
|
||||||
|
# users/me/tutorial_status -> zerver.views.tutorial
|
||||||
|
url(r'^users/me/tutorial_status$', rest_dispatch,
|
||||||
|
{'POST': 'zerver.views.tutorial.set_tutorial_status'}),
|
||||||
|
|
||||||
# settings -> zerver.views.user_settings
|
# settings -> zerver.views.user_settings
|
||||||
url(r'^settings$', rest_dispatch,
|
url(r'^settings$', rest_dispatch,
|
||||||
{'PATCH': 'zerver.views.user_settings.json_change_settings'}),
|
{'PATCH': 'zerver.views.user_settings.json_change_settings'}),
|
||||||
|
|
Loading…
Reference in New Issue