-
Notifications
You must be signed in to change notification settings - Fork 0
Grocery store orders page hw #10
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
base: flask_login_and_templates
Are you sure you want to change the base?
Conversation
Wrote make login manager
login/logout system works perfect, relations added to models
populate orders
| USERS_DIR = os.path.join(FIXTURES_DIR, "users.csv") | ||
| GOODS_DIR = os.path.join(FIXTURES_DIR, "goods.csv") | ||
| STORES_DIR = os.path.join(FIXTURES_DIR, "stores.csv") | ||
| USERS_FILENAME = os.path.join(FIXTURES_DIR, "users.csv") |
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.
it is actually PATH, not FILENAME
|
|
||
| def get_goods(): | ||
| with open(GOODS_DIR, "r") as f: | ||
| with open(GOODS_FILENAME, "r") as f: |
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.
it would be great if you handled all the possible exceptions
|
|
||
| class PopulateOrders(Command): | ||
| def run(self): | ||
| from grocery_store import app, db |
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.
do not make local imports
| "order_price": sum([good.good.price for good in order.order_lines]), | ||
| "order_goods": {good.good.name: good.good.price for good in order.order_lines} | ||
| } | ||
| orders_list.append(order_data) |
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 can use here list comprehensions
and would be great if you use NamedTuple instead of dict (It is a great opportunity to get familiar with)
| Sign Up | ||
| </a> | ||
| {% endif %} | ||
| {% if current_user.is_authenticated %} |
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.
too many checks if the user is authenticated
Try to check it one time
No description provided.