@login_required
@expect_json
def _create_item(request):
 parent_locator = request.json['parent_locator']
 usage_key = usage_key_with_run(parent_locator)
 if (not has_studio_write_access(request.user, usage_key.course_key)):
  raise PermissionDenied()
 category = request.json['category']
 if isinstance(usage_key, LibraryUsageLocator):
  if (category not in ['html', 'problem', 'video']):
   return HttpResponseBadRequest(("Category '%s' not supported for Libraries" % category), content_type='text/plain')
 created_block = create_xblock(parent_locator=parent_locator, user=request.user, category=category, display_name=request.json.get('display_name'), boilerplate=request.json.get('boilerplate'))
 return JsonResponse({'locator': unicode(created_block.location), 'courseKey': unicode(created_block.location.course_key)})

@ login_required @ expect_json def _create_item ( request ) : parent_locator = request . json [ 'parent_locator' ] usage_key = usage_key_with_run ( parent_locator ) if ( not has_studio_write_access ( request . user , usage_key . course_key ) ) : raise PermissionDenied ( ) category = request . json [ 'category' ] if isinstance ( usage_key , LibraryUsageLocator ) : if ( category not in [ 'html' , 'problem' , 'video' ] ) : return HttpResponseBadRequest ( ( "Category '%s' not supported for Libraries" % category ) , content_type = 'text/plain' ) created_block = create_xblock ( parent_locator = parent_locator , user = request . user , category = category , display_name = request . json . get ( 'display_name' ) , boilerplate = request . json . get ( 'boilerplate' ) ) return JsonResponse ( { 'locator' : unicode ( created_block . location ) , 'courseKey' : unicode ( created_block . location . course_key ) } )
view for create items .