diff --git a/xblock/VERSION.txt b/xblock/VERSION.txt index 3a3cd8cc8..88c5fb891 100644 --- a/xblock/VERSION.txt +++ b/xblock/VERSION.txt @@ -1 +1 @@ -1.3.1 +1.4.0 diff --git a/xblock/mixins.py b/xblock/mixins.py index 160c95c8f..6c8ba3790 100644 --- a/xblock/mixins.py +++ b/xblock/mixins.py @@ -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: