Conversation
kaidamasaki
left a comment
There was a problem hiding this comment.
Well done!
I left a few minor notes but your code looks really good overall! Congrats!
PS: Great job committing regularly!
| if not self.completed_at: | ||
| is_complete = False | ||
| else: | ||
| is_complete = True |
There was a problem hiding this comment.
I think you probably meant to clean this up since the code below (line 20) handles this on its own.
| # if not self.completed_at: | ||
| # is_complete = False | ||
| # else: | ||
| # is_complete = True | ||
|
|
There was a problem hiding this comment.
Style: It's good practice to clean up commented out code.
| goals_bp = Blueprint("goals", __name__, url_prefix="/goals") | ||
|
|
||
| #----------------- | ||
| #HELPER FUNCTIONS |
| request_body = request.get_json() | ||
|
|
||
| if "title" not in request_body or "description" not in request_body or "completed_at" not in request_body: | ||
| return make_response(jsonify({"details" : "Invalid data"}), 400) |
There was a problem hiding this comment.
If you're returning a dictionary you don't need to call jsonify or make_response Flask's default return behavior will work just fine.
| return make_response(jsonify({"details" : "Invalid data"}), 400) | |
| return {"details" : "Invalid data"}, 400 |
When you return a dictionary Flask automatically makes a JSON response. (This isn't true for a list which is why we need jsonify sometimes.)
| if completion_status == "mark_incomplete": | ||
| task.completed_at = None | ||
|
|
||
| #task_dict["task"] = task.to_dict() |
There was a problem hiding this comment.
You didn't commit before turning from here.
Things will look right in your response but won't be saved between requests.
No description provided.