Labour wins court case over voting rules