def revert_ccx_staff_to_coaches(apps, schema_editor):
 CustomCourseForEdX = apps.get_model(u'ccx', u'CustomCourseForEdX')
 db_alias = schema_editor.connection.alias
 if (not (db_alias == u'default')):
  return
 list_ccx = CustomCourseForEdX.objects.using(db_alias).all()
 for ccx in list_ccx:
  ccx_locator = CCXLocator.from_course_locator(ccx.course_id, unicode(ccx.id))
  try:
   course = get_course_by_id(ccx_locator)
  except Http404:
   log.error(u'Could not migrate access for CCX course: %s', unicode(ccx_locator))
  else:
   coach = User.objects.get(id=ccx.coach.id)
   allow_access(course, coach, u'ccx_coach', send_email=False)
   revoke_access(course, coach, u'staff', send_email=False)
   log.info(u'The CCX coach of CCX %s has been switched from "Staff" to "CCX Coach".', unicode(ccx_locator))

def revert_ccx_staff_to_coaches ( apps , schema_editor ) : CustomCourseForEdX = apps . get_model ( u'ccx' , u'CustomCourseForEdX' ) db_alias = schema_editor . connection . alias if ( not ( db_alias == u'default' ) ) : return list_ccx = CustomCourseForEdX . objects . using ( db_alias ) . all ( ) for ccx in list_ccx : ccx_locator = CCXLocator . from_course_locator ( ccx . course_id , unicode ( ccx . id ) ) try : course = get_course_by_id ( ccx_locator ) except Http404 : log . error ( u'Could not migrate access for CCX course: %s' , unicode ( ccx_locator ) ) else : coach = User . objects . get ( id = ccx . coach . id ) allow_access ( course , coach , u'ccx_coach' , send_email = False ) revoke_access ( course , coach , u'staff' , send_email = False ) log . info ( u'The CCX coach of CCX %s has been switched from "Staff" to "CCX Coach".' , unicode ( ccx_locator ) )
modify all staff on ccx courses so that they no longer have the staff role on the course that they coach .