def library_blocks_view(library, user, response_format):
 assert isinstance(library.location.library_key, LibraryLocator)
 assert isinstance(library.location, LibraryUsageLocator)
 children = library.children
 if (response_format == 'json'):
  prev_version = library.runtime.course_entry.structure['previous_version']
  return JsonResponse({'display_name': library.display_name, 'library_id': unicode(library.location.library_key), 'version': unicode(library.runtime.course_entry.course_key.version), 'previous_version': (unicode(prev_version) if prev_version else None), 'blocks': [unicode(x) for x in children]})
 can_edit = has_studio_write_access(user, library.location.library_key)
 xblock_info = create_xblock_info(library, include_ancestor_info=False, graders=[])
 component_templates = (get_component_templates(library, library=True) if can_edit else [])
 return render_to_response('library.html', {'can_edit': can_edit, 'context_library': library, 'component_templates': component_templates, 'xblock_info': xblock_info, 'templates': CONTAINER_TEMPLATES})

def library_blocks_view ( library , user , response_format ) : assert isinstance ( library . location . library_key , LibraryLocator ) assert isinstance ( library . location , LibraryUsageLocator ) children = library . children if ( response_format == 'json' ) : prev_version = library . runtime . course_entry . structure [ 'previous_version' ] return JsonResponse ( { 'display_name' : library . display_name , 'library_id' : unicode ( library . location . library_key ) , 'version' : unicode ( library . runtime . course_entry . course_key . version ) , 'previous_version' : ( unicode ( prev_version ) if prev_version else None ) , 'blocks' : [ unicode ( x ) for x in children ] } ) can_edit = has_studio_write_access ( user , library . location . library_key ) xblock_info = create_xblock_info ( library , include_ancestor_info = False , graders = [ ] ) component_templates = ( get_component_templates ( library , library = True ) if can_edit else [ ] ) return render_to_response ( 'library.html' , { 'can_edit' : can_edit , 'context_library' : library , 'component_templates' : component_templates , 'xblock_info' : xblock_info , 'templates' : CONTAINER_TEMPLATES } )
the main view of a courses content library .