mirror of https://github.com/me50/kukemuna.git
automated commit by check50 [check50=True]
This commit is contained in:
parent
f12011707e
commit
b9530e6711
9
app.py
9
app.py
|
|
@ -68,7 +68,7 @@ def buy():
|
|||
return render_template("buy.html")
|
||||
else:
|
||||
symbol = request.form.get("symbol")
|
||||
shares = float(request.form.get("shares"))
|
||||
shares = request.form.get("shares")
|
||||
|
||||
if not symbol:
|
||||
return apology("Not Symbol")
|
||||
|
|
@ -78,7 +78,7 @@ def buy():
|
|||
if stock == None:
|
||||
return apology("Symbol not found")
|
||||
|
||||
if not shares == "":
|
||||
if shares:
|
||||
transaction_value = float(shares) * stock["price"]
|
||||
|
||||
user_id = session["user_id"]
|
||||
|
|
@ -95,9 +95,11 @@ def buy():
|
|||
date = datetime.datetime.now()
|
||||
|
||||
db.execute("INSERT INTO transactions (user_id, symbol, shares, price, date) VALUES (?, ?, ?, ?, ?)",
|
||||
user_id, stock["symbol"], shares, stock["price"], date)
|
||||
user_id, stock["symbol"], shares, stock["price"], date)
|
||||
|
||||
flash("Bought!")
|
||||
else:
|
||||
return apology("Missing shares", 400)
|
||||
|
||||
return redirect("/")
|
||||
# return apology("TODO")
|
||||
|
|
@ -208,7 +210,6 @@ def register():
|
|||
username_exists = db.execute("SELECT * FROM users WHERE username = ?", username)
|
||||
|
||||
if username_exists:
|
||||
flash("Username exists already!")
|
||||
return apology("username already exists!", 400)
|
||||
|
||||
db.execute("INSERT INTO users(username, hash) VALUES(?, ?)",
|
||||
|
|
|
|||
BIN
finance.db
BIN
finance.db
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -10,7 +10,7 @@
|
|||
<input class="form-control mx-auto w-auto" autocomplete="off" autofocus="" name="symbol" placeholder="Symbol" type="text">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<input class="form-control mx-auto w-auto" autocomplete="off" autofocus min="1" name="shares" placeholder="Shares" type="text">
|
||||
<input class="form-control mx-auto w-auto" autocomplete="off" autofocus min="1" name="shares" placeholder="Shares" type="number">
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit">Buy</button>
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Reference in New Issue