]> git.cworth.org Git - turbot/blobdiff - turbot/events.py
Turbot home: Report "you do not belong to any hunts" if that is the case
[turbot] / turbot / events.py
index 86a3c837d15f2f28485c13c7ae7a913c454f803c..a118835d3b8eb0b42a5e04f6483abbebaf95a74b 100644 (file)
@@ -91,11 +91,20 @@ def home(turb, user_id):
             continue
         hunt_blocks += hunt_block(turb, hunt)
 
+    if len(hunt_blocks):
+        hunt_blocks = [
+            section_block(text_block("*Hunts you belong to*")),
+            divider_block(),
+            * hunt_blocks
+        ]
+    else:
+        hunt_blocks = [
+            section_block(text_block("You do not belong to any hunts"))
+        ]
+
     return {
         "type": "home",
         "blocks": [
-            section_block(text_block("*Hunts you belong to*")),
-            divider_block(),
             * hunt_blocks,
             actions_block(button_block("New hunt", "new_hunt"))
         ]
@@ -221,14 +230,14 @@ def puzzle_channel_created(turb, puzzle_channel_name, puzzle_channel_id):
     # string and cleanly return (eliminating all future retries).
     item['sheet_url'] = 'pending'
     item['channel_url'] = channel_url(puzzle_channel_id)
-    puzzle_table.put_item(Item=item)
+    turb.table.put_item(Item=item)
 
     # Create a sheet for the puzzle
     sheet = sheets_create_for_puzzle(turb, item)
 
     # Update the database with the URL of the sheet
     item['sheet_url'] = sheet['url']
-    puzzle_table.put_item(Item=item)
+    turb.table.put_item(Item=item)
 
     # Get the new sheet_url into the channel description
     set_channel_description(turb, item)