Moved library key normalization into library_tools module, fixed library update task test

This commit is contained in:
E. Kolpakov
2015-04-14 14:27:02 +03:00
parent 5737364388
commit 9bbad95497
4 changed files with 31 additions and 25 deletions

View File

@@ -10,6 +10,11 @@ from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.capa_module import CapaDescriptor
def normalize_key_for_search(library_key):
""" Normalizes library key for use with search indexing """
return library_key.replace(version_guid=None, branch=None)
class LibraryToolsService(object):
"""
Service that allows LibraryContentModule to interact with libraries in the
@@ -92,6 +97,7 @@ class LibraryToolsService(object):
search_engine = SearchEngine.get_search_engine(index="library_index")
if search_engine:
filter_clause = {
"library": unicode(normalize_key_for_search(library.location.library_key)),
"content_type": CapaDescriptor.INDEX_CONTENT_TYPE,
"problem_types": capa_type
}