Skip to content

Module 2 Project Tasks PR#3

Merged
jaybee1971 merged 13 commits intomasterfrom
module_2
Aug 25, 2020
Merged

Module 2 Project Tasks PR#3
jaybee1971 merged 13 commits intomasterfrom
module_2

Conversation

@jaybee1971
Copy link
Copy Markdown
Owner

Please review.
If I get time this week I will try and add due dates, which is the only outstanding stretch goal (I think).
Also need to style the new description input form, as not great on UI, but it works.

@jaybee1971 jaybee1971 requested a review from Jonesey13 August 24, 2020 11:35
Copy link
Copy Markdown

@hugh-emerson hugh-emerson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, go ahead and merge when you're ready! 👍

See my comments for some suggestions. And if you like, you can still ask us for feedback on any further changes.

@@ -1,2 +1,19 @@
Flask==1.1.1
python-dotenv==0.12.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you deliberately remove python-dotenv?

It's required for flask-run to automatically read the .env file.

To get this app to work for you, you will need to have a Trello account and store the following variables in your .env file:
API_KEY - Your unique key for using the Trello API
API_TOKEN - Generate your own API token and store value here
BOARD_ID - The ID of the board you want to use for the project
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job updating the README. You could also add these vars with empty values to the .env.template file, which generates .env the first time you run setup.

Also it's worth mentioning that your app requires the board to have lists with the correct names.

trello_api.py Outdated
return trelloCards


def trelloPost(title, description):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to stick to the snake_case naming convention rather than camelCase. It's just python thing to use snake_case, but you should always be consistent and currently you're mixing cases.

Also, this function name isn't the clearest. It's not a generic function for making a POST request to Trello, it's specifically creating a new card.

# API_PARAMS was getting appended with additional parameters, so had to set variable in each API function
API_PARAMS = {'key': API_KEY, 'token': API_TOKEN}
board = os.getenv('BOARD_ID')
headers = {"Accept": "application/json"}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Accept header means what format you want the response to be in.

Since you're only using this for a PUT request, did you mean to set "Content-Type" instead? That specifies the format of your request body.

But I think Trello accepts and returns JSON by default.

trello_api.py Outdated
Comment on lines +9 to +10
# API_PARAMS was getting appended with additional parameters, so had to set variable in each API function
API_PARAMS = {'key': API_KEY, 'token': API_TOKEN}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you write postParams = API_PARAMS, you have two variables that are actually just different names for the same dictionary. They are pointing to the exact same object.

What you wanted was params = API_PARAMS.copy(), then you can delete all the duplicated API_PARAMS = ... lines

app.py Outdated
return redirect('/')


# old code for using session_items instead of Trello API
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should delete old code. It will live forever in Git.

If you really want, you can keep a note of the commit hash or a tag/branch name to look it up easily.

session_items.py Outdated
@@ -1,12 +1,11 @@
from flask import session
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should delete this file

trello_api.py Outdated
)
trelloLists.append(list_data)
if list_data.status == "Not Started":
session['newItemId'] = list_data.trelloId
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but it's a bit odd to store these values on the session. Cookies are for user specific data but this is constant for the instance of the app, as it's tied to the board that's in use.

It would make a bit more sense to either set some constants when the app starts up or you could even get the list ID each time you need it.

app.py Outdated
new_status = request.form.get(id)
if new_status == 'Delete':
session.delete_item(id)
for trelloId in request.form:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously this will slow down if there are many cards on the board as you're making a separate HTTP request for every single card whether or not its status needs to change.

You don't need to change this now, but just making sure you're aware.

@jaybee1971 jaybee1971 merged commit 70f9184 into master Aug 25, 2020
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