reading the specification of 'buy' for pset7, which says the following:
buy Complete the implementation of buy in such a way that it enables a user to buy stocks.
Require that a user input a stock’s symbol, implemented as a text field whose name is symbol. Render an apology if the input is blank or the symbol does not exist (as per the return value of lookup).
Require that a user input a number of shares, implemented as a text field whose name is shares. Render an apology if the input is not a positive integer.
Submit the user’s input via POST to /buy.
Odds are you’ll want to call lookup to look up a stock’s current price.
Odds are you’ll want to SELECT how much cash the user currently has in users.
Add one or more new tables to finance.db via which to keep track of the purchase. Store enough information so that you know who bought what at what price and when.
Use appropriate SQLite types.
Define UNIQUE indexes on any fields that should be unique.
Define (non-UNIQUE) indexes on any fields via which you will search (as via SELECT with WHERE).
Render an apology, without completing a purchase, if the user cannot afford the number of shares at the current price.
You don’t need to worry about race conditions (or use transactions).
Once you’ve implemented buy correctly, you should be able to see users' purchases in your new table(s) via phpLiteAdmin or sqlite3.
There is nothing in the spec saying to output the purchase price to the user. So that's fine, check50 tells me I should be doing that. So I added another html page "bought.html" and pass it in the sale price (price per share * number of shares) via render_template, which is returned from my buy function after a successful purchase. I've test this and it works. However, I am still failing this check. To further complicate things, it is working for 1 of the stocks (it successfully finds the value "112.00"), but apparently not another. Check50 doesn't tell me what input is being used when the check is failed (what stock symbol/number of shares being bought), which would be helpful for my own debugging.
:( buy handles valid purchase expected to find "9,888.00" in page, but it wasn't found
Log sending POST request to /login sending POST request to /buy
checking that "112.00" is in page
checking that "9,888.00" is in page
[code snipped to avoid spoilers]