def currency_names(self): currencies = [] markets = Market.select() for market in markets: currencies.append(market.coin_name) currencies.append(market.coin_pair) return currencies
def get(self): user = User.select().where(User.id == int(self.current_user)).get() names = self.currency_names() # get user's portfolio based off of slug in url userMarkets = UserCurrency.select().where( UserCurrency.user_id == user.id) bitcoin = Currency.select().where( Currency.coin_pair == "USDT-BTC").get() # set bitcoin as variable in order to render the price on the index page. if not userMarkets: market = Market.select().join(Currency).where( Currency.coin_pair == "USDT-BTC").get() return self.render_template("dashboard.html", { "user": user, "market": market, "bitcoin": bitcoin, 'names': names }) return self.render_template( "dashboard.html", { "user": user, "bitcoin": bitcoin, "userMarkets": userMarkets, 'names': names })
def get(self): user = False if self.current_user: user = int(self.current_user) bitcoin = Currency.select().where(Currency.coin_pair == "USDT-BTC").get() # set bitcoin as variable in order to render the price on the index page. markets = Market.select().join(Currency).where(Currency.id == Market.currency_id).order_by(Currency.volume.desc()).limit(6) return self.render_template("index.html", {'markets': markets, "bitcoin": bitcoin, "user": user})
def post(self): userID = int(self.current_user) currencyName = self.get_body_argument("currencyName") market = Market.select().where((Market.coin_pair == currencyName) | (Market.coin_name == currencyName)).get() markets = UserCurrency.select().where(UserCurrency.market_id == market.id) if not markets: userCurr = UserCurrency.create(user_id=userID, market_id=market.id, currency_id=market.id) userCurr.save() elif markets: for user in markets: if user.user_id != userID: userCurr = UserCurrency.create(user_id=userID, market_id=market.id, currency_id=market.id) userCurr.save() return self.redirect("/dashboard")
def index(password): print >> sys.stderr, "within index" try: if password == PASSWORD: print >> sys.stderr, "within try" sellerList = Seller.select() smsList = SMS.select() numberList = Number.select() l = List.select() marketList = Market.select() lrList = ListRelationship.select() outboxList = Outbox.select() return render_template("index.html", title = 'TABLES', sellerList = sellerList, smsList = smsList, l = l, marketList = marketList) #return 'hello world' else: print >> sys.stderr, "wrong password" except: print >> sys.stderr, "within except" print >> sys.stderr, str(sys.exc_info()[0]) # These write the nature of the error print >> sys.stderr, str(sys.exc_info()[1]) statement = 'An exception has Occured'+ str(sys.exc_type) + '[' + str(sys.exc_value) + ']' return statement