def make_reservation(): decided_games = get_decided_games() for decided_game in decided_games: decided_game['status'] = "Ended" elasticsearch_utils.update_game(decided_game) worker.order_meal(mail, password, str(decided_game['food']['rest_id']), str(decided_game['food']['dish_id']), decided_game["looser"])
def make_draw(): games = elasticsearch_utils.get_active_about_to_end_games() for game in games: participents = game.get("participents_ids") if len(participents) < 2: print "no participents" random.shuffle(participents) winner = participents[0] looser = participents[1] winner_user = elasticsearch_utils.get_user_from_es(winner) looser_user = elasticsearch_utils.get_user_from_es(looser) # send to winner send_mail(winner_user["email"], looser_user["email"], subject = "KULULU %s, You won a lunch in Lunch Roulette !!!" % winner_user["user_name"], body="Congrats!\nYou won the following lunch: %s (worth %s shekels)\nfrom: %s\nLunch will be ordered for you tomorrow (%s IS PAYING !! WOHO)\nYours truly,\nLunch Roulette" % (game["food"]["name"], game["food"]["price"],game["food"]["rest_name"], looser_user["user_name"])) # send to looser send_mail(looser_user["email"], winner_user["email"], subject = "BOOHOO %s, You lost %s shekels in Lunch Roulette " % (looser_user["user_name"], game["food"]["price"]), body="We're sorry to inform you that you owe your co-worker %s lunch tomorrow!\nNever give up hope, maybe you will eat for free tomorrow :)\nYours truly,\nLunch Roulette" % winner_user["user_name"]) game['status'] = "Decided" game['looser'] = [looser] game['winner'] = winner elasticsearch_utils.update_game(game) return games