human
Complete the below
@login_required
@ensure_csrf_cookie
def course_listing(request):

    ''''List all courses available to the logged in user'
    '''
assistant
#Here is the Python program you requested.
    optimization_enabled = (GlobalStaff().has_user(request.user) and WaffleSwitchNamespace(name=WAFFLE_NAMESPACE).is_enabled(u'enable_global_staff_optimization'))
    org = (request.GET.get('org', '') if optimization_enabled else None)
    (courses_iter, in_process_course_actions) = get_courses_accessible_to_user(request, org)
    user = request.user
    libraries = (_accessible_libraries_iter(request.user, org) if LIBRARIES_ENABLED else [])
    def format_in_process_course_view(uca):
        '\n                                Return    a    dict    of    the    data    which    the    view    requires    for    each    unsucceeded    course\n                                '
        return {u'display_name': uca.display_name, u'course_key': unicode(uca.course_key), u'org': uca.course_key.org, u'number': uca.course_key.course, u'run': uca.course_key.run, u'is_failed': (True if (uca.state == CourseRerunUIStateManager.State.FAILED) else False), u'is_in_progress': (True if (uca.state == CourseRerunUIStateManager.State.IN_PROGRESS) else False), u'dismiss_link': (reverse_course_url(u'course_notifications_handler', uca.course_key, kwargs={u'action_state_id': uca.id}) if (uca.state == CourseRerunUIStateManager.State.FAILED) else u'')}
    def format_library_for_view(library):
        '\n                                Return    a    dict    of    the    data    which    the    view    requires    for    each    library\n                                '
        return {u'display_name': library.display_name, u'library_key': unicode(library.location.library_key), u'url': reverse_library_url(u'library_handler', unicode(library.location.library_key)), u'org': library.display_org_with_default, u'number': library.display_number_with_default, u'can_edit': has_studio_write_access(request.user, library.location.library_key)}
    split_archived = settings.FEATURES.get(u'ENABLE_SEPARATE_ARCHIVED_COURSES', False)
    (active_courses, archived_courses) = _process_courses_list(courses_iter, in_process_course_actions,...