From f24810fc15444385a0932b24a38f646318fcca94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Pelay?= <45865185+jpelay@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:56:41 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=B2=20Fix=20make=5Fresponse=20incorrec?= =?UTF-8?q?tly=20sending=20`text`=20instead=20of=20JSON=20(#5599)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #5558 Introduced an error where some calls where expecting a JSON, and got text instead. I checked the places where this happened and fix the calls. If I'm missing some, please add them 😄 **How to test** Perform the following: * Update an adventure * Update a class customization * Create students account * Reset password * Reset a student's password * Update your public profile And all of them should show the success modal! Also: Fixes #5550 --- app.py | 14 +++++---- templates/incl/menubar.html | 2 +- .../cypress/e2e/feedback/feedback_modal.cy.js | 2 +- website/achievements.py | 2 +- website/admin.py | 3 +- website/auth_pages.py | 4 +-- website/classes.py | 29 ++++++++++--------- website/feedback.py | 2 +- website/for_teachers.py | 7 +++-- website/programs.py | 2 +- website/user_activity.py | 2 +- 11 files changed, 37 insertions(+), 32 deletions(-) diff --git a/app.py b/app.py index a0c4fe8f529..cd5b09fd2af 100644 --- a/app.py +++ b/app.py @@ -727,6 +727,12 @@ def prepare_files(): threader = textwrap.dedent(""" import time from turtlethread import Turtle + def int_with_error(value, error_message): + try: + return int(value) + except ValueError: + raise ValueError(error_message.format(value)) + t = Turtle() t.left(90) with t.running_stitch(stitch_length=20): @@ -751,7 +757,6 @@ def prepare_files(): for file in [x for x in files if x[:len(filename)] == filename and x[-3:] != 'zip']: zip_file.write('machine_files/' + file) zip_file.close() - return make_response({'filename': filename}, 200) @@ -788,7 +793,6 @@ def generate_microbit_file(): save_transpiled_code_for_microbit(transpile_result) return make_response({'filename': 'Micro-bit.py', 'microbit': True}, 200) else: - # TODO return make_response({'message': 'Microbit feature is disabled'}, 403) @@ -827,7 +831,6 @@ def remove_file(response): return send_file(os.path.join(micro_bit_directory, "micropython.hex"), as_attachment=True) else: - # TODO return make_response({'message': 'Microbit feature is disabled'}, 403) @@ -2604,9 +2607,10 @@ def update_public_profile(user): body['tags'].append('admin') DATABASE.update_public_profile(user['username'], body) + response = {"message": gettext("public_profile_updated")} if achievement: - utils.add_pending_achievement({"achievement": achievement}) - return make_response(gettext("public_profile_updated"), 200) + response["achievement"] = achievement + return response @app.route('/translating') diff --git a/templates/incl/menubar.html b/templates/incl/menubar.html index 939651587ff..efb726ba59a 100644 --- a/templates/incl/menubar.html +++ b/templates/incl/menubar.html @@ -56,7 +56,7 @@