Skip to content

Commit

Permalink
Merge pull request #469 from open-craft/ahmed/bb-2607-add-component-t…
Browse files Browse the repository at this point in the history
…itle-to-search-indexing

[BD-29] [TNL-7060]: Add titles to course search indexing for all xblocks
  • Loading branch information
Dave St.Germain authored Aug 4, 2020
2 parents 520f884 + c1bc100 commit 07830a5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion xblock/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.1
1.4.0
26 changes: 24 additions & 2 deletions xblock/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,31 @@ def index_dictionary(self):
"""
return key/value fields to feed an index within in a Python dict object
values may be numeric / string or dict
default implementation is an empty dict
"""
return {}
display_name = getattr(self, "display_name", None)

# Getting self.display_name.default wouldn't work as self.display_name is actually
# a str after the class instance is created. So, we can only access the default value
# of display_name field by accessing class variable of same name
content_type = getattr(
getattr(self.__class__, "display_name", None), "default", None
)

_index_dictionary = dict()

if display_name is not None:
_index_dictionary.update({
"content": {
"display_name": display_name
}
})

if content_type is not None:
_index_dictionary.update({
"content_type": content_type
})

return _index_dictionary


class ViewsMixin:
Expand Down

0 comments on commit 07830a5

Please sign in to comment.