def test_view_board_goal_qr_code_data(client): """ Test that the data for goal QR codes are being set correctly. """ with app.app_context(): client.post("/login", data={ "username": "******", "password": "******" }) res = client.get("/restaurants/5f0df6a10bb07c8199d4405a/board", follow_redirects=True) rpm = RestaurantProfileManager("") bpm = GameBoardManager(rpm) board = bpm.get_restaurant_board_by_id("5f0df6a10bb07c8199d4405a") for i in range(len(board["board"])): assert str.encode("unittestuser+{}+{}".format( board["board"][i]["_id"], i)) in res.data
def view_board(obj_id): """ Allows users to view the chosen restaurant's game board. """ username = current_user.get_id() rpm = RestaurantProfileManager("") gpm = GameBoardManager(rpm) gpm.update_board(obj_id) board = gpm.get_restaurant_board_by_id(obj_id) set_board_progress(current_user, board, obj_id) board["expiry_date"] = board["expiry_date"].strftime( "%B X%d, %Y - X%I:%M %p UTC").replace("X0", "X").replace("X", "") return render_template('view_game_board.j2', goals=board["board"], name=board["name"], rewards=board["board_reward"], cust_id=username, size=board["size"], date=board["expiry_date"])
def view_board(): """ When retrieving this route, get a restaurant profile's current bingo board. Render these items together to show current bingo board and expiration date. """ rest_id = current_user.get_restaurant_id() try: gbm = GameBoardManager(current_user) gbm.update_board(rest_id) bingo_board = gbm.get_restaurant_board_by_id(rest_id) if bingo_board["board"] == []: return redirect("/board/edit") return render_template( 'view_game_board.j2', goals=[x['goal'] for x in bingo_board["board"]], board_name=bingo_board["name"], rewards=[x['reward'] for x in bingo_board["board_reward"]], board_size=bingo_board["size"], current_expiry=str(bingo_board["expiry_date"])) except KeyError: return redirect("/board/edit")