def new_alert(): if session['email']: moneydict, position = Money.search_data() if request.method == 'POST': input_currency = request.form['input_currency'] rate_exchange = request.form['rate_exchange'] bank_buy = request.form['bank_buy'] bank_sale = request.form['bank_sale'] result = All_alert.create_alert(session['email'], input_currency, rate_exchange, [bank_buy, bank_sale]) if result is True: message = "Your notification setting is created successfully!" currency_msg = "幣別: {}".format(input_currency) exchange_msg = "匯率: {}".format("現金匯率" if rate_exchange == "cash" else "即期匯率") buy_msg = "銀行買入通知價格: ${}".format(bank_buy) sale_msg = "銀行賣出通知價格: ${}".format(bank_sale) return render_template("new_alert.html", moneydict=moneydict, message=message, currency_msg=currency_msg, exchange_msg=exchange_msg, buy_msg=buy_msg, sale_msg=sale_msg) else: message = "You alread created the notification. (每個幣別只能對應兩種匯率)Please add a new one!" currency_msg = "幣別: {}".format(input_currency) exchange_msg = "匯率: {}".format("現金匯率" if rate_exchange == "cash" else "即期匯率") buy_msg = "銀行買入通知價格: ${}".format(bank_buy) sale_msg = "銀行賣出通知價格: ${}".format(bank_sale) return render_template("new_alert.html", moneydict=moneydict, message=message, currency_msg=currency_msg, exchange_msg=exchange_msg, buy_msg=buy_msg, sale_msg=sale_msg) else: return render_template("new_alert.html", moneydict=moneydict) else: return redirect("/login")
def home(): """ 页面:显示汇率主页 :return: """ moneys_dict = Money.get_data() # 使用home页面进行背景页面 return render_template("home.html", moneys_dict=moneys_dict)
def new_alert(): if session['email']: money_dict, positon = Money.search_data() if request.method == 'POST': input_currency = request.form['input_currency'] rate_exchange = request.form['rate_exchange'] bank_buy = request.form['bank_buy'] bank_sale = request.form['bank_sale'] result = All_alert.create_alert(session['email'], input_currency, rate_exchange, [bank_buy, bank_sale]) if result: message = "您的通知已经设置成功,可继续新增!" currency_msg = f"币别:{input_currency}" exchange_msg = "汇率:{}".format("现金汇率" if rate_exchange == "cash" else "即期汇率") buy_msg = f"银行买入通知价格:¥{bank_buy}" sale_msg = f"银行卖出通知价格:¥{bank_sale}" return render_template("new_alert.html", money_dict=money_dict, message=message, currency_msg=currency_msg, exchange_msg=exchange_msg, buy_msg=buy_msg, sale_msg=sale_msg) else: message = "您的通知新增失败,每个币种只能新增两种通知,请重新新增!" currency_msg = f"币别:{input_currency}" exchange_msg = "汇率:{}".format("现金汇率" if rate_exchange == "cash" else "即期汇率") buy_msg = f"银行买入通知价格:¥{bank_buy}" sale_msg = f"银行卖出通知价格:¥{bank_sale}" return render_template("new_alert.html", money_dict=money_dict, message=message, currency_msg=currency_msg, exchange_msg=exchange_msg, buy_msg=buy_msg, sale_msg=sale_msg) else: return render_template("new_alert.html", money_dict=money_dict) else: return redirect('/login')
def new_alert(): """ 页面:监听新的货币 :return: """ if session['email']: money_dict = Money.get_data() if request.method == 'POST': # 接受表单信息 Input_current = request.form["Input_current"] rate_kind = request.form["rate_kind"] buy_price = request.form["buy_price"] sell_price = request.form["sell_price"] result = Alert.create_alert(email=session['email'], current=Input_current, rate_kind=rate_kind, price=[buy_price, sell_price]) if result is True: # 创造item成功.返回创建信息 message = "新的货币监听已经创建成功!" current_msg = "货币:{}".format(Input_current) rate_kind_msg = "汇率类型:{}".format("现钞" if rate_kind == "cash" else "现汇") buy_price_msg = "买入价格:¥ {}".format(buy_price) sell_price_msg = "卖出价格:¥ {}".format(sell_price) return render_template("create_alert.html", money_dict=money_dict, message=message, current_msg=current_msg, rate_kind_msg=rate_kind_msg, buy_price_msg=buy_price_msg, sell_price_msg=sell_price_msg) else: # 创造item失败 message = "创建失败:该货币已被您加入监听!" return render_template("create_alert.html", money_dict=money_dict, message=message) else: # 在登录状态下直接get,则返回创建页面 return render_template("create_alert.html", money_dict=money_dict) else: # 没有登录信息,返回login页面 return redirect("/login")
''' Pretty much the entirety of the game's runtime will be spent inside this while loop ''' while not self.done: dt = self.clock.tick(self.fps) self.event_loop() self.update(dt) self.draw() pg.display.update() if __name__ == '__main__': pg.init() pg.display.set_caption('The Harvest') screens = { 'Mainmenu': Mainmenu(), 'Farm': Farm(), 'Tile': Tile(), 'Options': Options(), 'Settings': Settings(), 'Stats': Stats(), 'Info': Info(), 'Tutorial': Tutorial(), 'Money': Money() } game = Game(display, screens, 'Mainmenu') game.run() pg.quit() sys.exit()
def check_alert(): money_dict, position = Money.search_data() all_user = [] data = Database.find_all(collection="users") for user in data: all_user.append(user["email"]) for user in all_user: message = [] user_all_alert = Database.find(collection="all_alert", query={"email": user}) for user_alert in user_all_alert: if user_alert["rate_exchange"] == "cash": if money_dict[position[user_alert["currency"]]].cash_in != "-": if float(user_alert["price"][0]) >= float(money_dict[ position[user_alert["currency"]]].cash_in): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass elif money_dict[position[ user_alert["currency"]]].cash_out != "-": if float(user_alert["price"][0]) <= float(money_dict[ position[user_alert["currency"]]].cash_out): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass else: pass else: pass elif money_dict[position[ user_alert["currency"]]].cash_out != "-": if float(user_alert["price"][0]) <= float(money_dict[ position[user_alert["currency"]]].cash_out): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass else: pass else: pass if user_alert["rate_exchange"] == "sign": if money_dict[position[user_alert["currency"]]].sign_in != "-": if float(user_alert["price"][0]) >= float(money_dict[ position[user_alert["currency"]]].sign_in): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass elif money_dict[position[ user_alert["currency"]]].sign_out != "-": if float(user_alert["price"][0]) <= float(money_dict[ position[user_alert["currency"]]].sign_out): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass else: pass else: pass elif money_dict[position[ user_alert["currency"]]].sign_out != "-": if float(user_alert["price"][0]) <= float(money_dict[ position[user_alert["currency"]]].sign_out): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass else: pass else: pass else: pass print(user, " : ", message) requests.post( "https://api.mailgun.net/v3/sandbox1b96a1ed36554268902d683b941720e5.mailgun.org/messages", auth=("api", "d71c327fcef21d1ae76ab199208f2269-49a2671e-37cd89ca"), data={ "from": "Mailgun Sandbox <*****@*****.**>", "to": user, "subject": "汇率变动提醒", "text": "目前符合的货币为:{},具体请查看提醒页面!".format(str(message).strip("[]")) })
def check_alert(): moneydict, position = Money.search_data() all_user = [] data = Database.find_all(collection="users") for user in data: all_user.append(user["email"]) for user in all_user: print(user) message = [] user_all_alert = Database.find(collection="all_alert", query={"email": user}) for user_alert in user_all_alert: if user_alert["rate_exchange"] == "cash": if moneydict[position[user_alert["currency"]]].cash_in != "-": if float(user_alert["price"][0]) >= float(moneydict[ position[user_alert["currency"]]].cash_in): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass elif moneydict[position[ user_alert["currency"]]].cash_out != "-": if float(user_alert["price"][0]) <= float(moneydict[ position[user_alert["currency"]]].cash_out): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass else: pass else: pass elif moneydict[position[ user_alert["currency"]]].cash_out != "-": if float(user_alert["price"][0]) <= float(moneydict[ position[user_alert["currency"]]].cash_out): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass else: pass else: pass if user_alert["rate_exchange"] == "sign": if moneydict[position[user_alert["currency"]]].sign_in != "-": if float(user_alert["price"][1]) >= float(moneydict[ position[user_alert["currency"]]].sign_in): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass elif moneydict[position[ user_alert["currency"]]].sign_out != "-": if float(user_alert["price"][1]) <= float(moneydict[ position[user_alert["currency"]]].sign_out): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass else: pass else: pass elif moneydict[position[ user_alert["currency"]]].sign_out != "-": if float(user_alert["price"][1]) <= float(moneydict[ position[user_alert["currency"]]].sign_out): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass else: pass else: pass else: pass print(user, ":", message) requests.post( "https://api.mailgun.net/v3/sandboxcf0f0204481f4e5db32ca491987d150f.mailgun.org/messages", auth=("api", "b7288f39ae1c25d533325c5181e0eada-4a62b8e8-809b3b07"), data={ "from": "Mailgun Sandbox <*****@*****.**>", "to": user, "subject": "外幣通知", "text": "目前符合調的外幣為:{},請盡快至關網查看!".format(str(message).strip("[]")) })
def check_alert(): moneydict, position = Money.search_data() all_user = [] data = Database.find_all(collection="users") for user in data: all_user.append(user["email"]) for user in all_user: print(user) message = [] user_all_alert = Database.find(collection="all_alert", query={"email": user}) for user_alert in user_all_alert: if user_alert["rate_exchange"] == "cash": if moneydict[position[user_alert["currency"]]].cash_in != "-": if float(user_alert["price"][0]) >= float(moneydict[position[user_alert["currency"]]].cash_in): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass elif moneydict[position[user_alert["currency"]]].cash_out != "-": if float(user_alert["price"][0]) <= float(moneydict[position[user_alert["currency"]]].cash_out): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass else: pass else: pass elif moneydict[position[user_alert["currency"]]].cash_out != "-": if float(user_alert["price"][0]) <= float(moneydict[position[user_alert["currency"]]].cash_out): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass else: pass else: pass if user_alert["rate_exchange"] == "sign": if moneydict[position[user_alert["currency"]]].sign_in != "-": if float(user_alert["price"][1]) >= float(moneydict[position[user_alert["currency"]]].sign_in): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass elif moneydict[position[user_alert["currency"]]].sign_out != "-": if float(user_alert["price"][1]) <= float(moneydict[position[user_alert["currency"]]].sign_out): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass else: pass else: pass elif moneydict[position[user_alert["currency"]]].sign_out != "-": if float(user_alert["price"][1]) <= float(moneydict[position[user_alert["currency"]]].sign_out): if user_alert["currency"] not in message: message.append(user_alert["currency"]) else: pass else: pass else: pass else: pass print(user,":",message) requests.post( "https://api.mailgun.net/v3/sandboxcf0f0204481f4e5db32ca491987d150f.mailgun.org/messages", auth=("api", "b7288f39ae1c25d533325c5181e0eada-4a62b8e8-809b3b07"), data={"from": "Mailgun Sandbox <*****@*****.**>", "to": user, "subject": "外幣通知", "text": "目前符合調的外幣為:{},請盡快至關網查看!".format(str(message).strip("[]"))})
def home(): moneydict, position = Money.search_data() return render_template("home.html", moneydict=moneydict)
def home(): monen_dict, positon = Money.search_data() return render_template('home.html', money_dict=monen_dict, positon=positon)