当前位置: 首页>>代码示例>>Python>>正文


Python CoursewareSearchIndexer.remove_deleted_items方法代码示例

本文整理汇总了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])
开发者ID:franosincic,项目名称:edx-platform,代码行数:13,代码来源:tasks.py

示例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)
开发者ID:franosincic,项目名称:edx-platform,代码行数:21,代码来源:tasks.py


注:本文中的contentstore.courseware_index.CoursewareSearchIndexer.remove_deleted_items方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。