From 240fcc1d5a9c10f577fdddfdd46735b83f6bae1a Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 22 May 2014 11:15:04 -0400 Subject: [PATCH] Fix merge conflicts --- .../contentstore/tests/test_contentstore.py | 11 -- .../contentstore/views/component.py | 10 +- cms/djangoapps/contentstore/views/item.py | 26 +--- cms/djangoapps/contentstore/views/preview.py | 9 -- .../views/tests/test_container.py | 144 ------------------ .../views/tests/test_container_page.py | 4 +- .../js/spec/views/pages/container_spec.js | 2 +- cms/static/js/spec/views/unit_spec.js | 13 -- cms/static/js/spec_helpers/edit_helpers.js | 2 +- cms/static/js/utils/module.js | 10 +- cms/static/js/views/pages/container.js | 4 +- cms/templates/container.html | 6 +- cms/templates/studio_container_wrapper.html | 4 +- cms/templates/studio_xblock_wrapper.html | 12 +- cms/templates/unit.html | 10 +- common/djangoapps/student/views.py | 26 ---- lms/templates/notes.html | 13 -- lms/templates/textannotation.html | 46 ------ lms/templates/videoannotation.html | 21 --- 19 files changed, 24 insertions(+), 349 deletions(-) delete mode 100644 cms/djangoapps/contentstore/views/tests/test_container.py diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index 778dc15110..5d1ca5ffaf 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -356,17 +356,6 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): """ Tests the ajax callback to render an XModule """ -<<<<<<< HEAD -======= - resp = self._test_preview(Location('i4x', 'edX', 'toy', 'vertical', 'vertical_test', None), 'container_preview') - self.assertContains(resp, '/branch/draft/block/sample_video') - self.assertContains(resp, '/branch/draft/block/separate_file_video') - self.assertContains(resp, '/branch/draft/block/video_with_end_time') - self.assertContains(resp, '/branch/draft/block/T1_changemind_poll_foo_2') - - def _test_preview(self, location, view_name): - """ Preview test case. """ ->>>>>>> edx/master direct_store = modulestore('direct') _, course_items = import_from_xml(direct_store, 'common/test/data/', ['toy']) usage_key = course_items[0].id.make_usage_key('vertical', 'vertical_test') diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index 7e507fe284..38c73e07cf 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -196,15 +196,9 @@ def unit_handler(request, usage_key_string): return render_to_response('unit.html', { 'context_course': course, 'unit': item, -<<<<<<< HEAD - 'unit_locator': usage_key, - 'xblocks': xblocks, - 'component_templates': component_templates, -======= - 'unit_locator': locator, - 'locators': locators, + 'unit_usage_key': usage_key, + 'child_usage_keys': [block.scope_ids.usage_id for block in xblocks], 'component_templates': json.dumps(component_templates), ->>>>>>> edx/master 'draft_preview_link': preview_lms_link, 'published_preview_link': lms_link, 'subsection': containing_subsection, diff --git a/cms/djangoapps/contentstore/views/item.py b/cms/djangoapps/contentstore/views/item.py index 7de471b138..6eba2559db 100644 --- a/cms/djangoapps/contentstore/views/item.py +++ b/cms/djangoapps/contentstore/views/item.py @@ -20,13 +20,8 @@ from xblock.fields import Scope from xblock.fragment import Fragment import xmodule -<<<<<<< HEAD from xmodule.modulestore.django import modulestore -from xmodule.modulestore.exceptions import ItemNotFoundError, InvalidLocationError -======= -from xmodule.modulestore.django import modulestore, loc_mapper from xmodule.modulestore.exceptions import ItemNotFoundError, InvalidLocationError, DuplicateItemError ->>>>>>> edx/master from xmodule.modulestore.inheritance import own_metadata from xmodule.video_module import manage_video_subtitles_save @@ -182,25 +177,15 @@ def xblock_view_handler(request, usage_key_string, view_name): accept_header = request.META.get('HTTP_ACCEPT', 'application/json') if 'application/json' in accept_header: -<<<<<<< HEAD store = get_modulestore(usage_key) - component = store.get_item(usage_key) - is_read_only = _xblock_is_read_only(component) - - # wrap the generated fragment in the xmodule_editor div so that the javascript - # can bind to it correctly - component.runtime.wrappers.append(partial(wrap_xblock, 'StudioRuntime', usage_id_serializer=unicode)) -======= - store = get_modulestore(old_location) - xblock = store.get_item(old_location) + xblock = store.get_item(usage_key) is_read_only = _is_xblock_read_only(xblock) container_views = ['container_preview', 'reorderable_container_child_preview'] unit_views = ['student_view'] # wrap the generated fragment in the xmodule_editor div so that the javascript # can bind to it correctly - xblock.runtime.wrappers.append(partial(wrap_xblock, 'StudioRuntime')) ->>>>>>> edx/master + xblock.runtime.wrappers.append(partial(wrap_xblock, 'StudioRuntime', usage_id_serializer=unicode)) if view_name == 'studio_view': try: @@ -226,13 +211,8 @@ def xblock_view_handler(request, usage_key_string, view_name): # which links to the new container page. html = render_to_string('container_xblock_component.html', { 'xblock_context': context, -<<<<<<< HEAD - 'xblock': component, - 'locator': usage_key, -======= 'xblock': xblock, - 'locator': locator, ->>>>>>> edx/master + 'locator': usage_key, }) return JsonResponse({ 'html': html, diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index 6e27611e5f..87f1beb9a5 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -27,12 +27,7 @@ from util.sandboxing import can_execute_unsafe_code import static_replace from .session_kv_store import SessionKeyValueStore -<<<<<<< HEAD -from .helpers import render_from_lms -======= from .helpers import render_from_lms, xblock_has_own_studio_page -from ..utils import get_course_for_item ->>>>>>> edx/master from contentstore.views.access import get_user_role @@ -175,13 +170,9 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False): """ # Only add the Studio wrapper when on the container page. The unit page will remain as is for now. if context.get('container_view', None) and view == 'student_view': -<<<<<<< HEAD -======= root_xblock = context.get('root_xblock') is_root = root_xblock and xblock.location == root_xblock.location - locator = loc_mapper().translate_location(xblock.course_id, xblock.location, published=False) is_reorderable = _is_xblock_reorderable(xblock, context) ->>>>>>> edx/master template_context = { 'xblock_context': context, 'xblock': xblock, diff --git a/cms/djangoapps/contentstore/views/tests/test_container.py b/cms/djangoapps/contentstore/views/tests/test_container.py deleted file mode 100644 index c3914fabb7..0000000000 --- a/cms/djangoapps/contentstore/views/tests/test_container.py +++ /dev/null @@ -1,144 +0,0 @@ -""" -Unit tests for the container view. -""" - -import json - -from contentstore.tests.utils import CourseTestCase -from contentstore.utils import compute_publish_state, PublishState -from contentstore.views.helpers import xblock_studio_url -from xmodule.modulestore.django import modulestore -from xmodule.modulestore.tests.factories import ItemFactory - - -class ContainerViewTestCase(CourseTestCase): - """ - Unit tests for the container view. - """ - - def setUp(self): - super(ContainerViewTestCase, self).setUp() - self.chapter = ItemFactory.create(parent_location=self.course.location, - category='chapter', display_name="Week 1") - self.sequential = ItemFactory.create(parent_location=self.chapter.location, - category='sequential', display_name="Lesson 1") - self.vertical = ItemFactory.create(parent_location=self.sequential.location, - category='vertical', display_name='Unit') - self.child_vertical = ItemFactory.create(parent_location=self.vertical.location, - category='vertical', display_name='Child Vertical') - self.video = ItemFactory.create(parent_location=self.child_vertical.location, - category="video", display_name="My Video") - - def test_container_html(self): - self._test_html_content( - self.child_vertical, - expected_location_in_section_tag=self.child_vertical.location, - expected_breadcrumbs=( - r'Unit\s*' - r'Child Vertical' - ).format(unit_location=(unicode(self.vertical.location).replace("+", "\\+"))) - ) - - def test_container_on_container_html(self): - """ - Create the scenario of an xblock with children (non-vertical) on the container page. - This should create a container page that is a child of another container page. - """ - published_xblock_with_child = ItemFactory.create( - parent_location=self.child_vertical.location, - category="wrapper", display_name="Wrapper" - ) - ItemFactory.create( - parent_location=published_xblock_with_child.location, - category="html", display_name="Child HTML" - ) - expected_breadcrumbs = ( - r'Unit\s*' - r'Child Vertical\s*' - r'Wrapper' - ).format( - unit_location=unicode(self.vertical.location).replace("+", "\\+"), - child_vertical_location=unicode(self.child_vertical.location).replace("+", "\\+"), - ) - self._test_html_content( - published_xblock_with_child, - expected_location_in_section_tag=published_xblock_with_child.location, - expected_breadcrumbs=expected_breadcrumbs - ) - - # Now make the unit and its children into a draft and validate the container again - modulestore('draft').convert_to_draft(self.vertical.location) - modulestore('draft').convert_to_draft(self.child_vertical.location) - draft_xblock_with_child = modulestore('draft').convert_to_draft(published_xblock_with_child.location) - self._test_html_content( - draft_xblock_with_child, - expected_location_in_section_tag=draft_xblock_with_child.location, - expected_breadcrumbs=expected_breadcrumbs - ) - - def _test_html_content(self, xblock, expected_location_in_section_tag, expected_breadcrumbs): - """ - Get the HTML for a container page and verify the section tag is correct - and the breadcrumbs trail is correct. - """ - publish_state = compute_publish_state(xblock) - url = xblock_studio_url(xblock) - resp = self.client.get_html(url) - self.assertEqual(resp.status_code, 200) - html = resp.content - expected_section_tag = \ - '