-
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
Paper-Ruthie Newman #71
base: master
Are you sure you want to change the base?
Changes from all commits
910c4c0
017dee1
0127839
ae62c5c
bf142cb
fc8b18e
48a601a
6e7565f
e2ca8c7
03c82fb
d4f8cf9
a3a4726
53b33d7
9186041
5b1097a
802e2ec
9a89ccd
4a12975
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: gunicorn 'app:create_app()' |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,6 +1,48 @@ | ||||||||
from flask import current_app | ||||||||
from app import db | ||||||||
from flask import Blueprint | ||||||||
|
||||||||
|
||||||||
class Task(db.Model): | ||||||||
task_id = db.Column(db.Integer, primary_key=True) | ||||||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True) | ||||||||
title = db.Column(db.String(50)) | ||||||||
description = db.Column(db.String(50)) | ||||||||
completed_at = db.Column(db.DateTime, nullable=True) | ||||||||
goal_id = db.Column(db.Integer, db.ForeignKey("goal.id"), nullable=True) | ||||||||
|
||||||||
|
||||||||
def create_json(self): | ||||||||
if self.completed_at == None: | ||||||||
completed = False | ||||||||
else: | ||||||||
completed = True | ||||||||
|
||||||||
return { | ||||||||
'id' : self.id, | ||||||||
'title' : self.title, | ||||||||
'description' : self.description, | ||||||||
'is_complete' : completed | ||||||||
} | ||||||||
|
||||||||
def create_json_with_goal_id(self): | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could make this helper a part of the above |
||||||||
if self.completed_at == None: | ||||||||
completed = False | ||||||||
else: | ||||||||
completed = True | ||||||||
|
||||||||
return { | ||||||||
'id' : self.id, | ||||||||
'goal_id' : self.goal_id, | ||||||||
'title' : self.title, | ||||||||
'description' : self.description, | ||||||||
'is_complete' : completed | ||||||||
} | ||||||||
|
||||||||
def from_json(request_dict): | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similarly I suggest making it a class method. This way you don't have to make an instance of Task before getting a new instance.
Suggested change
|
||||||||
new_task = Task( | ||||||||
title = request_dict["title"], | ||||||||
description = request_dict["description"], | ||||||||
completed_at = request_dict["completed_at"] | ||||||||
) | ||||||||
|
||||||||
return new_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.
Since this method creates a new Goal, I suggest making it a class method