-
Notifications
You must be signed in to change notification settings - Fork 71
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 - BRITTANY C. #54
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.
This looks very nice, Brittany! Some things you could consider for a future project is that functions should only do one thing. That means we could separate out each request method into its own route decorator and function, too.
Also, keep blank lines to a minimum. Sometimes spacing out chunks of code will help, but doing it too much can make it hard to read!
from dotenv import load_dotenv | ||
import datetime |
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.
since you aren't using datetime in this file, we don't need to import it. also, are you calling load_dotenv anywhere? were your environment variables able to load without it?
from dotenv import load_dotenv | |
import datetime | |
from dotenv import load_dotenv | |
load_dotenv() |
@@ -1,6 +1,33 @@ | |||
from types import new_class |
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.
is this being used?
from types import new_class |
from flask import current_app | ||
from app import db | ||
from app.models.task import Task |
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.
from app.models.task import Task |
"title": self.title | ||
} | ||
|
||
def goal_json_object_with_tasks(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.
👍 great helper method!
@@ -1,6 +1,32 @@ | |||
from flask import current_app | |||
from app import db | |||
|
|||
from datetime import datetime |
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.
from datetime import datetime |
task = Task.query.get(task_id) | ||
|
||
if task is None: | ||
return jsonify(None), 404 |
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.
here we could use get_or_404()
method, too!
|
||
if request.method == "PATCH": | ||
|
||
task = Task.query.get(task_id) | ||
|
||
if task is None: | ||
return jsonify(None), 404 | ||
|
||
task.completed_at = None | ||
|
||
return jsonify({"task":task.json_object()}),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.
careful with adding too many blank lines! it can make code harder to read
if request.method == "PATCH": | |
task = Task.query.get(task_id) | |
if task is None: | |
return jsonify(None), 404 | |
task.completed_at = None | |
return jsonify({"task":task.json_object()}),200 | |
if request.method == "PATCH": | |
task = Task.query.get(task_id) | |
if task is None: | |
return jsonify(None), 404 | |
task.completed_at = None | |
return jsonify({"task":task.json_object()}),200 |
goal = Goal.query.get(goal_id) | ||
|
||
if goal is None: | ||
return jsonify(None), 404 |
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.
here we could use get_or_404()
method, too!
def goals_task(goal_id): | ||
|
||
form_data = request.get_json() | ||
|
||
for task_id in form_data["task_ids"]: | ||
|
||
task = Task.query.get(task_id) | ||
|
||
task.goal_id = goal_id | ||
|
||
db.session.commit() | ||
|
||
return make_response({"id": int(goal_id),"task_ids":form_data["task_ids"]}), 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.
try not to use so many blank lines
goal = Goal.query.get(goal_id) | ||
if goal is None: | ||
return make_response("", 404) |
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.
here we could use get_or_404()
method, too!
No description provided.