Skip to content

Nicole W of Maple#83

Open
N-Washington wants to merge 1 commit intoAda-C16:masterfrom
N-Washington:master
Open

Nicole W of Maple#83
N-Washington wants to merge 1 commit intoAda-C16:masterfrom
N-Washington:master

Conversation

@N-Washington
Copy link

No description provided.

migrate.init_app(app, db)

# Register Blueprints here
from .routes import tasks_bp
Copy link

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

Suggested change
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)
Copy link

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)

Comment on lines +20 to +26
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
}
Copy link

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"]
Copy link

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")
Copy link

@tgoslee tgoslee Nov 14, 2021

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

@tgoslee
Copy link

tgoslee commented Nov 14, 2021

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

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