@login_required
@require_http_methods(('GET', 'DELETE'))
def orphan_handler(request, course_key_string):
 course_usage_key = CourseKey.from_string(course_key_string)
 if (request.method == 'GET'):
  if has_studio_read_access(request.user, course_usage_key):
   return JsonResponse([unicode(item) for item in modulestore().get_orphans(course_usage_key)])
  else:
   raise PermissionDenied()
 if (request.method == 'DELETE'):
  if request.user.is_staff:
   deleted_items = _delete_orphans(course_usage_key, request.user.id, commit=True)
   return JsonResponse({'deleted': deleted_items})
  else:
   raise PermissionDenied()

@ login_required @ require_http_methods ( ( 'GET' , 'DELETE' ) ) def orphan_handler ( request , course_key_string ) : course_usage_key = CourseKey . from_string ( course_key_string ) if ( request . method == 'GET' ) : if has_studio_read_access ( request . user , course_usage_key ) : return JsonResponse ( [ unicode ( item ) for item in modulestore ( ) . get_orphans ( course_usage_key ) ] ) else : raise PermissionDenied ( ) if ( request . method == 'DELETE' ) : if request . user . is_staff : deleted_items = _delete_orphans ( course_usage_key , request . user . id , commit = True ) return JsonResponse ( { 'deleted' : deleted_items } ) else : raise PermissionDenied ( )
view for handling orphan related requests .