def _has_access_descriptor(user, action, descriptor, course_key=None):
 def can_load():
  "\n        NOTE: This does not check that the student is enrolled in the course\n        that contains this module.  We may or may not want to allow non-enrolled\n        students to see modules.  If not, views should check the course, so we\n        don't have to hit the enrollments table on every module load.\n        "
  if (not _has_group_access(descriptor, user, course_key)):
   return ACCESS_DENIED
  if _has_staff_access_to_descriptor(user, descriptor, course_key):
   return ACCESS_GRANTED
  return (_visible_to_nonstaff_users(descriptor) and _can_access_descriptor_with_milestones(user, descriptor, course_key) and (_has_detached_class_tag(descriptor) or _can_access_descriptor_with_start_date(user, descriptor, course_key)))
 checkers = {'load': can_load, 'staff': (lambda : _has_staff_access_to_descriptor(user, descriptor, course_key)), 'instructor': (lambda : _has_instructor_access_to_descriptor(user, descriptor, course_key))}
 return _dispatch(checkers, action, user, descriptor)

def _has_access_descriptor ( user , action , descriptor , course_key = None ) : def can_load ( ) : if ( not _has_group_access ( descriptor , user , course_key ) ) : return ACCESS_DENIED if _has_staff_access_to_descriptor ( user , descriptor , course_key ) : return ACCESS_GRANTED return ( _visible_to_nonstaff_users ( descriptor ) and _can_access_descriptor_with_milestones ( user , descriptor , course_key ) and ( _has_detached_class_tag ( descriptor ) or _can_access_descriptor_with_start_date ( user , descriptor , course_key ) ) ) checkers = { 'load' : can_load , 'staff' : ( lambda : _has_staff_access_to_descriptor ( user , descriptor , course_key ) ) , 'instructor' : ( lambda : _has_instructor_access_to_descriptor ( user , descriptor , course_key ) ) } return _dispatch ( checkers , action , user , descriptor )
check if user has access to this descriptor .