Conversation
| migrate.init_app(app, db) | ||
|
|
||
| # Register Blueprints here | ||
| from .routes import tasks_bp |
There was a problem hiding this comment.
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.
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.
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"] |
| return {"details":"Invalid data"}, 400 | ||
|
|
||
| elif request.method == "GET": | ||
| request_title = request.args.get("title") |
There was a problem hiding this comment.
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.