Commit 585c64f2 by Matjaz Gregoric

Enable staff debug everywhere except on detached blocks.

Staff markup was enabled on all block types in
https://github.com/edx/edx-platform/pull/10903

This works well inside the courseware, but it breaks layout of the course about
page, which is also an XModule, see:
https://github.com/edx/edx-platform/pull/10903#issuecomment-164266342

This commit disables staff markup/staff debug on all blocks except
blocks tagged with 'detached'. Detached blocks include course about
and info pages, static tabs.
parent 7f6e8b88
......@@ -1349,6 +1349,19 @@ class XmlViewInStudioTest(ViewInStudioTest):
self.assertNotIn('View Unit in Studio', result_fragment.content)
@XBlock.tag("detached")
class DetachedXBlock(XBlock):
"""
XBlock marked with the 'detached' flag.
"""
def student_view(self, context=None): # pylint: disable=unused-argument
"""
A simple view that returns just enough to test.
"""
frag = Fragment(u"Hello there!")
return frag
@attr('shard_1')
@patch.dict('django.conf.settings.FEATURES', {'DISPLAY_DEBUG_INFO_TO_STAFF': True, 'DISPLAY_HISTOGRAMS_TO_STAFF': True})
@patch('courseware.module_render.has_access', Mock(return_value=True, autospec=True))
......@@ -1404,6 +1417,28 @@ class TestStaffDebugInfo(ModuleStoreTestCase):
result_fragment = module.render(STUDENT_VIEW)
self.assertIn('Staff Debug', result_fragment.content)
@XBlock.register_temp_plugin(DetachedXBlock, identifier='detached-block')
def test_staff_debug_info_disabled_for_detached_blocks(self):
"""Staff markup should not be present on detached blocks."""
descriptor = ItemFactory.create(
category='detached-block',
display_name='Detached Block'
)
field_data_cache = FieldDataCache.cache_for_descriptor_descendents(
self.course.id,
self.user,
descriptor
)
module = render.get_module(
self.user,
self.request,
descriptor.location,
field_data_cache,
)
result_fragment = module.render(STUDENT_VIEW)
self.assertNotIn('Staff Debug', result_fragment.content)
@patch.dict('django.conf.settings.FEATURES', {'DISPLAY_HISTOGRAMS_TO_STAFF': False})
def test_histogram_disabled(self):
module = render.get_module(
......
......@@ -6,7 +6,7 @@ from django.template.defaultfilters import escapejs
## The JS for this is defined in xqa_interface.html
${block_content}
%if location.category in ['problem','video','html','combinedopenended','library_content']:
%if 'detached' not in tags:
% if edit_link:
<div>
<a href="${edit_link}">Edit</a>
......
......@@ -293,6 +293,7 @@ def add_staff_markup(user, has_instructor_access, disable_staff_debug_info, bloc
staff_context = {
'fields': field_contents,
'xml_attributes': getattr(block, 'xml_attributes', {}),
'tags': block._class_tags, # pylint: disable=protected-access
'location': block.location,
'xqa_key': block.xqa_key,
'source_file': source_file,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment