The resolution property for schemes and stacks