-
Notifications
You must be signed in to change notification settings - Fork 97
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
Nicole W of Maple #83
base: master
Are you sure you want to change the base?
Conversation
@@ -30,5 +30,7 @@ def create_app(test_config=None): | |||
migrate.init_app(app, db) | |||
|
|||
# Register Blueprints here | |||
from .routes import tasks_bp |
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.
Once you start implementing the goals you can import it here and register the blueprint
from .routes import tasks_bp | |
from .routes import tasks_bp, goals_bp |
task_id = db.Column(db.Integer, primary_key=True, autoincrement=True) | ||
title = db.Column(db.String) | ||
description = db.Column(db.String) | ||
completed_at = db.Column(db.DateTime, nullable=True) |
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.
to make a relationship with the goal model you will use db.relationship inside the goal model like this
tasks = db.relationship('Task', backref='goal', lazy=True)
response_body = { | ||
"task":{ | ||
"id": new_task.task_id, | ||
"title": new_task.title, | ||
"description": new_task.description, | ||
"is_complete": True if new_task.completed_at is not None 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.
your response body is being repeated a few times in your code. You can create a helper function that makes this response and then call that function or you can move it to your task model and create an instance method to call
request_body = request.get_json() | ||
task.title = request_body["title"] | ||
task.description = request_body["description"] | ||
# task.completed_at = request_body["completed_at"] |
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.
remove code you arent using anymore
return {"details":"Invalid data"}, 400 | ||
|
||
elif request.method == "GET": | ||
request_title = request.args.get("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.
to implement sorting you can do something similar to this:
sort_method = request.args.get('sort')
then create a conditional that says if the sort method equals "asc" then order_by asc and the same for descending
Honestly Nicole this was a good start to building out the project. Take what you did for tasks and do the same for goals. I added some comments on implementing goals, refactoring, and implementing sorting. Let me know if you have questions |
No description provided.