diff --git a/Changelog.md b/Changelog.md index 9ba5538c..799bf474 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented here. ## [v2.4.1] - Fix bug that prevented copies of instructor directories from being deleted (#483) - Add STACK_ROOT to containers as well as notes in readme (#484) +- Ensure _env_status is updated to "setup" earlier when a request to update test settings is made (#499) ## [v2.4.0] - Fix bug that prevented test results from being returned when a feedback file could not be found (#458) diff --git a/client/autotest_client/__init__.py b/client/autotest_client/__init__.py index dc2ea3a8..87455aae 100644 --- a/client/autotest_client/__init__.py +++ b/client/autotest_client/__init__.py @@ -2,6 +2,7 @@ from werkzeug.exceptions import HTTPException import os import sys +import time import rq import json import io @@ -108,6 +109,11 @@ def _update_settings(settings_id, user): if error: abort(make_response(jsonify(message=error), 422)) + test_settings["_user"] = user + test_settings["_last_access"] = int(time.time()) + test_settings["_env_status"] = "setup" + REDIS_CONNECTION.hset("autotest:settings", key=settings_id, value=json.dumps(test_settings)) + queue = rq.Queue("settings", connection=REDIS_CONNECTION) data = {"user": user, "settings_id": settings_id, "test_settings": test_settings, "file_url": file_url} queue.enqueue_call( @@ -198,7 +204,9 @@ def settings(settings_id, **_kw): @authorize def create_settings(user): settings_id = REDIS_CONNECTION.incr("autotest:settings_id") - REDIS_CONNECTION.hset("autotest:settings", key=settings_id, value=json.dumps({"_user": user})) + REDIS_CONNECTION.hset( + "autotest:settings", key=settings_id, value=json.dumps({"_user": user, "_env_status": "setup"}) + ) _update_settings(settings_id, user) return {"settings_id": settings_id} diff --git a/server/autotest_server/__init__.py b/server/autotest_server/__init__.py index 046b565a..88524c26 100644 --- a/server/autotest_server/__init__.py +++ b/server/autotest_server/__init__.py @@ -370,11 +370,6 @@ def ignore_missing_dir_error( def update_test_settings(user, settings_id, test_settings, file_url): - test_settings["_user"] = user - test_settings["_last_access"] = int(time.time()) - test_settings["_env_status"] = "setup" - redis_connection().hset("autotest:settings", key=settings_id, value=json.dumps(test_settings)) - try: settings_dir = os.path.join(TEST_SCRIPT_DIR, str(settings_id))