]> git.cworth.org Git - turbot/blob - turbot/views.py
Revamp the Home page of our app to start looking like what we want
[turbot] / turbot / views.py
1 def text(body):
2     return {
3         "text": {
4             "type": "mrkdwn",
5             "text": body
6         }
7     }
8
9 def section(block):
10     return {
11         "type": "section",
12         **block
13     }
14
15 def actions(*elements):
16     return {
17         "type": "actions",
18         "elements": list(elements)
19     }
20
21 def button(label):
22     return {
23         "type": "button",
24         "text": {
25             "type": "plain_text",
26             "text": label,
27             "emoji": True
28         }
29     }
30
31 def home(user_id, body):
32     """Returns a view to be published as the turbot home tab for user_id
33
34     The body argument is a dictionary as provided by the Slack request.
35     The return value is a dictionary suitable to be published to the
36     Slack views_publish API."""
37
38     return {
39         "type": "home",
40         "blocks": [
41             section(text("This is (or soon will be) a list of available puzzle hunts)")),
42             actions(button("New hunt"))
43         ]
44     }