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])
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)