From 391853e9aaf53b523250cde341f71f4c874f47b2 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Mon, 22 Jan 2024 15:43:07 +0000 Subject: [PATCH] Fix saving feature --- game/static/game/js/game.js | 4 ++-- game/views/level.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/game/static/game/js/game.js b/game/static/game/js/game.js index 1d12d4205..3ef18a762 100644 --- a/game/static/game/js/game.js +++ b/game/static/game/js/game.js @@ -1211,13 +1211,13 @@ ocargo.Game.prototype._setupSaveTab = function () { break } } - var workspace = { name: newName, contents: ocargo.blocklyControl.serialize(), python_contents: ocargo.pythonControl.getCode(), blockly_enabled: BLOCKLY_ENABLED, - python_enabled: PYTHON_ENABLED + python_enabled: PYTHON_ENABLED, + pythonViewEnabled: PYTHON_VIEW_ENABLED } this.saving.saveWorkspace( diff --git a/game/views/level.py b/game/views/level.py index 865edc7b2..a4146b72b 100644 --- a/game/views/level.py +++ b/game/views/level.py @@ -360,6 +360,12 @@ def load_workspace(request, workspaceID): def save_workspace(request, workspaceID=None): + request_params = ["name", "contents", "python_contents", "blockly_enabled", "python_enabled", "pythonViewEnabled"] + + missing_params = [param for param in request_params if param not in request.POST] + if missing_params != []: + raise Exception("Request missing the following required parameters", missing_params) + name = request.POST.get("name") contents = request.POST.get("contents") python_contents = request.POST.get("python_contents")