def _change_access(course, user, level, action, send_email=True):
 try:
  role = ROLES[level](course.id)
 except KeyError:
  raise ValueError("unrecognized level '{}'".format(level))
 if (action == 'allow'):
  if (level == 'ccx_coach'):
   email_params = get_email_params(course, True)
   enroll_email(course_id=course.id, student_email=user.email, auto_enroll=True, email_students=send_email, email_params=email_params)
  role.add_users(user)
 elif (action == 'revoke'):
  role.remove_users(user)
 else:
  raise ValueError("unrecognized action '{}'".format(action))

def _change_access ( course , user , level , action , send_email = True ) : try : role = ROLES [ level ] ( course . id ) except KeyError : raise ValueError ( "unrecognized level '{}'" . format ( level ) ) if ( action == 'allow' ) : if ( level == 'ccx_coach' ) : email_params = get_email_params ( course , True ) enroll_email ( course_id = course . id , student_email = user . email , auto_enroll = True , email_students = send_email , email_params = email_params ) role . add_users ( user ) elif ( action == 'revoke' ) : role . remove_users ( user ) else : raise ValueError ( "unrecognized action '{}'" . format ( action ) )
change access of user .