'Identify a subset of users who may be eligible for a program certificate.
This is done by finding users who have earned a qualifying certificate in
at least one program course\'s course run.'

def _load_usernames(self):

    status_query = Q(status__in=CertificateStatuses.PASSED_STATUSES)
    course_run_query = reduce((lambda x, y: (x | y)), [Q(course_id=course_run.key, mode=course_run.type) for course_run in self.course_runs])
    for course_run in self.course_runs:
        if (course_run.type == CourseMode.PROFESSIONAL):
            course_run_query |= Q(course_id=course_run.key, mode=CourseMode.NO_ID_PROFESSIONAL_MODE)
    query = (status_query & course_run_query)
    username_dicts = GeneratedCertificate.eligible_certificates.filter(query).values('user__username').distinct()
    self.usernames = [d['user__username'] for d in username_dicts]
