Skip to content

Commit

Permalink
fix: use content object associations changed event to update collecti…
Browse files Browse the repository at this point in the history
…ons on restore
  • Loading branch information
navinkarkera committed Dec 13, 2024
1 parent 9ebfcc1 commit b812159
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 0 additions & 2 deletions openedx/core/djangoapps/content/search/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,6 @@ def searchable_doc_for_library_block(xblock_metadata: lib_api.LibraryXBlockMetad

# Add the breadcrumbs. In v2 libraries, the library itself is not a "parent" of the XBlocks so we add it here:
doc[Fields.breadcrumbs] = [{"display_name": library_name}]
# Add collections data to index if this block is part of any collection
doc.update(_collections_for_content_object(xblock_metadata.usage_key))

return doc

Expand Down
8 changes: 8 additions & 0 deletions openedx/core/djangoapps/content_libraries/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,14 @@ def restore_library_block(usage_key):
)
)

# Add tags and collections back to index
CONTENT_OBJECT_ASSOCIATIONS_CHANGED.send_event(
content_object=ContentObjectChangedData(
object_id=str(usage_key),
changes=["collections", "tags"],
),
)

# For each collection, trigger LIBRARY_COLLECTION_UPDATED signal and set background=True to trigger
# collection indexing asynchronously.
#
Expand Down

0 comments on commit b812159

Please sign in to comment.