15 def actions(*elements):
18 "elements": list(elements)
21 def button(label, name):
32 def input(label, name, placeholder):
36 "type": "plain_text_input",
50 text = "{}: <#{}>".format(hunt['name'], hunt['channel_id'])
51 return section(text_block(text))
53 def home(turb, user_id, body):
54 """Returns a view to be published as the turbot home tab for user_id
56 The body argument is a dictionary as provided by the Slack request.
57 The return value is a dictionary suitable to be published to the
58 Slack views_publish API."""
60 response = turb.db.Table("hunts").scan()
61 hunts = response['Items']
66 section(text_block("*Active hunts*")),
67 *[hunt_block(hunt) for hunt in hunts if hunt['active']],
68 actions(button("New hunt", "new_hunt"))
73 """Returns a view to be published as the new_hunt modal"""
77 "title": { "type": "plain_text", "text": "New Hunt" },
78 "submit": { "type": "plain_text", "text": "Create" },
80 input("Hunt name", "name", "Name of the hunt"),
81 input("Hunt ID", "slug", "Short prefix for hunt (no spaces)"),
82 input("Hunt URL", "url", "External URL of hunt")