From 4ed02dad3ef9127fd1146753e93334b6c33389de Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 8 Jan 2021 22:19:29 -0800 Subject: [PATCH] Reject puzzle edit if "solved" and "solution" are inconsistent There's an argument here that we really shouldn't be giving the user two different fields if we're forcing them to be edited together, but that's what we have right now. --- turbot/interaction.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/turbot/interaction.py b/turbot/interaction.py index 8ae4a53..417066a 100644 --- a/turbot/interaction.py +++ b/turbot/interaction.py @@ -197,6 +197,15 @@ def edit_puzzle_submission(turb, payload, metadata): sol.strip() for sol in solution.split(',') ] + # Verify that there's a solution if the puzzle is mark solved + if puzzle['status'] == 'solved' and not puzzle['solution']: + return submission_error("solution", + "A solved puzzle requires a solution.") + + if puzzle['status'] == 'unsolved' and puzzle['solution']: + return submission_error("solution", + "An unsolved puzzle should have no solution.") + # Add any new rounds to the database if new_rounds: if 'rounds' not in puzzle: -- 2.43.0