Orientational transitions in a one-dimensional lattice of molecules with dipole and quadrupole moments