-
Notifications
You must be signed in to change notification settings - Fork 15
Accelerate -Cadence #1
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?
Conversation
if goal is None: | ||
return make_response("",404) | ||
if request.method == "GET": | ||
if goal is not None: |
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.
you don't need this line again because you already did the check
if goal is not None: | |
}) | ||
return make_response(jsonify(goal_reponse),200) | ||
|
||
else: |
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.
want to make sure request.mthod == 'POST
here
else: | |
elif request.method == 'POST': |
goal_reponse=[] | ||
goals = Goal.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.
move these after if request.method == 'GET':
if request.method == "GET": | ||
|
||
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.
def is_complete(completed_at): | ||
|
||
if completed_at is None: | ||
return False | ||
else: | ||
return True |
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 use of helper functions
delete_id_response= f'Goal {goal_id} "{goal.title}" successfully deleted' | ||
return make_response(jsonify({"details":delete_id_response})) | ||
|
||
# @goals_bp.route('<goal_id>/tasks', methods=["GET", "POST"]) |
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.
To get tests passing for Wave 6 go ahead and implement what you started. Go back and look at the video if you need help with the implementation https://adaacademy.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=0e99645b-d46b-4e64-b5fe-ad48012e1e3e
if request.method == "POST": | ||
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({ | ||
"details": "Invalid data" | ||
}, 400) | ||
else: | ||
new_task = Task(title=request_body["title"], description=request_body["description"], completed_at=request_body["completed_at"]) | ||
db.session.add(new_task) | ||
db.session.commit() | ||
return make_response( | ||
{ "task": { | ||
"id": new_task.task_id, | ||
"title": new_task.title, | ||
"description": new_task.description, | ||
"is_complete": is_complete(new_task.completed_at) | ||
}}, 201) |
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.
💃🏽
data_response = { | ||
"task": { | ||
"id": task.task_id, | ||
"title": task.title, | ||
"description": task.description, | ||
"is_complete": True | ||
} | ||
} |
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.
💃🏽
if task.completed_at is None : | ||
return make_response(jsonify(data_response),200) | ||
|
||
task.completed_at = None |
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.
I would move this to line 156
if task.completed_at is None : | ||
return make_response(jsonify(data_response),200) |
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.
you do not need this check here
No description provided.