-
Notifications
You must be signed in to change notification settings - Fork 146
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
Lion - Miranda #123
base: master
Are you sure you want to change the base?
Lion - Miranda #123
Conversation
… completed_at type and value
…ute to Getting Tasks of One Goal
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.
Nice work Miranda, you hit the learning goals here. Well done. I left some minor comments in the code. Let me know if you have questions via slack.
if "title" not in response_body: | ||
return jsonify({"details": "Invalid data"}), 400 |
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.
It's good that you're doing data validation, but you should probably indicate what data is invalid.
@goal_bp.route("", methods=["GET"]) | ||
def read_goal(): | ||
goals = Goal.query.all() | ||
response = [goal.return_body() for goal in goals] |
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.
Nice use of a list comprehension.
@classmethod | ||
def from_dict(cls, data_dict): | ||
if "title" in data_dict: | ||
new_obj = cls(title=data_dict["title"]) | ||
return new_obj | ||
|
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 a class-method as a helper.
PATH = "https://slack.com/api/chat.postMessage" | ||
|
||
SLACKBOT_TOKEN = os.environ.get("SLACKBOT_TOKEN") | ||
|
||
# the query parameters come from the | ||
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 of this method might do well as a helper function.
No description provided.