本文整理汇总了Python中contentstore.courseware_index.CoursewareSearchIndexer.remove_deleted_items方法的典型用法代码示例。如果您正苦于以下问题:Python CoursewareSearchIndexer.remove_deleted_items方法的具体用法?Python CoursewareSearchIndexer.remove_deleted_items怎么用?Python CoursewareSearchIndexer.remove_deleted_items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类contentstore.courseware_index.CoursewareSearchIndexer
的用法示例。
在下文中一共展示了CoursewareSearchIndexer.remove_deleted_items方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_course_task
# 需要导入模块: from contentstore.courseware_index import CoursewareSearchIndexer [as 别名]
# 或者: from contentstore.courseware_index.CoursewareSearchIndexer import remove_deleted_items [as 别名]
def delete_course_task(user_id, course_key_string):
profile = UserProfile.objects.get(pk=user_id)
user = User.objects.get(pk=profile.user_id)
course_key = CourseKey.from_string(course_key_string)
delete_course_and_groups(course_key, user.id)
searcher = SearchEngine.get_search_engine(CoursewareSearchIndexer.INDEX_NAME)
if searcher != None:
CoursewareSearchIndexer.remove_deleted_items(searcher, CourseKey.from_string(course_key_string), [])
searcher.remove(CourseAboutSearchIndexer.DISCOVERY_DOCUMENT_TYPE, [course_key_string])
示例2: delete_temp_user_task
# 需要导入模块: from contentstore.courseware_index import CoursewareSearchIndexer [as 别名]
# 或者: from contentstore.courseware_index.CoursewareSearchIndexer import remove_deleted_items [as 别名]
def delete_temp_user_task(request, user_id):
profile = UserProfile.objects.get(pk=user_id)
user = User.objects.get(pk=profile.user_id)
courses = [format_course_for_view(c) for c in get_courses_accessible_to_user(request, user)[0]]
libraries = [format_library_for_view(lib, user) for lib in accessible_libraries_list(user)]
for course in courses:
course_key = CourseKey.from_string(course["course_key"])
delete_course_and_groups(course_key, user.id)
searcher = SearchEngine.get_search_engine(CoursewareSearchIndexer.INDEX_NAME)
if searcher != None:
CoursewareSearchIndexer.remove_deleted_items(searcher, CourseKey.from_string(course_key_string), [])
searcher.remove(CourseAboutSearchIndexer.DISCOVERY_DOCUMENT_TYPE, [course_key_string])
for library in libraries:
library_key = CourseKey.from_string(library['library_key'])
delete_course_and_groups(library_key, user.id)