-
Notifications
You must be signed in to change notification settings - Fork 128
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
Zoisite - Jasmin W. #114
base: main
Are you sure you want to change the base?
Zoisite - Jasmin W. #114
Conversation
create helper funtion & pass all get tests
pass wave2 tests
create patch_complete & patch_incomplete class methods & pass all wav…
pass all wave 6 tests after add_tasks_to_goal & get_tasks_from_goal m…
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.
This project looks so good, Jasmin! You should be very proud! I've added just a few comments to streamline things, but really well done!
goal = Goal.query.get(id) | ||
if not goal: | ||
abort(make_response({"message":f"id {id} not found!"}, 404)) | ||
return 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.
Keep in mind that these are two very similar methods! I wonder if there is a way to combine the two into one! Great job separating it into its own helper file though!
|
||
#update function for title | ||
def update(self, request_body): | ||
self.title=request_body["title"] |
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 love this method! I'm excited to see how you use it!
|
||
#create function for title | ||
@classmethod | ||
def create(cls, request_body): |
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.
Just for consistency's sake, it's a good idea to use a method name that is closer to from_dict to mirror our to_dict method!
task_id = db.Column(db.Integer, primary_key=True, autoincrement=True ) | ||
title = db.Column(db.String, nullable=False) | ||
description = db.Column(db.String, nullable=False) | ||
completed_at = db.Column(db.DateTime, nullable=True, default=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.
In this situation, the default for nullable is True, so we do not have to specify that particular constraint! Similarly, when nullable is set to True, the default for default is None, so that also doesn't need to be specified!
goals_id = db.Column(db.Integer, db.ForeignKey("goal.goal_id")) | ||
|
||
def to_dict(self): | ||
is_complete=True if self.completed_at else False |
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.
Well done with this specification!
|
||
|
||
|
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.
Don't forget to remove some of this extraneous space before submitting a pull request!
goals_response = [] | ||
for goal in goals: | ||
goals_response.append(goal.to_dict()) |
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.
Don't forget we can use list comprehensions here!
db.session.add(new_goal) | ||
db.session.commit() | ||
return jsonify({"goal":new_goal.to_dict()}), 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.
Great job with error handling again!
goal.update(request_body) | ||
db.session.commit() | ||
return jsonify({"goal":goal.to_dict()}), 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.
Don't forget your error handling here!
goal.patch_complete() | ||
db.session.commit() | ||
return jsonify({"goal":goal.to_dict()}), 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.
And more error handling here!
No description provided.