def all_boards(): """ Returns all the boards the user has access to or adds a board. """ if request.method == 'GET': board_ids = Board.get_board_ids_by_netid(g.user.netid) boards = map(lambda id_: Board.get_board_by_id(id_).to_dict(), board_ids) return ok({'boards': boards}) elif request.method == 'POST': # add a board board_name = request.form.get("name") if not board_name: return error(Error.EMPTY_BOARD_ID, 400) b = Board.add_board(board_name) Access.add_access(b.id, g.user.netid) return ok({"created": True, "board": b.to_dict()})