'Returns the user object corresponding to the request\'s \'username\' parameter,
or the current request.user if no \'username\' was provided.
Verifies that the request.user has access to the requested users\'s grades.
Returns a 403 error response if access is denied, or a 404 error response if the user does not exist.'

def _get_effective_user(self, request, course):

    if ('username' in request.GET):
        username = request.GET.get('username')
    else:
        username = request.user.username
    if (request.user.username == username):
        return request.user
    if (not has_access(request.user, CourseStaffRole.ROLE, course)):
        log.info('User    %s    tried    to    access    the    grade    for    user    %s.', request.user.username, username)
        return self.make_error_response(status_code=status.HTTP_403_FORBIDDEN, developer_message='The    user    requested    does    not    match    the    logged    in    user.', error_code='user_mismatch')
    try:
        return USER_MODEL.objects.get(username=username)
    except USER_MODEL.DoesNotExist:
        return self.make_error_response(status_code=status.HTTP_404_NOT_FOUND, developer_message='The    user    matching    the    requested    username    does    not    exist.', error_code='user_does_not_exist')
