def _rerun_course(request, org, number, run, fields):
 source_course_key = CourseKey.from_string(request.json.get('source_course_key'))
 if (not has_studio_write_access(request.user, source_course_key)):
  raise PermissionDenied()
 store = modulestore()
 with store.default_store('split'):
  destination_course_key = store.make_course_key(org, number, run)
 if store.has_course(destination_course_key, ignore_case=True):
  raise DuplicateCourseError(source_course_key, destination_course_key)
 add_instructor(destination_course_key, request.user, request.user)
 CourseRerunState.objects.initiated(source_course_key, destination_course_key, request.user, fields['display_name'])
 fields['advertised_start'] = None
 json_fields = json.dumps(fields, cls=EdxJSONEncoder)
 rerun_course.delay(unicode(source_course_key), unicode(destination_course_key), request.user.id, json_fields)
 return JsonResponse({'url': reverse_url('course_handler'), 'destination_course_key': unicode(destination_course_key)})

def _rerun_course ( request , org , number , run , fields ) : source_course_key = CourseKey . from_string ( request . json . get ( 'source_course_key' ) ) if ( not has_studio_write_access ( request . user , source_course_key ) ) : raise PermissionDenied ( ) store = modulestore ( ) with store . default_store ( 'split' ) : destination_course_key = store . make_course_key ( org , number , run ) if store . has_course ( destination_course_key , ignore_case = True ) : raise DuplicateCourseError ( source_course_key , destination_course_key ) add_instructor ( destination_course_key , request . user , request . user ) CourseRerunState . objects . initiated ( source_course_key , destination_course_key , request . user , fields [ 'display_name' ] ) fields [ 'advertised_start' ] = None json_fields = json . dumps ( fields , cls = EdxJSONEncoder ) rerun_course . delay ( unicode ( source_course_key ) , unicode ( destination_course_key ) , request . user . id , json_fields ) return JsonResponse ( { 'url' : reverse_url ( 'course_handler' ) , 'destination_course_key' : unicode ( destination_course_key ) } )
reruns an existing course .