From 5a1bf7d220db5d91db52dce48bdf29485eae105b Mon Sep 17 00:00:00 2001
From: Carl Worth <cworth@cworth.org>
Date: Sat, 9 Jan 2021 02:47:57 -0800
Subject: [PATCH] new_puzzle_submission: Create a puzzle dict before shoving it
 into the DB

This will be handy for calling some puzzle.py functions that expect a dict.
---
 turbot/interaction.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/turbot/interaction.py b/turbot/interaction.py
index b220161..c0aff61 100644
--- a/turbot/interaction.py
+++ b/turbot/interaction.py
@@ -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
 
-- 
2.45.2