Conversation
spitsfire
left a comment
There was a problem hiding this comment.
Great job, Xiomara! You did a great job separating out helper functions and helper methods! Most of your route return statements were very consistent, but there were a few that could be altered. Consistent returns in an API is key.
Your logic and routes were very clean and organized! Woo hoo!
| @@ -0,0 +1,102 @@ | |||
| from flask import Blueprint, jsonify, make_response, request | |||
| from requests import session | |||
There was a problem hiding this comment.
This session is not the same as db.session. They serve completely separate purposes, so we can get rid of this import completely
| from requests import session |
| # Create goal | ||
|
|
||
|
|
||
| @goal_bp.route("", methods=["POST"]) |
| for goal in goals: | ||
| goals_response.append(goal.to_json()) | ||
|
|
||
| return jsonify(goals_response), 200 |
There was a problem hiding this comment.
Try to stay consistent with your return statements here. Most of them are using make_response(jsonify()), so let's repeat that everywhere for predictability and consistency.
| return jsonify(goals_response), 200 | |
| return make_response(jsonify(goals_response), 200) |
| @goal_bp.route("/<id>", methods=["GET"]) | ||
| def get_one_goal(id): | ||
| goal = validate_goal(id) | ||
| return jsonify({"goal": goal.to_json()}), 200 |
There was a problem hiding this comment.
| return jsonify({"goal": goal.to_json()}), 200 | |
| return make_response(jsonify({"goal": goal.to_json()}), 200) |
| # Update goal | ||
|
|
||
|
|
||
| @goal_bp.route("/<id>", methods=["PUT"]) |
|
|
||
|
|
||
| # Get One Task: One Saved Task | ||
| @task_bp.route("/<id>", methods=["GET"]) |
|
|
||
| # Get Tasks | ||
|
|
||
| @task_bp.route("", methods=["POST", "GET"]) |
| def post_message_to_slack(task): | ||
| send_msg_path = "https://slack.com/api/chat.postMessage" | ||
| confirm_message = f"You completed the task {task.title}!" | ||
| query_params = { | ||
| "channel": "task-notifications", | ||
| "text": confirm_message | ||
| } | ||
| headers = { | ||
| "Authorization": os.environ.get("slack_token") | ||
| } | ||
| requests.post(send_msg_path, params=query_params, headers=headers) |
There was a problem hiding this comment.
Let's move this to the helpers.py file!
| # Mark Complete | ||
|
|
||
|
|
||
| @task_bp.route("/<id>/mark_complete", methods=["PATCH"]) |
|
|
||
|
|
||
| # Mark Incomplete | ||
| @task_bp.route("/<id>/mark_incomplete", methods=["PATCH"]) |
| goal = validate_goal(id) | ||
| request_body = request.get_json() | ||
|
|
||
| for id in request_body["id"]: |
There was a problem hiding this comment.
Here is where I think the last wave is failing. Double check what the correct key is in the tests! id is for the goal, not the list of tasks
Hey Claire, I'm still working on finishing wave 6 and deploying to Heroku. My VsCode crashed yesterday and was having technical difficulties