Don't allow visibility editing in content libraries
This commit is contained in:
@@ -17,6 +17,7 @@ from xmodule.exceptions import NotFoundError, ProcessingError
|
||||
from xmodule.library_tools import LibraryToolsService
|
||||
from xmodule.modulestore.django import modulestore, ModuleI18nService
|
||||
from opaque_keys.edx.keys import UsageKey
|
||||
from opaque_keys.edx.locator import LibraryUsageLocator
|
||||
from xmodule.x_module import ModuleSystem
|
||||
from xblock.runtime import KvsFieldData
|
||||
from xblock.django.request import webob_to_django_response, django_to_webob_request
|
||||
@@ -242,6 +243,7 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
|
||||
# Only add the Studio wrapper when on the container page. The "Pages" page will remain as is for now.
|
||||
if not context.get('is_pages_view', None) and view in PREVIEW_VIEWS:
|
||||
root_xblock = context.get('root_xblock')
|
||||
can_edit_visibility = not isinstance(xblock.location, LibraryUsageLocator)
|
||||
is_root = root_xblock and xblock.location == root_xblock.location
|
||||
is_reorderable = _is_xblock_reorderable(xblock, context)
|
||||
template_context = {
|
||||
@@ -251,6 +253,7 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
|
||||
'is_root': is_root,
|
||||
'is_reorderable': is_reorderable,
|
||||
'can_edit': context.get('can_edit', True),
|
||||
'can_edit_visibility': can_edit_visibility,
|
||||
}
|
||||
html = render_to_string('studio_xblock_wrapper.html', template_context)
|
||||
frag = wrap_fragment(frag, html)
|
||||
|
||||
@@ -122,6 +122,12 @@ FEATURES = {
|
||||
# for consistency in user-experience, keep the value of this feature flag
|
||||
# in sync with the one in lms/envs/common.py
|
||||
'ENABLE_EDXNOTES': False,
|
||||
|
||||
# Enable support for content libraries. Note that content libraries are
|
||||
# only supported in courses using split mongo. Change the setting
|
||||
# DEFAULT_STORE_FOR_NEW_COURSE to be 'split' to have future courses
|
||||
# and libraries created with split.
|
||||
'ENABLE_CONTENT_LIBRARIES': False,
|
||||
}
|
||||
ENABLE_JASMINE = False
|
||||
|
||||
|
||||
@@ -594,6 +594,7 @@ define(["jquery", "underscore", "underscore.string", "js/common_helpers/ajax_hel
|
||||
});
|
||||
}
|
||||
|
||||
// Create a suite for a non-paged container that includes 'edit visibility' buttons
|
||||
parameterized_suite("Non paged",
|
||||
{ },
|
||||
{
|
||||
@@ -603,6 +604,8 @@ define(["jquery", "underscore", "underscore.string", "js/common_helpers/ajax_hel
|
||||
has_visibility_editor: true
|
||||
}
|
||||
);
|
||||
|
||||
// Create a suite for a paged container that does not include 'edit visibility' buttons
|
||||
parameterized_suite("Paged",
|
||||
{ page_size: 42 },
|
||||
{
|
||||
@@ -610,5 +613,6 @@ define(["jquery", "underscore", "underscore.string", "js/common_helpers/ajax_hel
|
||||
initial: 'mock/mock-container-paged-xblock.underscore',
|
||||
add_response: 'mock/mock-xblock-paged.underscore',
|
||||
has_visibility_editor: false
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
@@ -68,6 +68,14 @@ messages = json.dumps(xblock.validate().to_json())
|
||||
<span class="action-button-text">${_("Edit")}</span>
|
||||
</a>
|
||||
</li>
|
||||
% if can_edit_visibility:
|
||||
<li class="action-item action-visibility">
|
||||
<a href="#" data-tooltip="${_("Visibility Settings")}" class="visibility-button action-button">
|
||||
<i class="icon fa fa-eye" aria-hidden="true"></i>
|
||||
<span class="sr">${_("Visibility")}</span>
|
||||
</a>
|
||||
</li>
|
||||
% endif
|
||||
<li class="action-item action-duplicate">
|
||||
<a href="#" data-tooltip="${_("Duplicate")}" class="duplicate-button action-button">
|
||||
<i class="icon fa fa-copy"></i>
|
||||
@@ -81,18 +89,6 @@ messages = json.dumps(xblock.validate().to_json())
|
||||
<span class="sr">${_("Delete")}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="action-item action-visibility">
|
||||
<a href="#" data-tooltip="${_("Visibility Settings")}" class="visibility-button action-button">
|
||||
<i class="icon fa fa-eye" aria-hidden="true"></i>
|
||||
<span class="sr">${_("Visibility")}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="action-item action-duplicate">
|
||||
<a href="#" data-tooltip="${_("Duplicate")}" class="duplicate-button action-button">
|
||||
<i class="icon fa fa-copy"></i>
|
||||
<span class="sr">${_("Duplicate")}</span>
|
||||
</a>
|
||||
</li>
|
||||
% if is_reorderable:
|
||||
<li class="action-item action-drag">
|
||||
<span data-tooltip="${_('Drag to reorder')}" class="drag-handle action"></span>
|
||||
|
||||
@@ -406,6 +406,14 @@ class XBlockWrapper(PageObject):
|
||||
def has_group_visibility_set(self):
|
||||
return self.q(css=self._bounded_selector('.wrapper-xblock.has-group-visibility-set')).is_present()
|
||||
|
||||
@property
|
||||
def has_edit_visibility_button(self):
|
||||
"""
|
||||
Returns true if this xblock has an 'edit visibility' button
|
||||
:return:
|
||||
"""
|
||||
return self.q(css=self._bounded_selector('.visibility-button')).is_present()
|
||||
|
||||
def go_to_container(self):
|
||||
"""
|
||||
Open the container page linked to by this xblock, and return
|
||||
|
||||
@@ -69,6 +69,18 @@ class LibraryEditPageTest(StudioLibraryTest):
|
||||
self.assertEqual(len(self.lib_page.xblocks), 1)
|
||||
self.assertEqual(self.lib_page.xblocks[0].locator, second_block_id)
|
||||
|
||||
def test_no_edit_visibility_button(self):
|
||||
"""
|
||||
Scenario: Ensure that library xblocks do not have 'edit visibility' buttons.
|
||||
Given I have a library in Studio with no XBlocks
|
||||
And I navigate to Library Page in Studio
|
||||
When I add Text XBlock
|
||||
Then one XBlock is displayed
|
||||
And no 'edit visibility' button is shown
|
||||
"""
|
||||
add_component(self.lib_page, "html", "Text")
|
||||
self.assertFalse(self.lib_page.xblocks[0].has_edit_visibility_button)
|
||||
|
||||
def test_add_edit_xblock(self):
|
||||
"""
|
||||
Scenario: Ensure that we can add an XBlock, edit it, then see the resulting changes.
|
||||
|
||||
Reference in New Issue
Block a user