-
Notifications
You must be signed in to change notification settings - Fork 146
Lions-Juila #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Lions-Juila #120
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work Julia, you hit the learning goals here. I left some minor comments in the code here. Take a look and if you have any questions please ping me in Slack.
@classmethod | ||
def from_dict(cls, data_dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great helper method
"description" not in response_body: | ||
# “is_complete” not in respnse_body | ||
return jsonify({"details": "Invalid data"}), 400 | ||
new_task = Task( | ||
title = response_body["title"], | ||
description = response_body["description"],) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good validation, but you should indicate what data is invalid.
|
||
if title_param == "asc": | ||
tasks = Task.query.order_by(Task.title.asc()) | ||
|
||
elif title_param == "desc": | ||
tasks = Task.query.order_by(Task.title.desc()) | ||
else: | ||
tasks = Task.query.all() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of query params.
|
||
SLACKBOT_TOKEN = os.environ.get("SLACKBOT_TOKEN") | ||
|
||
query_params = { | ||
"token": SLACKBOT_TOKEN, | ||
"channel": "task-notifications", | ||
"text": f"Someone just completed the task {task.title}" | ||
} | ||
|
||
requests.post(url=PATH, data=query_params, headers={"Authorization": SLACKBOT_TOKEN}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The slack portion here should probably be in a helper function.
@@ -0,0 +1,13 @@ | |||
from flask import jsonify, abort, make_response | |||
|
|||
def get_one_obj_or_abort(cls, obj_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great helper
No description provided.