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

Rock - Nyckolle L. #52

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open

Rock - Nyckolle L. #52

wants to merge 28 commits into from

Conversation

NLucuab
Copy link

@NLucuab NLucuab commented May 13, 2021

No description provided.

Copy link

@spitsfire spitsfire left a comment

Choose a reason for hiding this comment

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

Heck yeah! Good job, Nyckolle! A couple things you could consider for future projects:

  1. For most of the request methods, you separated them out and gave them their own route decorator and function! Awesome. Think about doing that for the GET and POST methods, too. A function should do one thing and one thing only in practice.
  2. Try and make your return statements consistent. Everything can be returned using jsonify(), a dictionary, or make_response(). Any of these options work, some return "extra" headers and data we may/may not need, but it's good to pick just one. That way your endpoints will have consistency when making tests or being read by others!

title = db.Column(db.String)
tasks = db.relationship('Task', backref='goaltask', lazy=True)

def goal_json(self):

Choose a reason for hiding this comment

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

👍 love to see some helper methods!

goaltask_id = db.Column(db.Integer, db.ForeignKey('goal.goal_id'), nullable=True)

# creates a dictionary of key-value pairs describing the given task
def to_json(self):

Choose a reason for hiding this comment

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

👍

@@ -1,2 +1,328 @@
from flask import Blueprint
from flask import Blueprint, request, jsonify
from werkzeug.wrappers import PlainRequest

Choose a reason for hiding this comment

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

since we aren't using this anywhere, we can get rid of it

Suggested change
from werkzeug.wrappers import PlainRequest

from flask import Blueprint, request, jsonify
from werkzeug.wrappers import PlainRequest
from app import db
from flask.helpers import make_response

Choose a reason for hiding this comment

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

we can directly import this from flask above

Suggested change
from flask.helpers import make_response

@@ -1,2 +1,328 @@
from flask import Blueprint
from flask import Blueprint, request, jsonify

Choose a reason for hiding this comment

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

Suggested change
from flask import Blueprint, request, jsonify
from flask import Blueprint, request, jsonify, makes_response

Comment on lines +234 to +237
goal = Goal.query.get(goal_id)

if goal is None:
return make_response("", 404)

Choose a reason for hiding this comment

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

here we could use get_or_404(), too!

@goals_bp.route("/<goal_id>", methods=["PUT"], strict_slashes=False)
def update_goal(goal_id):

goal = Goal.query.get(goal_id)

Choose a reason for hiding this comment

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

here we could use get_or_404(), too!

Comment on lines +264 to +267
goal = Goal.query.get(goal_id)

if goal is None:
return make_response("", 404)

Choose a reason for hiding this comment

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

here we could use get_or_404(), too!

Comment on lines +282 to +286
goal = Goal.query.get(goal_id)

# if no goal with the provided goal_id, returns a 404 error
if not goal:
return make_response("", 404)

Choose a reason for hiding this comment

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

here we could use get_or_404(), too!

Comment on lines +305 to +311
goal = Goal.query.get(goal_id)
# sets task variable equal to the task with the corresponding goal (in foreignkey column)
task = Task.query.get(goal_id)

# if goal doesn't exist, return a 404 error
if not goal:
return make_response("", 404)

Choose a reason for hiding this comment

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

here we could use get_or_404(), too!

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