Skip to content

Commit ed39975

Browse files
committed
add gifs for commands
1 parent 70cdb03 commit ed39975

6 files changed

+46
-40
lines changed

app.py

+46-40
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,41 @@
2525
Config.SLACK_SIGNING_SECRET, "/slack/events", app
2626
)
2727

28+
2829
@app.route('/slack/interactive-endpoint', methods=['POST'])
2930
def interactive_endpoint():
30-
payload = json.loads(request.form.get('payload'))
31-
if payload["type"] == "block_actions":
32-
actions = payload["actions"]
33-
if len(actions) > 0:
34-
if actions[0]["action_id"] == "create_action_button":
35-
# Create Task - button was clicked
36-
channel_id = payload["container"]["channel_id"]
37-
user_id = payload["user"]["id"]
38-
helper = ErrorHelper()
39-
ct = CreateTask()
40-
state_values = payload["state"]["values"]
41-
desc = None
42-
deadline = None
43-
points = None
44-
for _,val in state_values.items():
45-
if "create_action_description" in val:
46-
desc = val["create_action_description"]["value"]
47-
elif "create_action_deadline" in val:
48-
deadline = val["create_action_deadline"]["selected_date"]
49-
elif "create_action_points" in val:
50-
points = val["create_action_points"]["selected_option"]["value"]
51-
if desc is None or deadline is None or points is None:
52-
error_blocks = helper.get_error_payload("createtask")
53-
slack_client.chat_postEphemeral(channel=channel_id, user=user_id, blocks=error_blocks)
54-
else:
55-
blocks = ct.create_task(desc=desc, points=points, deadline=deadline)
56-
slack_client.chat_postEphemeral(channel=channel_id, user=user_id, blocks=blocks)
57-
return make_response("", 200)
31+
payload = json.loads(request.form.get('payload'))
32+
if payload["type"] == "block_actions":
33+
actions = payload["actions"]
34+
if len(actions) > 0:
35+
if actions[0]["action_id"] == "create_action_button":
36+
# Create Task - button was clicked
37+
channel_id = payload["container"]["channel_id"]
38+
user_id = payload["user"]["id"]
39+
helper = ErrorHelper()
40+
ct = CreateTask()
41+
state_values = payload["state"]["values"]
42+
desc = None
43+
deadline = None
44+
points = None
45+
for _, val in state_values.items():
46+
if "create_action_description" in val:
47+
desc = val["create_action_description"]["value"]
48+
elif "create_action_deadline" in val:
49+
deadline = val["create_action_deadline"]["selected_date"]
50+
elif "create_action_points" in val:
51+
points = val["create_action_points"]["selected_option"]["value"]
52+
if desc is None or deadline is None or points is None:
53+
error_blocks = helper.get_error_payload("createtask")
54+
slack_client.chat_postEphemeral(
55+
channel=channel_id, user=user_id, blocks=error_blocks)
56+
else:
57+
blocks = ct.create_task(
58+
desc=desc, points=points, deadline=deadline)
59+
slack_client.chat_postEphemeral(
60+
channel=channel_id, user=user_id, blocks=blocks)
61+
return make_response("", 200)
62+
5863

5964
@app.route('/')
6065
def basic():
@@ -90,25 +95,26 @@ def vcompleted():
9095
@app.route('/taskdone', methods=["POST"])
9196
def taskdone():
9297
data = request.form
98+
print("data: ", data)
9399
td = TaskDone(data)
94100
payload = td.update_points()
95101
return jsonify(payload)
96102

97103

98104
@app.route('/create', methods=["POST"])
99105
def create():
100-
ct = CreateTask()
101-
blocks = ct.create_task_input_blocks()
106+
ct = CreateTask()
107+
blocks = ct.create_task_input_blocks()
108+
data = request.form
109+
channel_id = data.get('channel_id')
110+
user_id = data.get('user_id')
111+
slack_client.chat_postEphemeral(
112+
channel=channel_id,
113+
user=user_id,
114+
blocks=blocks
115+
)
102116

103-
data = request.form
104-
channel_id = data.get("channel_id")
105-
user_id = data.get("user_id")
106-
slack_client.chat_postEphemeral(
107-
channel=channel_id,
108-
user=user_id,
109-
blocks=blocks
110-
)
111-
return Response(), 200
117+
return Response(), 200
112118

113119

114120
@app.route('/help', methods=["POST"])
@@ -126,4 +132,4 @@ def leaderboard():
126132

127133

128134
if __name__ == '__main__':
129-
app.run(host="localhost", port=8000, debug=True)
135+
app.run(host="localhost", port=8000, debug=True)

gifs/create-task.gif

609 KB
Loading

gifs/leaderboard.gif

298 KB
Loading

gifs/taskdone.gif

301 KB
Loading

gifs/viewcompleted.gif

341 KB
Loading

gifs/viewpending.gif

305 KB
Loading

0 commit comments

Comments
 (0)