def check_course_access(course, user, action, check_if_enrolled=False):
 access_response = has_access(user, action, course, course.id)
 if (not access_response):
  raise CoursewareAccessException(access_response)
 if check_if_enrolled:
  if (not ((user.id and CourseEnrollment.is_enrolled(user, course.id)) or has_access(user, 'staff', course))):
   raise UserNotEnrolled(course.id)

def check_course_access ( course , user , action , check_if_enrolled = False ) : access_response = has_access ( user , action , course , course . id ) if ( not access_response ) : raise CoursewareAccessException ( access_response ) if check_if_enrolled : if ( not ( ( user . id and CourseEnrollment . is_enrolled ( user , course . id ) ) or has_access ( user , 'staff' , course ) ) ) : raise UserNotEnrolled ( course . id )
check that the user has the access to perform the specified action on the course .