Skip to content

Commit

Permalink
fix: remove url from index
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Feb 21, 2025
1 parent 9bf84b2 commit 6b27c09
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 26 deletions.
17 changes: 2 additions & 15 deletions openedx/core/djangoapps/content/search/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class Fields:
context_key = "context_key"
org = "org"
access_id = "access_id" # .models.SearchAccess.id
# breadcrumbs: an array of {"display_name": "...", "usage_key": "...", "url": "..."} entries.
# First one is the name of the course/library itself.
# breadcrumbs: an array of {"display_name": "..."} entries. First one is the name of the course/library itself.
# After that is the name of any parent Section/Subsection/Unit/etc.
# It's a list of dictionaries because for now we just include the name of each but in future we may add their IDs.
breadcrumbs = "breadcrumbs"
# tags (dictionary)
# See https://blog.meilisearch.com/nested-hierarchical-facets-guide/
Expand Down Expand Up @@ -199,7 +199,6 @@ def _fields_from_block(block) -> dict:
class implementation returns only:
{"content": {"display_name": "..."}, "content_type": "..."}
"""

block_type = block.scope_ids.block_type
block_data = {
Fields.usage_key: str(block.usage_key),
Expand All @@ -214,9 +213,6 @@ class implementation returns only:
}
# Get the breadcrumbs (course, section, subsection, etc.):
if block.usage_key.context_key.is_course: # Getting parent is not yet implemented in Learning Core (for libraries).
# Import here to avoid circular imports
from cms.djangoapps.contentstore.utils import reverse_course_url, reverse_usage_url

cur_block = block
while cur_block.parent:
if not cur_block.has_cached_parent:
Expand All @@ -229,15 +225,6 @@ class implementation returns only:
}
if cur_block.scope_ids.block_type != "course":
parent_data["usage_key"] = str(cur_block.usage_key)
# Section and subsections don't have URLs in the CMS
if cur_block.scope_ids.block_type not in ["chapter", "sequential"]:
parent_data["url"] = (
reverse_course_url("course_handler", cur_block.context_key) +
reverse_usage_url("container_handler", cur_block.usage_key)
)
else:
parent_data["url"] = reverse_course_url("course_handler", cur_block.context_key)

block_data[Fields.breadcrumbs].insert(
0,
parent_data,
Expand Down
2 changes: 0 additions & 2 deletions openedx/core/djangoapps/content/search/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def setUp(self):
"breadcrumbs": [
{
"display_name": "Test Course",
"url": "/course/course-v1:org1+test_course+test_run"
},
],
"content": {},
Expand All @@ -104,7 +103,6 @@ def setUp(self):
"breadcrumbs": [
{
"display_name": "Test Course",
"url": "/course/course-v1:org1+test_course+test_run"
},
{
"display_name": "sequential",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ def test_problem_block(self):
"breadcrumbs": [
{
'display_name': 'Toy Course',
'url': '/course/course-v1:edX+toy+2012_Fall',
},
{
'display_name': 'chapter',
Expand All @@ -171,10 +170,6 @@ def test_problem_block(self):
{
'display_name': 'vertical',
'usage_key': 'block-v1:edX+toy+2012_Fall+type@vertical+block@vertical_test',
'url': (
'/course/course-v1:edX+toy+2012_Fall'
'/container/block-v1:edX+toy+2012_Fall+type@vertical+block@vertical_test'
),
},
],
"content": {
Expand Down Expand Up @@ -213,7 +208,6 @@ def test_html_block(self):
"breadcrumbs": [
{
'display_name': 'Toy Course',
'url': '/course/course-v1:edX+toy+2012_Fall',
},
{
'display_name': 'Overview',
Expand Down Expand Up @@ -257,7 +251,6 @@ def test_video_block_untagged(self):
"breadcrumbs": [
{
'display_name': 'Toy Course',
'url': '/course/course-v1:edX+toy+2012_Fall',
},
{
'display_name': 'Overview',
Expand Down
2 changes: 0 additions & 2 deletions openedx/core/djangoapps/content/search/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def test_create_delete_xblock(self, meilisearch_client):
"breadcrumbs": [
{
"display_name": "Test Course",
"url": "/course/course-v1:orgA+test_course+test_run",
},
],
"content": {},
Expand All @@ -93,7 +92,6 @@ def test_create_delete_xblock(self, meilisearch_client):
"breadcrumbs": [
{
"display_name": "Test Course",
"url": "/course/course-v1:orgA+test_course+test_run",
},
{
"display_name": "sequential",
Expand Down

0 comments on commit 6b27c09

Please sign in to comment.