def get_eligibilities_for_user(username, course_key=None):
 eligibilities = CreditEligibility.get_user_eligibilities(username)
 if course_key:
  course_key = CourseKey.from_string(unicode(course_key))
  eligibilities = eligibilities.filter(course__course_key=course_key)
 return [{'course_key': unicode(eligibility.course.course_key), 'deadline': eligibility.deadline} for eligibility in eligibilities]

def get_eligibilities_for_user ( username , course_key = None ) : eligibilities = CreditEligibility . get_user_eligibilities ( username ) if course_key : course_key = CourseKey . from_string ( unicode ( course_key ) ) eligibilities = eligibilities . filter ( course__course_key = course_key ) return [ { 'course_key' : unicode ( eligibility . course . course_key ) , 'deadline' : eligibility . deadline } for eligibility in eligibilities ]
retrieve all courses or particular course for which the user is eligible for credit .