]> git.cworth.org Git - turbot/commitdiff
Fix puzzle edit form in the case of no existing rounds in the hunt yet
authorCarl Worth <cworth@cworth.org>
Sat, 8 Jan 2022 01:26:59 +0000 (17:26 -0800)
committerCarl Worth <cworth@cworth.org>
Sat, 8 Jan 2022 01:26:59 +0000 (17:26 -0800)
This was a corner case affecting only the first few puzzles or so, (before
any puzzles were associated with a round).

turbot/interaction.py

index 6a94a342b88004ef4a384027d61f437f2089aa48..cbb8befe2bcb3eb4ebf3df0d7f3165fcf1f5e128 100644 (file)
@@ -267,10 +267,11 @@ def edit_puzzle_submission(turb, payload, metadata):
         puzzle['type'] = 'meta'
     else:
         puzzle['type'] = 'plain'
-    rounds = [option['value'] for option in
-              state['rounds']['rounds']['selected_options']]
-    if rounds:
-        puzzle['rounds'] = rounds
+    if 'rounds' in state:
+        rounds = [option['value'] for option in
+                  state['rounds']['rounds']['selected_options']]
+        if rounds:
+            puzzle['rounds'] = rounds
     new_rounds = state['new_rounds']['new_rounds']['value']
     puzzle_state = state['state']['state']['value']
     if puzzle_state: