Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
api: Fix encoding of strings in tutorial endpoint.
Gaurav Pandey232c7107ebc8
diff --git a/static/js/tutorial.js b/static/js/tutorial.jsindex e5cfebbaed3..486d201782d 100644--- a/static/js/tutorial.js+++ b/static/js/tutorial.js@@ -5,7 +5,7 @@ import {page_params} from "./page_params";function set_tutorial_status(status, callback) {return channel.post({url: "/json/users/me/tutorial_status",- data: {status: JSON.stringify(status)},+ data: {status},success: callback,});}diff --git a/zerver/tests/test_tutorial.py b/zerver/tests/test_tutorial.pyindex fd3507498a9..5399337998e 100644--- a/zerver/tests/test_tutorial.py+++ b/zerver/tests/test_tutorial.py@@ -1,4 +1,3 @@-import orjsonfrom django.conf import settingsfrom zerver.lib.actions import internal_send_private_message@@ -27,7 +26,7 @@ class TutorialTests(ZulipTestCase):("finished", UserProfile.TUTORIAL_FINISHED),]for incoming_status, expected_db_status in cases:- params = dict(status=orjson.dumps(incoming_status).decode())+ params = dict(status=incoming_status)result = self.client_post("/json/users/me/tutorial_status", params)self.assert_json_success(result)user = self.example_user("hamlet")diff --git a/zerver/views/tutorial.py b/zerver/views/tutorial.pyindex d772f99b732..649f891b040 100644--- a/zerver/views/tutorial.py+++ b/zerver/views/tutorial.py@@ -3,14 +3,13 @@ from django.http import HttpRequest, HttpResponsefrom zerver.decorator import human_users_onlyfrom zerver.lib.request import REQ, has_request_variablesfrom zerver.lib.response import json_success-from zerver.lib.validator import check_stringfrom zerver.models import UserProfile@human_users_only@has_request_variablesdef set_tutorial_status(- request: HttpRequest, user_profile: UserProfile, status: str = REQ(json_validator=check_string)+ request: HttpRequest, user_profile: UserProfile, status: str = REQ()) -> HttpResponse:if status == "started":user_profile.tutorial_status = UserProfile.TUTORIAL_STARTED