From 8a9845c26ee5ffac3e428da9dc8e72c8d2d413c6 Mon Sep 17 00:00:00 2001 From: John Eskew Date: Wed, 23 Dec 2015 14:00:36 -0500 Subject: [PATCH] Remove ModuleStoreEnum.Type.xml --- .../commands/tests/test_create_course.py | 4 ---- common/djangoapps/static_replace/__init__.py | 3 +-- common/djangoapps/student/views.py | 1 - .../xmodule/xmodule/modulestore/__init__.py | 1 - .../tests/test_mixed_modulestore.py | 7 ++----- .../xmodule/modulestore/tests/test_xml.py | 4 ---- common/lib/xmodule/xmodule/modulestore/xml.py | 4 ++-- .../xmodule/modulestore/xml_exporter.py | 4 +--- lms/djangoapps/bulk_email/forms.py | 7 ------- lms/djangoapps/courseware/courses.py | 4 +--- lms/djangoapps/dashboard/sysadmin.py | 18 +----------------- lms/djangoapps/instructor/views/tools.py | 3 +-- lms/lib/xblock/test/test_mixin.py | 8 ++------ openedx/core/lib/courses.py | 2 +- openedx/core/lib/xblock_utils.py | 3 +-- 15 files changed, 13 insertions(+), 60 deletions(-) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py b/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py index 1bde9f7a07..5ae88a9345 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_create_course.py @@ -29,10 +29,6 @@ class TestArgParsing(unittest.TestCase): with self.assertRaises(CommandError): self.command.handle("foo", "user@foo.org", "org", "course", "run") - def test_xml_store(self): - with self.assertRaises(CommandError): - self.command.handle(ModuleStoreEnum.Type.xml, "user@foo.org", "org", "course", "run") - def test_nonexistent_user_id(self): errstring = "No user 99 found" with self.assertRaisesRegexp(CommandError, errstring): diff --git a/common/djangoapps/static_replace/__init__.py b/common/djangoapps/static_replace/__init__.py index 84c81bd187..5a12317ea9 100644 --- a/common/djangoapps/static_replace/__init__.py +++ b/common/djangoapps/static_replace/__init__.py @@ -164,8 +164,7 @@ def replace_static_urls(text, data_directory=None, course_id=None, static_asset_ return original # if we're running with a MongoBacked store course_namespace is not None, then use studio style urls elif (not static_asset_path) \ - and course_id \ - and modulestore().get_modulestore_type(course_id) != ModuleStoreEnum.Type.xml: + and course_id: # first look in the static file pipeline and see if we are trying to reference # a piece of static content which is in the edx-platform repo (e.g. JS associated with an xmodule) diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index 7cad92aa31..1698119c3f 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -649,7 +649,6 @@ def dashboard(request): show_email_settings_for = frozenset( enrollment.course_id for enrollment in course_enrollments if ( settings.FEATURES['ENABLE_INSTRUCTOR_EMAIL'] and - modulestore().get_modulestore_type(enrollment.course_id) != ModuleStoreEnum.Type.xml and CourseAuthorization.instructor_email_enabled(enrollment.course_id) ) ) diff --git a/common/lib/xmodule/xmodule/modulestore/__init__.py b/common/lib/xmodule/xmodule/modulestore/__init__.py index 4d2b3ae714..6e0e8671e6 100644 --- a/common/lib/xmodule/xmodule/modulestore/__init__.py +++ b/common/lib/xmodule/xmodule/modulestore/__init__.py @@ -55,7 +55,6 @@ class ModuleStoreEnum(object): """ split = 'split' mongo = 'mongo' - xml = 'xml' class RevisionOption(object): """ diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py index b31785cfce..5f1c8c0fd9 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py @@ -1991,11 +1991,8 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup): self.assertEquals(store.get_modulestore_type(), store_type) # verify store used for creating a course - try: - course = self.store.create_course("org", "course{}".format(uuid4().hex[:5]), "run", self.user_id) - self.assertEquals(course.system.modulestore.get_modulestore_type(), store_type) - except NotImplementedError: - self.assertEquals(store_type, ModuleStoreEnum.Type.xml) + course = self.store.create_course("org", "course{}".format(uuid4().hex[:5]), "run", self.user_id) + self.assertEquals(course.system.modulestore.get_modulestore_type(), store_type) @ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) def test_default_store(self, default_ms): diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_xml.py b/common/lib/xmodule/xmodule/modulestore/tests/test_xml.py index f029de4283..4da26acfd0 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_xml.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_xml.py @@ -31,10 +31,6 @@ class TestXMLModuleStore(unittest.TestCase): """ Test around the XML modulestore """ - def test_xml_modulestore_type(self): - store = XMLModuleStore(DATA_DIR, source_dirs=[]) - self.assertEqual(store.get_modulestore_type(), ModuleStoreEnum.Type.xml) - @patch('xmodule.tabs.CourseTabList.initialize_default', Mock()) def test_unicode_chars_in_xml_content(self): # edX/full/6.002_Spring_2012 has non-ASCII chars, and during diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py index c6b7b748ed..01aab51a5b 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml.py +++ b/common/lib/xmodule/xmodule/modulestore/xml.py @@ -875,7 +875,7 @@ class XMLModuleStore(ModuleStoreReadBase): Args: course_key: just for signature compatibility """ - return ModuleStoreEnum.Type.xml + return None #ModuleStoreEnum.Type.xml def get_courses_for_wiki(self, wiki_slug, **kwargs): """ @@ -893,7 +893,7 @@ class XMLModuleStore(ModuleStoreReadBase): Returns the course count """ - return {ModuleStoreEnum.Type.xml: True} + return {'xml': True} @contextmanager def branch_setting(self, branch_setting, course_id=None): # pylint: disable=unused-argument diff --git a/common/lib/xmodule/xmodule/modulestore/xml_exporter.py b/common/lib/xmodule/xmodule/modulestore/xml_exporter.py index 91066d485d..7468e6755a 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml_exporter.py +++ b/common/lib/xmodule/xmodule/modulestore/xml_exporter.py @@ -279,9 +279,7 @@ class CourseExportManager(ExportManager): policy = {'course/' + courselike.location.name: own_metadata(courselike)} course_policy.write(dumps(policy, cls=EdxJSONEncoder, sort_keys=True, indent=4)) - # xml backed courses don't support drafts! - if courselike.runtime.modulestore.get_modulestore_type() != ModuleStoreEnum.Type.xml: - _export_drafts(self.modulestore, self.courselike_key, export_fs, xml_centric_courselike_key) + _export_drafts(self.modulestore, self.courselike_key, export_fs, xml_centric_courselike_key) class LibraryExportManager(ExportManager): diff --git a/lms/djangoapps/bulk_email/forms.py b/lms/djangoapps/bulk_email/forms.py index 6fdec1459f..32d91443c5 100644 --- a/lms/djangoapps/bulk_email/forms.py +++ b/lms/djangoapps/bulk_email/forms.py @@ -100,11 +100,4 @@ class CourseAuthorizationAdminForm(forms.ModelForm): msg += 'Please recheck that you have supplied a valid course id.' raise forms.ValidationError(msg) - # Now, try and discern if it is a Studio course - HTML editor doesn't work with XML courses - is_studio_course = modulestore().get_modulestore_type(course_key) != ModuleStoreEnum.Type.xml - if not is_studio_course: - msg = "Course Email feature is only available for courses authored in Studio. " - msg += '"{0}" appears to be an XML backed course.'.format(course_key.to_deprecated_string()) - raise forms.ValidationError(msg) - return course_key diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index 252bb598cf..1b63685156 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -453,10 +453,8 @@ def get_studio_url(course, page): Args: course (CourseDescriptor) """ - is_studio_course = course.course_edit_method == "Studio" - is_mongo_course = modulestore().get_modulestore_type(course.id) != ModuleStoreEnum.Type.xml studio_link = None - if is_studio_course and is_mongo_course: + if course.course_edit_method == "Studio": studio_link = get_cms_course_link(course, page) return studio_link diff --git a/lms/djangoapps/dashboard/sysadmin.py b/lms/djangoapps/dashboard/sysadmin.py index 3d89a86f77..4273035d9e 100644 --- a/lms/djangoapps/dashboard/sysadmin.py +++ b/lms/djangoapps/dashboard/sysadmin.py @@ -491,23 +491,7 @@ class Courses(SysadminDashboardView): escape(str(err)) ) - is_xml_course = (modulestore().get_modulestore_type(course_key) == ModuleStoreEnum.Type.xml) - if course_found and is_xml_course: - cdir = course.data_dir - self.def_ms.courses.pop(cdir) - - # now move the directory (don't actually delete it) - new_dir = "{course_dir}_deleted_{timestamp}".format( - course_dir=cdir, - timestamp=int(time.time()) - ) - os.rename(settings.DATA_DIR / cdir, settings.DATA_DIR / new_dir) - - self.msg += (u"Deleted " - u"{0} = {1} ({2})".format( - cdir, course.id, course.display_name)) - - elif course_found and not is_xml_course: + if course_found: # delete course that is stored with mongodb backend self.def_ms.delete_course(course.id, request.user.id) # don't delete user permission groups, though diff --git a/lms/djangoapps/instructor/views/tools.py b/lms/djangoapps/instructor/views/tools.py index d1bbb66269..1bfb96d910 100644 --- a/lms/djangoapps/instructor/views/tools.py +++ b/lms/djangoapps/instructor/views/tools.py @@ -66,10 +66,9 @@ def bulk_email_is_enabled_for_course(course_id): """ bulk_email_enabled_globally = (settings.FEATURES['ENABLE_INSTRUCTOR_EMAIL'] is True) - is_studio_course = (modulestore().get_modulestore_type(course_id) != ModuleStoreEnum.Type.xml) bulk_email_enabled_for_course = CourseAuthorization.instructor_email_enabled(course_id) - if bulk_email_enabled_globally and is_studio_course and bulk_email_enabled_for_course: + if bulk_email_enabled_globally and bulk_email_enabled_for_course: return True return False diff --git a/lms/lib/xblock/test/test_mixin.py b/lms/lib/xblock/test/test_mixin.py index 6cb4d3c52c..3b501b3737 100644 --- a/lms/lib/xblock/test/test_mixin.py +++ b/lms/lib/xblock/test/test_mixin.py @@ -159,19 +159,15 @@ class XBlockGetParentTest(LmsXBlockMixinTestCase): """ MODULESTORE = TEST_DATA_MIXED_MODULESTORE - @ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split, ModuleStoreEnum.Type.xml) + @ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) def test_parents(self, modulestore_type): with self.store.default_store(modulestore_type): # setting up our own local course tree here, since it needs to be # created with the correct modulestore type. - if modulestore_type == 'xml': - course_key = self.store.make_course_key('edX', 'toy', '2012_Fall') - else: - course_key = ToyCourseFactory.create(run='2012_Fall_copy').id + course_key = ToyCourseFactory.create().id course = self.store.get_course(course_key) - self.assertIsNone(course.get_parent()) def recurse(parent): diff --git a/openedx/core/lib/courses.py b/openedx/core/lib/courses.py index 2936cc93d8..ca5d3f13d8 100644 --- a/openedx/core/lib/courses.py +++ b/openedx/core/lib/courses.py @@ -13,7 +13,7 @@ from xmodule.modulestore import ModuleStoreEnum def course_image_url(course): """Try to look up the image url for the course. If it's not found, log an error and return the dead link""" - if course.static_asset_path or modulestore().get_modulestore_type(course.id) == ModuleStoreEnum.Type.xml: + if course.static_asset_path: # If we are a static course with the course_image attribute # set different than the default, return that path so that # courses can use custom course image paths, otherwise just diff --git a/openedx/core/lib/xblock_utils.py b/openedx/core/lib/xblock_utils.py index ab25b27639..2a0232436b 100644 --- a/openedx/core/lib/xblock_utils.py +++ b/openedx/core/lib/xblock_utils.py @@ -300,10 +300,9 @@ def add_staff_markup(user, has_instructor_access, disable_staff_debug_info, bloc # 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_mongo_course = modulestore().get_modulestore_type(block.location.course_key) != ModuleStoreEnum.Type.xml is_studio_course = block.course_edit_method == "Studio" - if is_studio_course and is_mongo_course: + 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/' + unicode(block.location)