xblock save only affects draft
Fix test which caused error
This commit is contained in:
@@ -26,7 +26,7 @@ from xblock.runtime import Mixologist
|
||||
|
||||
from lms.lib.xblock.runtime import unquote_slashes
|
||||
|
||||
from contentstore.utils import get_lms_link_for_item, compute_unit_state, UnitState
|
||||
from contentstore.utils import get_lms_link_for_item, compute_unit_state, UnitState, get_modulestore
|
||||
from contentstore.views.helpers import get_parent_xblock
|
||||
|
||||
from models.settings.course_grading import CourseGradingModel
|
||||
@@ -358,7 +358,7 @@ def component_handler(request, usage_id, handler, suffix=''):
|
||||
|
||||
location = unquote_slashes(usage_id)
|
||||
|
||||
descriptor = modulestore().get_item(location)
|
||||
descriptor = get_modulestore(location).get_item(location)
|
||||
# Let the module handle the AJAX
|
||||
req = django_to_webob_request(request)
|
||||
|
||||
@@ -371,9 +371,6 @@ def component_handler(request, usage_id, handler, suffix=''):
|
||||
|
||||
# unintentional update to handle any side effects of handle call; so, request user didn't author
|
||||
# the change
|
||||
if getattr(descriptor, 'is_draft', False):
|
||||
modulestore('draft').update_item(descriptor, None)
|
||||
else:
|
||||
modulestore('direct').update_item(descriptor, None)
|
||||
get_modulestore(location).update_item(descriptor, None)
|
||||
|
||||
return webob_to_django_response(resp)
|
||||
|
||||
@@ -202,12 +202,9 @@ def xblock_view_handler(request, package_id, view_name, tag=None, branch=None, v
|
||||
log.debug("unable to render studio_view for %r", component, exc_info=True)
|
||||
fragment = Fragment(render_to_string('html_error.html', {'message': str(exc)}))
|
||||
|
||||
# change not authored by requestor but by xblocks. should not convert to draft if not
|
||||
# already draft
|
||||
if getattr(component, 'is_draft', False):
|
||||
modulestore('draft').update_item(component, None)
|
||||
else:
|
||||
modulestore('direct').update_item(component, None)
|
||||
# change not authored by requestor but by xblocks.
|
||||
store.update_item(component, None)
|
||||
|
||||
elif view_name == 'student_view' and component.has_children:
|
||||
# For non-leaf xblocks on the unit page, show the special rendering
|
||||
# which links to the new container page.
|
||||
|
||||
@@ -636,11 +636,11 @@ class TestComponentHandler(TestCase):
|
||||
def setUp(self):
|
||||
self.request_factory = RequestFactory()
|
||||
|
||||
patcher = patch('contentstore.views.component.modulestore')
|
||||
self.modulestore = patcher.start()
|
||||
patcher = patch('contentstore.views.component.get_modulestore')
|
||||
self.get_modulestore = patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
self.descriptor = self.modulestore.return_value.get_item.return_value
|
||||
self.descriptor = self.get_modulestore.return_value.get_item.return_value
|
||||
|
||||
self.usage_id = 'dummy_usage_id'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user