Skip to content

Conversation

pje106
Copy link

@pje106 pje106 commented Nov 10, 2022

No description provided.

Copy link

@CheezItMan CheezItMan left a 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.

Comment on lines +18 to +19
@classmethod
def from_dict(cls, data_dict):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great helper method

Comment on lines +17 to +23
if "title" not in response_body or\
"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"],)

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.

Comment on lines +32 to +40
title_param = request.args.get("sort")

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()

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.

Comment on lines +102 to +112
PATH = "https://slack.com/api/chat.postMessage"

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})

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):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great helper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants