Dean Preston, a tenants rights activist, squeaked out a victory against the appointed incumbent in San Francisco’s District Five.