def _has_access_to_course(user, access_level, course_key):
 if ((user is None) or (not user.is_authenticated())):
  debug('Deny: no user or anon user')
  return ACCESS_DENIED
 if ((not in_preview_mode()) and is_masquerading_as_student(user, course_key)):
  return ACCESS_DENIED
 if GlobalStaff().has_user(user):
  debug('Allow: user.is_staff')
  return ACCESS_GRANTED
 if (access_level not in ('staff', 'instructor')):
  log.debug('Error in access._has_access_to_course access_level=%s unknown', access_level)
  debug('Deny: unknown access level')
  return ACCESS_DENIED
 staff_access = (CourseStaffRole(course_key).has_user(user) or OrgStaffRole(course_key.org).has_user(user))
 if (staff_access and (access_level == 'staff')):
  debug('Allow: user has course staff access')
  return ACCESS_GRANTED
 instructor_access = (CourseInstructorRole(course_key).has_user(user) or OrgInstructorRole(course_key.org).has_user(user))
 if (instructor_access and (access_level in ('staff', 'instructor'))):
  debug('Allow: user has course instructor access')
  return ACCESS_GRANTED
 debug('Deny: user did not have correct access')
 return ACCESS_DENIED

def _has_access_to_course ( user , access_level , course_key ) : if ( ( user is None ) or ( not user . is_authenticated ( ) ) ) : debug ( 'Deny: no user or anon user' ) return ACCESS_DENIED if ( ( not in_preview_mode ( ) ) and is_masquerading_as_student ( user , course_key ) ) : return ACCESS_DENIED if GlobalStaff ( ) . has_user ( user ) : debug ( 'Allow: user.is_staff' ) return ACCESS_GRANTED if ( access_level not in ( 'staff' , 'instructor' ) ) : log . debug ( 'Error in access._has_access_to_course access_level=%s unknown' , access_level ) debug ( 'Deny: unknown access level' ) return ACCESS_DENIED staff_access = ( CourseStaffRole ( course_key ) . has_user ( user ) or OrgStaffRole ( course_key . org ) . has_user ( user ) ) if ( staff_access and ( access_level == 'staff' ) ) : debug ( 'Allow: user has course staff access' ) return ACCESS_GRANTED instructor_access = ( CourseInstructorRole ( course_key ) . has_user ( user ) or OrgInstructorRole ( course_key . org ) . has_user ( user ) ) if ( instructor_access and ( access_level in ( 'staff' , 'instructor' ) ) ) : debug ( 'Allow: user has course instructor access' ) return ACCESS_GRANTED debug ( 'Deny: user did not have correct access' ) return ACCESS_DENIED
returns true if the given user has access_level access to the course with the given course_key .