]> git.cworth.org Git - turbot/commitdiff
new_puzzle_submission: Create a puzzle dict before shoving it into the DB
authorCarl Worth <cworth@cworth.org>
Sat, 9 Jan 2021 10:47:57 +0000 (02:47 -0800)
committerCarl Worth <cworth@cworth.org>
Sat, 9 Jan 2021 11:17:21 +0000 (03:17 -0800)
This will be handy for calling some puzzle.py functions that expect a dict.

turbot/interaction.py

index b22016107df99ae5127e4101d6cbe87abc0c4a3e..c0aff61dbc7412bbfb895f6cbec2336432bbc0a1 100644 (file)
@@ -776,8 +776,8 @@ def new_puzzle_submission(turb, payload, metadata):
                 }
             )
 
-    # Insert the newly-created puzzle into the database
-    item={
+    # Construct a puzzle dict
+    puzzle = {
         "hunt_id": hunt_id,
         "SK": "puzzle-{}".format(puzzle_id),
         "puzzle_id": puzzle_id,
@@ -788,10 +788,12 @@ def new_puzzle_submission(turb, payload, metadata):
         "type": puzzle_type
     }
     if url:
-        item['url'] = url
+        puzzle['url'] = url
     if rounds:
-        item['rounds'] = rounds
-    turb.table.put_item(Item=item)
+        puzzle['rounds'] = rounds
+
+    # Insert the newly-created puzzle into the database
+    turb.table.put_item(Item=puzzle)
 
     return lambda_ok