From d15d106c5159888a1849cae85e5d58798d3b21b0 Mon Sep 17 00:00:00 2001 From: Susan Hammond Date: Mon, 2 Dec 2024 13:39:13 -0600 Subject: [PATCH] Hot fix on MySQL Foreign key constraint causing assessment tasks to not save. --- .../controller/Routes/Completed_assessment_routes.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BackEndFlask/controller/Routes/Completed_assessment_routes.py b/BackEndFlask/controller/Routes/Completed_assessment_routes.py index eadf8c013..ced1c1ef3 100644 --- a/BackEndFlask/controller/Routes/Completed_assessment_routes.py +++ b/BackEndFlask/controller/Routes/Completed_assessment_routes.py @@ -159,17 +159,20 @@ def get_completed_assessment_by_team_or_user_id(): def add_completed_assessment(): try: assessment_data = request.json - team_id = int(assessment_data["team_id"]) + if (team_id == -1): + assessment_data["team_id"] = None assessment_task_id = int(request.args.get("assessment_task_id")) user_id = int(assessment_data["user_id"]) + if (user_id == -1): + assessment_data["user_id"] = None completed = completed_assessment_exists(team_id, assessment_task_id, user_id) if completed: - completed = replace_completed_assessment(request.json, completed.completed_assessment_id) + completed = replace_completed_assessment(assessment_data, completed.completed_assessment_id) else: - completed = create_completed_assessment(request.json) + completed = create_completed_assessment(assessment_data) return create_good_response(completed_assessment_schema.dump(completed), 201, "completed_assessments")