def assign_staff_role_to_ccx(ccx_locator, user, master_course_id):
 coach_role_on_master_course = CourseCcxCoachRole(master_course_id)
 if coach_role_on_master_course.has_user(user):
  role = CourseStaffRole(ccx_locator)
  if (not role.has_user(user)):
   with ccx_course(ccx_locator) as course:
    allow_access(course, user, 'staff', send_email=False)

def assign_staff_role_to_ccx ( ccx_locator , user , master_course_id ) : coach_role_on_master_course = CourseCcxCoachRole ( master_course_id ) if coach_role_on_master_course . has_user ( user ) : role = CourseStaffRole ( ccx_locator ) if ( not role . has_user ( user ) ) : with ccx_course ( ccx_locator ) as course : allow_access ( course , user , 'staff' , send_email = False )
check if user has ccx_coach role on master course then assign him staff role on ccx only if role is not already assigned .