def get_allowed_block_types(library_key): # pylint: disable=unused-argument """ Get a list of XBlock types that can be added to the specified content library. """ # This import breaks in the LMS so keep it here. The LMS doesn't generally # use content libraries APIs directly but some tests may want to use them to # create libraries and then test library learning or course-library integration. from cms.djangoapps.contentstore.views.helpers import xblock_type_display_name # TODO: return support status and template options # See cms/djangoapps/contentstore/views/component.py block_types = sorted(name for name, class_ in XBlock.load_classes()) lib = get_library(library_key) if lib.type != COMPLEX: # Problem and Video libraries only permit XBlocks of the same name. block_types = (name for name in block_types if name == lib.type) info = [] for block_type in block_types: display_name = xblock_type_display_name(block_type, None) # For now as a crude heuristic, we exclude blocks that don't have a display_name if display_name: info.append( LibraryXBlockType(block_type=block_type, display_name=display_name)) return info
def get_allowed_block_types(library_key): # pylint: disable=unused-argument """ Get a list of XBlock types that can be added to the specified content library. For now, the result is the same regardless of which library is specified, but that may change in the future. """ # TODO: return support status and template options # See cms/djangoapps/contentstore/views/component.py block_types = sorted(name for name, class_ in XBlock.load_classes()) info = [] for block_type in block_types: display_name = xblock_type_display_name(block_type, None) # For now as a crude heuristic, we exclude blocks that don't have a display_name if display_name: info.append(LibraryXBlockType(block_type=block_type, display_name=display_name)) return info