diff --git a/openedx/core/djangoapps/content_libraries/signal_handlers.py b/openedx/core/djangoapps/content_libraries/signal_handlers.py index 1d723bea8b23..49d40b27d689 100644 --- a/openedx/core/djangoapps/content_libraries/signal_handlers.py +++ b/openedx/core/djangoapps/content_libraries/signal_handlers.py @@ -20,7 +20,7 @@ LIBRARY_COLLECTION_DELETED, LIBRARY_COLLECTION_UPDATED, ) -from openedx_learning.api.authoring import get_collection_components, get_component, get_components +from openedx_learning.api.authoring import get_component, get_components from openedx_learning.api.authoring_models import Collection, CollectionPublishableEntity, Component, PublishableEntity from lms.djangoapps.grades.api import signals as grades_signals @@ -182,18 +182,12 @@ def library_collection_entities_changed(sender, instance, action, pk_set, **kwar _library_collection_component_changed(instance.component, library.library_key) return + # When action=="post_clear", pk_set==None + # Since the collection instance now has an empty entities set, + # we don't know which ones were removed, so we need to update associations for all library components. + components = get_components(instance.learning_package_id) if pk_set: - components = get_collection_components( - instance.learning_package_id, - instance.key, - ).filter(pk__in=pk_set) - else: - # When action=="post_clear", pk_set==None - # Since the collection instance now has an empty entities set, - # we don't know which ones were removed, so we need to update associations for all library components. - components = get_components( - instance.learning_package_id, - ) + components = components.filter(pk__in=pk_set) for component in components.all(): _library_collection_component_changed(component, library.library_key)