Remove 'View In Studio' link from vertical
in favor of display in the Staff Instructor Toolbar.
This commit is contained in:
@@ -1712,104 +1712,6 @@ class JsonInitDataTest(ModuleStoreTestCase):
|
||||
self.assertEqual(html.count("</script>"), 1)
|
||||
|
||||
|
||||
class ViewInStudioTest(ModuleStoreTestCase):
|
||||
"""Tests for the 'View in Studio' link visiblity."""
|
||||
|
||||
def setUp(self):
|
||||
""" Set up the user and request that will be used. """
|
||||
super(ViewInStudioTest, self).setUp()
|
||||
self.staff_user = GlobalStaffFactory.create()
|
||||
self.request = RequestFactoryNoCsrf().get('/')
|
||||
self.request.user = self.staff_user
|
||||
self.request.session = {}
|
||||
self.module = None
|
||||
self.default_context = {'bookmarked': False, 'username': self.user.username}
|
||||
|
||||
def _get_module(self, course_id, descriptor, location):
|
||||
"""
|
||||
Get the module from the course from which to pattern match (or not) the 'View in Studio' buttons
|
||||
"""
|
||||
field_data_cache = FieldDataCache.cache_for_descriptor_descendents(
|
||||
course_id,
|
||||
self.staff_user,
|
||||
descriptor
|
||||
)
|
||||
|
||||
return render.get_module(
|
||||
self.staff_user,
|
||||
self.request,
|
||||
location,
|
||||
field_data_cache,
|
||||
)
|
||||
|
||||
def setup_mongo_course(self, course_edit_method='Studio'):
|
||||
""" Create a mongo backed course. """
|
||||
course = CourseFactory.create(
|
||||
course_edit_method=course_edit_method
|
||||
)
|
||||
|
||||
descriptor = ItemFactory.create(
|
||||
category='vertical',
|
||||
parent_location=course.location,
|
||||
)
|
||||
|
||||
child_descriptor = ItemFactory.create(
|
||||
category='vertical',
|
||||
parent_location=descriptor.location
|
||||
)
|
||||
|
||||
self.module = self._get_module(course.id, descriptor, descriptor.location)
|
||||
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
self.child_module = self._get_module(course.id, child_descriptor, child_descriptor.location)
|
||||
|
||||
|
||||
class MongoViewInStudioTest(ViewInStudioTest):
|
||||
"""Test the 'View in Studio' link visibility in a mongo backed course."""
|
||||
|
||||
def test_view_in_studio_link_studio_course(self):
|
||||
"""Regular Studio courses should see 'View in Studio' links."""
|
||||
self.setup_mongo_course()
|
||||
result_fragment = self.module.render(STUDENT_VIEW, context=self.default_context)
|
||||
self.assertIn('View Unit in Studio', result_fragment.content)
|
||||
|
||||
def test_view_in_studio_link_only_in_top_level_vertical(self):
|
||||
"""Regular Studio courses should not see 'View in Studio' for child verticals of verticals."""
|
||||
self.setup_mongo_course()
|
||||
# Render the parent vertical, then check that there is only a single "View Unit in Studio" link.
|
||||
result_fragment = self.module.render(STUDENT_VIEW, context=self.default_context)
|
||||
# The single "View Unit in Studio" link should appear before the first xmodule vertical definition.
|
||||
parts = result_fragment.content.split('data-block-type="vertical"')
|
||||
self.assertEqual(3, len(parts), "Did not find two vertical blocks")
|
||||
self.assertIn('View Unit in Studio', parts[0])
|
||||
self.assertNotIn('View Unit in Studio', parts[1])
|
||||
self.assertNotIn('View Unit in Studio', parts[2])
|
||||
|
||||
def test_view_in_studio_link_xml_authored(self):
|
||||
"""Courses that change 'course_edit_method' setting can hide 'View in Studio' links."""
|
||||
self.setup_mongo_course(course_edit_method='XML')
|
||||
result_fragment = self.module.render(STUDENT_VIEW, context=self.default_context)
|
||||
self.assertNotIn('View Unit in Studio', result_fragment.content)
|
||||
|
||||
|
||||
class MixedViewInStudioTest(ViewInStudioTest):
|
||||
"""Test the 'View in Studio' link visibility in a mixed mongo backed course."""
|
||||
|
||||
MODULESTORE = TEST_DATA_MIXED_MODULESTORE
|
||||
|
||||
def test_view_in_studio_link_mongo_backed(self):
|
||||
"""Mixed mongo courses that are mongo backed should see 'View in Studio' links."""
|
||||
self.setup_mongo_course()
|
||||
result_fragment = self.module.render(STUDENT_VIEW, context=self.default_context)
|
||||
self.assertIn('View Unit in Studio', result_fragment.content)
|
||||
|
||||
def test_view_in_studio_link_xml_authored(self):
|
||||
"""Courses that change 'course_edit_method' setting can hide 'View in Studio' links."""
|
||||
self.setup_mongo_course(course_edit_method='XML')
|
||||
result_fragment = self.module.render(STUDENT_VIEW, context=self.default_context)
|
||||
self.assertNotIn('View Unit in Studio', result_fragment.content)
|
||||
|
||||
|
||||
@XBlock.tag("detached")
|
||||
class DetachedXBlock(XBlock):
|
||||
"""
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<%page expression_filter="h"/>
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
|
||||
<div class="wrap-instructor-info studio-view">
|
||||
<a class="instructor-info-action" href="${edit_link}">${_("View Unit in Studio")}</a>
|
||||
</div>
|
||||
${frag_content | n, decode.utf8}
|
||||
@@ -323,23 +323,7 @@ def add_staff_markup(user, disable_staff_debug_info, block, view, frag, context)
|
||||
return frag
|
||||
# TODO: make this more general, eg use an XModule attribute instead
|
||||
if isinstance(block, VerticalBlock) and (not context or not context.get('child_of_vertical', False)):
|
||||
# check that the course is a mongo backed Studio course before doing work
|
||||
is_studio_course = block.course_edit_method == "Studio"
|
||||
|
||||
if is_studio_course:
|
||||
# build edit link to unit in CMS. Can't use reverse here as lms doesn't load cms's urls.py
|
||||
edit_link = "//" + settings.CMS_BASE + '/container/' + text_type(block.location)
|
||||
|
||||
# return edit link in rendered HTML for display
|
||||
return wrap_fragment(
|
||||
frag,
|
||||
render_to_string(
|
||||
"edit_unit_link.html",
|
||||
{'frag_content': frag.content, 'edit_link': edit_link}
|
||||
)
|
||||
)
|
||||
else:
|
||||
return frag
|
||||
return frag
|
||||
|
||||
if isinstance(block, SequenceModule) or getattr(block, 'HIDDEN', False):
|
||||
return frag
|
||||
|
||||
Reference in New Issue
Block a user