human
Complete the below
@require_POST
@ensure_csrf_cookie
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
@require_level('staff')
@require_post_params('rolename')
def list_forum_members(request, course_id):

    ''''Lists forum members of a certain rolename.
    Limited to staff access.
    The requesting user must be at least staff.
    Staff forum admins can access all roles EXCEPT for FORUM_ROLE_ADMINISTRATOR
    which is limited to instructors.
    Takes query parameter `rolename`.'
    '''
assistant
#Here is the Python code you requested.
    course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)
    course = get_course_by_id(course_id)
    has_instructor_access = has_access(request.user, 'instructor', course)
    has_forum_admin = has_forum_access(request.user, course_id, FORUM_ROLE_ADMINISTRATOR)
    rolename = request.POST.get('rolename')
    if (not (has_forum_admin or has_instructor_access)):
        return HttpResponseBadRequest('Operation    requires    staff    &    forum    admin    or    instructor    access')
    if ((rolename == FORUM_ROLE_ADMINISTRATOR) and (not has_instructor_access)):
        return HttpResponseBadRequest('Operation    requires    instructor    access.')
    if (rolename not in [FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_MODERATOR, FORUM_ROLE_GROUP_MODERATOR, FORUM_ROLE_COMMUNITY_TA]):
        return HttpResponseBadRequest(strip_tags("Unrecognized    rolename    '{}'.".format(rolename)))
    try:
        role = Role.objects.get(name=rolename, course_id=course_id)
        users = role.users.all().order_by('username')
    except Role.DoesNotExist:
        users = []
    course_discussion_settings = get_course_discussion_settings(course_id)
    def extract_user_info(user):
        '    Convert    user    to    dict    for    json    rendering.    '
        group_id = get_group_id_for_user(user, course_discussion_settings)
        group_name = get_group_name(group_id, course_discussion_settings)
        return {'username': user.username, 'email': user.email, 'first_name': user.first_name, 'last_name': user.last_name, 'group_name': group_name}
    response_payload = {'course_id': course_id.to_deprecated_string(), rolename: map(extract_user_info, users), 'division_scheme': course_discussion_settings.division_scheme}
    return JsonResponse(response_payload)