AP wins reinstatement to White House events after judge rules government can’t bar its journalists