Skip to content
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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Zoisite - Jasmin W. #114

wants to merge 16 commits into from

Conversation

JazzWo
Copy link

@JazzWo JazzWo commented May 12, 2023

No description provided.

Copy link

@apradoada apradoada left a 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

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"]

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

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)

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

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!




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

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

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

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

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!

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