Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion openedx/core/djangoapps/content/search/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ def searchable_doc_for_container(
Fields.block_id: container_key.container_id, # Field name isn't exact but this is the closest match
Fields.access_id: _meili_access_id_from_context_key(container_key.library_key),
Fields.publish_status: PublishStatus.never,
Fields.last_published: None,
}

try:
Expand All @@ -593,6 +594,7 @@ def searchable_doc_for_container(
Fields.modified: container.modified.timestamp(),
Fields.num_children: draft_num_children,
Fields.publish_status: publish_status,
Fields.last_published: container.last_published.timestamp() if container.last_published else None,
})
library = lib_api.get_library(container_key.library_key)
if library:
Expand All @@ -601,8 +603,8 @@ def searchable_doc_for_container(
if container.published_version_num is not None:
published_num_children = lib_api.get_container_children_count(container_key, published=True)
doc[Fields.published] = {
# Fields.published_display_name: container_published.title, TODO: set the published title
Fields.published_num_children: published_num_children,
Fields.published_display_name: container.published_display_name,
}

return doc
1 change: 1 addition & 0 deletions openedx/core/djangoapps/content/search/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def setUp(self):
"org": "org1",
"created": created_date.timestamp(),
"modified": created_date.timestamp(),
"last_published": None,
"access_id": lib_access.id,
"breadcrumbs": [{"display_name": "Library"}],
# "published" is not set since we haven't published it yet
Expand Down
18 changes: 14 additions & 4 deletions openedx/core/djangoapps/content/search/tests/test_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ def test_draft_container(self):
"breadcrumbs": [{"display_name": "some content_library"}],
"created": 1680674828.0,
"modified": 1680674828.0,
"last_published": None,
"tags": {
"taxonomy": ["Difficulty"],
"level0": ["Difficulty > Normal"]
Expand All @@ -552,7 +553,7 @@ def test_published_container(self):
[self.library_block.usage_key],
user_id=None,
)
library_api.publish_changes(self.library.key)
library_api.publish_changes(self.library.key)

doc = searchable_doc_for_container(self.container.container_key)
doc.update(searchable_doc_tags(self.container.container_key))
Expand All @@ -573,11 +574,15 @@ def test_published_container(self):
"breadcrumbs": [{"display_name": "some content_library"}],
"created": 1680674828.0,
"modified": 1680674828.0,
"last_published": 1680674828.0,
"tags": {
"taxonomy": ["Difficulty"],
"level0": ["Difficulty > Normal"]
},
"published": {"num_children": 1},
"published": {
"num_children": 1,
"display_name": "A Unit in the Search Index",
},
}

def test_published_container_with_changes(self):
Expand All @@ -589,7 +594,8 @@ def test_published_container_with_changes(self):
[self.library_block.usage_key],
user_id=None,
)
library_api.publish_changes(self.library.key)
with freeze_time(self.container.created):
library_api.publish_changes(self.library.key)
block_2 = library_api.create_library_block(
self.library.key,
"html",
Expand Down Expand Up @@ -624,11 +630,15 @@ def test_published_container_with_changes(self):
"breadcrumbs": [{"display_name": "some content_library"}],
"created": 1680674828.0,
"modified": 1680674828.0,
"last_published": 1680674828.0,
"tags": {
"taxonomy": ["Difficulty"],
"level0": ["Difficulty > Normal"]
},
"published": {"num_children": 1},
"published": {
"num_children": 1,
"display_name": "A Unit in the Search Index",
},
}

def test_mathjax_plain_text_conversion_for_search(self):
Expand Down
2 changes: 2 additions & 0 deletions openedx/core/djangoapps/content_libraries/api/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class ContainerMetadata(PublishableItem):
"""
container_key: LibraryContainerLocator
container_type: ContainerType
published_display_name: str | None

@classmethod
def from_container(cls, library_key, container: Container, associated_collections=None):
Expand Down Expand Up @@ -103,6 +104,7 @@ def from_container(cls, library_key, container: Container, associated_collection
modified=draft.created,
draft_version_num=draft.version_num,
published_version_num=published.version_num if published else None,
published_display_name=published.title if published else None,
last_published=None if last_publish_log is None else last_publish_log.published_at,
published_by=published_by,
last_draft_created=last_draft_created,
Expand Down
Loading