def buy(): if request.method == 'GET': return render_template('dashboard.html') else: Ticker = request.form['Ticker'] Shares = int(request.form['Shares']) user_name = '%s' % escape(session['username']) #buy=model.buy(Ticker,Shares, user_name) info = model.dashboard(user_name) if request.form.get('inlineCheckbox1'): buy = model.buy(Ticker, Shares, user_name) info = model.dashboard(user_name) if buy: mes = buy['User'] + ' bought ' + str( buy['Shares'] ) + ' share(s) of ' + buy['Ticker'] + ' for ' + str( buy['Cost']) return render_template('dashboard.html', buy_info=mes, info=info) else: mes = "You don't have enough money" return render_template('dashboard.html', buy_info=mes, info=info) elif request.form.get('inlineCheckbox2'): sell = model.sell(Ticker, Shares, user_name) info = model.dashboard(user_name) if sell: message = sell['username'] + ' sold ' + str( sell['Shares'] ) + ' shares of ' + sell['Ticker'] + ' for ' + str( sell['Cost']) return render_template('dashboard.html', sell_info=message, info=info) else: message = "You don't have enough shares" return render_template('dashboard.html', sell_info=message, info=info) else: mes = "Click Buy or Sell box" return render_template('dashboard.html', buy_info=mes, info=info)
def dashboard(): if 'user_email' in session: monthlyRegistered, registered = model.dashboard() print registered return render_template('Dashboard.html', mR=monthlyRegistered, r=registered) else: return render_template('index.html')
def quote(): if request.method == 'GET': return render_template('dashboard.html') else: user_name = '%s' % escape(session['username']) quote = request.form['quote'] price = model.quote(quote) info = model.dashboard(user_name) if price: return render_template('dashboard.html', quote_info=quote + ': ' + str(price), info=info) else: return render_template('dashboard.html', quote_info='Could not find quote', info=info)
def lookup(): if request.method == 'GET': return render_template('dashboard.html') else: user_name = '%s' % escape(session['username']) info = model.dashboard(user_name) company = request.form['lookup'] ticker = model.lookup(company) if ticker: return render_template('dashboard.html', lookup_info=company + ': ' + ticker, info=info) else: return render_template('dashboard.html', lookup_info='Could not find Ticker for ' + company, info=info)
def deposit(): user_name = '%s' % escape(session['username']) if request.method == 'GET': return render_template('dashboard.html') else: try: deposit = int(request.form['deposit']) except: deposit = float(request.form['deposit']) money = model.deposit(user_name, deposit) info = model.dashboard(user_name) if money: return render_template('dashboard.html', deposit_info="Deposited: $" + str(deposit), info=info) else: return render_template('dashboard.html', deposit_info=money, info=info)
def sell(): if request.method == 'GET': return render_template('dashboard.html') else: Ticker = request.form['Ticker'] Shares = int(request.form['Shares']) user_name = '%s' % escape(session['username']) sell = model.sell(Ticker, Shares, user_name) info = model.dashboard(user_name) if sell: message = sell['username'] + ' sold ' + str( sell['Shares'] ) + ' shares of ' + sell['Ticker'] + ' for ' + str(sell['Cost']) return render_template('dashboard.html', sell_info=message, info=info) else: message = "You don't have enough shares" return render_template('dashboard.html', sell_info=message, info=info)
def dashboard(): if request.method == 'GET': user_name = '%s' % escape(session['username']) info = model.dashboard(user_name) return render_template('dashboard.html', info=info)
def get_dashboard(apikey): user_name = model.api_authenticate(apikey) if not user_name: return (jsonify({"error": "count not authenticate"})) return jsonify(model.dashboard(user_name))