-
Notifications
You must be signed in to change notification settings - Fork 111
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
Sea Turtles - Nina G. #117
base: master
Are you sure you want to change the base?
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.
Overall great job Nina! Your code was concise and well-organized. I left a few comments on things you did well and a few suggestions. Let me know if you have questions.
@@ -30,5 +28,10 @@ def create_app(test_config=None): | |||
migrate.init_app(app, db) | |||
|
|||
# Register Blueprints here | |||
from .task_routes import task_bp |
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 idea to create two seperate files for goals and tasks
"is_complete": bool(self.completed_at) | ||
} | ||
|
||
if self.goal_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 way to handle the optional attribute
title = db.Column(db.String, nullable=False) | ||
tasks = db.relationship("Task", back_populates="goal") | ||
|
||
def to_dict(self): |
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.
looks good!
try: | ||
new_goal = Goal(title=request_body["title"]) | ||
except KeyError: | ||
error_message(f"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.
I would suggest adding explicit messaging for the user to help them understand what's missing in their request
error_message("Invalid data: title is missing", 400)
db.session.delete(goal) | ||
db.session.commit() | ||
|
||
return make_response(jsonify(dict(details=f'Goal {goal.goal_id} "{goal.title}" successfully deleted'))), 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.
great informative message here!
from .models.goal import Goal | ||
import requests, os | ||
|
||
def error_message(message, status_code): |
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 helper functions look good! I also like that you put them in a separate file.
new_task = Task(title=request_body["title"], | ||
description=request_body["description"]) | ||
except KeyError: | ||
error_message(f"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.
Same suggestion as above about adding a more descriptive message for the user.
# ***************************************************************** | ||
# **Complete test with assertion about response body*************** | ||
# ***************************************************************** | ||
assert response_body == {"details": "task 1 not found"} |
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 make sure we are checking all of the data you can confirm that the database has no records, or that there is no record in the database with the ID of 1
No description provided.