]> git.cworth.org Git - turbot/blobdiff - turbot/interaction.py
new_puzzle_submission: Create a puzzle dict before shoving it into the DB
[turbot] / 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