From: Carl Worth Date: Sat, 9 Jan 2021 06:19:29 +0000 (-0800) Subject: Reject puzzle edit if "solved" and "solution" are inconsistent X-Git-Url: https://git.cworth.org/git?p=turbot;a=commitdiff_plain;h=4ed02dad3ef9127fd1146753e93334b6c33389de;hp=8835a45a1b898b96456f8e036299a8cb35741ba9 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. --- 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: