diff --git a/common/lib/xmodule/xmodule/vertical_block.py b/common/lib/xmodule/xmodule/vertical_block.py index e56f00a438..73b1717a8c 100644 --- a/common/lib/xmodule/xmodule/vertical_block.py +++ b/common/lib/xmodule/xmodule/vertical_block.py @@ -45,10 +45,14 @@ class VerticalBlock(SequenceFields, XModuleFields, StudioEditableBlock, XmlParse if context: child_context = copy(context) else: - child_context = { - 'bookmarked': self.runtime.service(self, 'bookmarks').is_bookmarked(usage_key=self.location), # pylint: disable=no-member - 'username': self.runtime.service(self, 'user').get_current_user().opt_attrs['edx-platform.username'] - } + child_context = {} + + if 'bookmarked' not in child_context: + bookmarks_service = self.runtime.service(self, 'bookmarks') + child_context['bookmarked'] = bookmarks_service.is_bookmarked(usage_key=self.location), # pylint: disable=no-member + if 'username' not in child_context: + user_service = self.runtime.service(self, 'user') + child_context['username'] = user_service.get_current_user().opt_attrs['edx-platform.username'] child_context['child_of_vertical'] = True @@ -68,7 +72,7 @@ class VerticalBlock(SequenceFields, XModuleFields, StudioEditableBlock, XmlParse 'items': contents, 'xblock_context': context, 'unit_title': self.display_name_with_default if not is_child_of_vertical else None, - 'show_bookmark_button': not is_child_of_vertical, + 'show_bookmark_button': child_context.get('show_bookmark_button', not is_child_of_vertical), 'bookmarked': child_context['bookmarked'], 'bookmark_id': u"{},{}".format(child_context['username'], unicode(self.location)) })) diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 4c0ddc7af3..d7cbc98c55 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -2000,7 +2000,7 @@ class TestRenderXBlock(RenderXBlockTestMixin, ModuleStoreTestCase): self.assertEqual(response.status_code, 404) self.assertIn('Page not found', response.content) - def get_response(self, url_encoded_params=None, usage_key=None): + def get_response(self, usage_key, url_encoded_params=None): """ Overridable method to get the response from the endpoint that is being tested. """ diff --git a/lms/djangoapps/courseware/testutils.py b/lms/djangoapps/courseware/testutils.py index e1fd191eea..43fde1eadf 100644 --- a/lms/djangoapps/courseware/testutils.py +++ b/lms/djangoapps/courseware/testutils.py @@ -1,6 +1,7 @@ """ Common test utilities for courseware functionality """ +# pylint: disable=attribute-defined-outside-init from abc import ABCMeta, abstractmethod from datetime import datetime @@ -31,7 +32,7 @@ class RenderXBlockTestMixin(object): '