-
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
Cedar - Jessica - Task List #74
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.
Great job!
I left a few little comments on tweaks you could make but overall everything looked really good! Well done!
token = os.environ.get('SLACK_TOKEN') | ||
CHANNEL_ID = "C02KD4B5A07" | ||
|
||
Headers = {"Authorization": "Bearer xoxb-" + token} |
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 line causes a failure if the SLACK_TOKEN
doesn't exist in the environment (which is why the automated tests fail).
It's perfectly reasonable to assume you will have a key (and the tests pass if given the token of token
so would work if the token was expired) this was just a quirk of our Learn setup.
If you wanted to fix the test failures you could use interpolation to do this instead:
Headers = {"Authorization": "Bearer xoxb-" + token} | |
Headers = {"Authorization": f"Bearer xoxb-{token}"} |
Again, this isn't a bug, just a quirk of our Learn setup.
It's just the kind of thing where I would want to know why it failed on Learn and not on my local machine.
@@ -1,6 +1,30 @@ | |||
from re import T |
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.
You're the second person I've seen import this but I'm not sure what effect it actually has (it doesn't seem explicitly referenced).
I'm curious, why the import?
def get_goal_from_id(goal_id): | ||
valid_int(goal_id, "goal_id") | ||
return Goal.query.get_or_404(goal_id, description="{goal not found}") |
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 get_or_404
returns HTML and not JSON by default you might want like this instead:
def get_goal_from_id(goal_id): | |
valid_int(goal_id, "goal_id") | |
return Goal.query.get_or_404(goal_id, description="{goal not found}") | |
def get_goal_from_id(goal_id): | |
valid_int(goal_id, "goal_id") | |
goal = Goal.query.get(goal_id) | |
if goal: | |
return goal | |
else: | |
abort(make_response({"description": "goal not found"}, 404)) |
db.session.delete(goal) | ||
db.session.commit() | ||
|
||
return make_response({"details": f"Goal {goal.goal_id} \"{goal.title}\" successfully deleted"}, 200) |
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 is a really good message! Very clear. 😄
task.goal_id = goal_id | ||
db.session.commit() | ||
response_body = { | ||
"id": int(goal_id), |
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.
Remember, if goal_id
is invalid this will cause an exception.
It may be worth using your valid_int
helper here.
No description provided.