]> git.cworth.org Git - turbot/commitdiff
Add a link each hunt's channel in the Home view
authorCarl Worth <cworth@cworth.org>
Wed, 14 Oct 2020 01:19:56 +0000 (18:19 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 14 Oct 2020 01:19:56 +0000 (18:19 -0700)
Making it much easier to get to the hunt, of course.

turbot/views.py

index aa0f010a1b651477f7442efc4a4ef9433124c5c1..2acc474579cc250378639d3307a607c3d9d6f928 100644 (file)
@@ -1,4 +1,4 @@
-def text(body):
+def text_block(body):
     return {
         "text": {
             "type": "mrkdwn",
@@ -29,6 +29,10 @@ def button(label, name):
         "value": name
     }
 
+def hunt_block(hunt):
+    text = "{}: <#{}>".format(hunt['name'], hunt['channel'])
+    return section(text_block(text))
+
 def home(turb, user_id, body):
     """Returns a view to be published as the turbot home tab for user_id
 
@@ -42,8 +46,8 @@ def home(turb, user_id, body):
     return {
         "type": "home",
         "blocks": [
-            section(text("*Active hunts*")),
-            *[section(text(hunt['name'])) for hunt in hunts if hunt['active']],
+            section(text_block("*Active hunts*")),
+            *[hunt_block(hunt) for hunt in hunts if hunt['active']],
             actions(button("New hunt", "new_hunt"))
         ]
     }