Effects of the lattice distortion on the magnetic order in rare-earth nickelates