Skip to content

Commit

Permalink
Updated application.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jhustles committed Oct 1, 2020
1 parent 17899c3 commit d9b7bb0
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions application.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def index():
# stock['gainLoss'] = usd(float(stock['marketValue']) - float(stock['costBasis']))
portfolioBalances.append(stock)


if request.method == "GET":
return render_template("index.html",
username=userInfo['username'],
Expand All @@ -123,7 +122,6 @@ def quote():
currentSearchHistory = []
searchResultsHistory = []


results = db.execute("SELECT username, cash FROM users WHERE id = :user_id", user_id=userInfo['user_id']) #[0]["username"]
availableCash = results[0]["cash"]
tickerInput = request.form.get("tickerInput")
Expand Down Expand Up @@ -417,7 +415,6 @@ def history():
@app.route("/login", methods=["GET", "POST"])
def login():
"""Log user in"""

# Forget any user_id
session.clear()

Expand All @@ -438,7 +435,6 @@ def login():
return apology("must provide password", 403)

# Query database for username
# Original with cs50
rows = db.execute("SELECT * FROM users WHERE username = :username", username=username)


Expand Down Expand Up @@ -522,8 +518,7 @@ def register():
@app.route("/sellEstimator", methods=["GET", "POST"])
@login_required
def sellEstimator():
message = ""
#user_id=session["user_id"] # when user logs in with correct username and pw, it will pull the user-id from SQL db
#message=""
userCash = db.execute("SELECT username, cash FROM users WHERE id = :user_id", user_id=userInfo['user_id']) #[0]["username"]
availableCash = userCash[0]["cash"]
if request.method == "GET":
Expand All @@ -548,10 +543,7 @@ def sellEstimator():
return render_template("sell.html", availableCash=usd(availableCash), message="Portfolio is currently empty. No items to sell.")

else: # data is available in the database, then gather it first and setup data structure

# portfolioBalances = []
for i in range(len(portfolioSymbols)):
#marketValues.append(portfolioQuantities[i]*marketPrices[i])
stock = {}
stock['symbol'] = portfolioSymbols[i]
stock['name'] = cnames[i]
Expand All @@ -570,11 +562,10 @@ def sellEstimator():
return render_template("sell.html", username=portfolioBalances[-1]['username'], availableCash=usd(availableCash), items=portfolioBalances, current_datetime=current_datetime)

else: # if request.method == "POST":

# Need to be able to access these variables in the next page route /sell
global sellEstimatedTotal # will pass this into the buy function | will need to differentiate for buy / sell
global sellSharesInput

# option = request.form.get("option")
sellSymbol = request.form.get("sellSymbol").upper()
sellSharesInput = request.form.get("sellSharesInput")

Expand Down

0 comments on commit d9b7bb0

Please sign in to comment.