-
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
Scissors - Ivana R #57
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.
SO AMAZING! It's clear you had so much fun with this project and that there was a lot of thoughtfulness in how this was implemented!
def to_json_format(self): | ||
task_to_json = { | ||
"id": self.task_id, | ||
"title": self.title, | ||
"description": self.description, | ||
"is_complete": True if self.completed_at is not None else False, | ||
} | ||
if self.goal is not None: | ||
task_to_json["goal_id"] = self.goal | ||
return task_to_json |
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.
Love this method!
tasks_bp = Blueprint("tasks", __name__, url_prefix="/tasks") | ||
goals_bp = Blueprint("goals", __name__, url_prefix="/goals") | ||
|
||
def err_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.
Nice little helper function :)
return jsonify({"task": single_task.to_json_format()}) | ||
|
||
|
||
def validate_field(field, dic): |
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.
SOOOO COOOL! This is honestly another level of developer thinking, to abstract out the very idea of validation into one function like this!
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 could be taken even one step further by allowing an optional 3rd param for expected_type, which the function could use to verify that the type of the field is the type that's expected.
ongoing_task.completed_at = datetime.utcnow() | ||
db.session.commit() | ||
|
||
glados = GLaDOS() |
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.
Glados! Love it!
import os | ||
import requests | ||
|
||
class GLaDOS(): |
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.
Oh my god this is my new favorite program OF ALL TIME!!!! :D
def add_task_response_to_json(self): | ||
|
||
return { | ||
"id": self.goal_id, | ||
"task_ids": [t.task_id for t in self.tasks] | ||
} |
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.
So succinct!
No description provided.