Skip to content

Conversation

ivystrayed
Copy link

No description provided.

…nd incomplete, added a function in routes which takes in both task number and complete/incomplete as variable and routes to helper functions
… need to DRY and finish up the conversion from task to goal
…hon files and created a helper function for routes to validate the models to eliminate redundency in task and goal models
Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Violet, you hit the learning goals here. I left some minor comments in the code. If you have questions let me know via Slack.

Comment on lines +31 to +35
if sort_query:
sort_function = getattr(sqlalchemy, sort_query)
goal_list = Goal.query.order_by(sort_function(Goal.title))
else:
goal_list = Goal.query.all()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clever, nice!

Comment on lines +43 to +44
@goal_bp.route("random", methods=["GET"])
def get_random_goal():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting route!

Comment on lines +31 to +32
@classmethod
def from_dict(cls, request_body):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great helper method




def validate_model_id(cls, id):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice helper function. It would be good to have another to validate required fields in the request body.

Comment on lines +62 to +63
task.title = request_body["title"]
task.description = request_body["description"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No data validation here?

Comment on lines +18 to +19
request_body = request.get_json()
new_task = Task.from_dict(request_body)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't seem to be any validation to check to see if the request body has a title or description.

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