Commit 0c74d6ac by Christina Roberts

Merge pull request #2562 from edx/christina/lms-mixed

Clean up of modulestore references (primarily LMS).
parents acb1c3aa 09d90b16
...@@ -3,8 +3,9 @@ Test finding orphans via the view and django config ...@@ -3,8 +3,9 @@ Test finding orphans via the view and django config
""" """
import json import json
from contentstore.tests.utils import CourseTestCase from contentstore.tests.utils import CourseTestCase
from xmodule.modulestore.django import editable_modulestore, loc_mapper from xmodule.modulestore.django import loc_mapper
from student.models import CourseEnrollment from student.models import CourseEnrollment
from xmodule.modulestore.django import modulestore
class TestOrphan(CourseTestCase): class TestOrphan(CourseTestCase):
""" """
...@@ -28,13 +29,14 @@ class TestOrphan(CourseTestCase): ...@@ -28,13 +29,14 @@ class TestOrphan(CourseTestCase):
def _create_item(self, category, name, data, metadata, parent_category, parent_name, runtime): def _create_item(self, category, name, data, metadata, parent_category, parent_name, runtime):
location = self.course.location.replace(category=category, name=name) location = self.course.location.replace(category=category, name=name)
editable_modulestore('direct').create_and_save_xmodule(location, data, metadata, runtime) store = modulestore('direct')
store.create_and_save_xmodule(location, data, metadata, runtime)
if parent_name: if parent_name:
# add child to parent in mongo # add child to parent in mongo
parent_location = self.course.location.replace(category=parent_category, name=parent_name) parent_location = self.course.location.replace(category=parent_category, name=parent_name)
parent = editable_modulestore('direct').get_item(parent_location) parent = store.get_item(parent_location)
parent.children.append(location.url()) parent.children.append(location.url())
editable_modulestore('direct').update_item(parent, self.user.id) store.update_item(parent, self.user.id)
def test_mongo_orphan(self): def test_mongo_orphan(self):
""" """
......
...@@ -49,7 +49,7 @@ from certificates.models import CertificateStatuses, certificate_status_for_stud ...@@ -49,7 +49,7 @@ from certificates.models import CertificateStatuses, certificate_status_for_stud
from xmodule.course_module import CourseDescriptor from xmodule.course_module import CourseDescriptor
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore import MONGO_MODULESTORE_TYPE from xmodule.modulestore import XML_MODULESTORE_TYPE
from collections import namedtuple from collections import namedtuple
...@@ -441,7 +441,7 @@ def dashboard(request): ...@@ -441,7 +441,7 @@ def dashboard(request):
show_email_settings_for = frozenset( show_email_settings_for = frozenset(
course.id for course, _enrollment in course_enrollment_pairs if ( course.id for course, _enrollment in course_enrollment_pairs if (
settings.FEATURES['ENABLE_INSTRUCTOR_EMAIL'] and settings.FEATURES['ENABLE_INSTRUCTOR_EMAIL'] and
modulestore().get_modulestore_type(course.id) == MONGO_MODULESTORE_TYPE and modulestore().get_modulestore_type(course.id) != XML_MODULESTORE_TYPE and
CourseAuthorization.instructor_email_enabled(course.id) CourseAuthorization.instructor_email_enabled(course.id)
) )
) )
......
...@@ -204,7 +204,7 @@ class ModuleStoreTestCase(TestCase): ...@@ -204,7 +204,7 @@ class ModuleStoreTestCase(TestCase):
'course' is an instance of CourseDescriptor for which we want 'course' is an instance of CourseDescriptor for which we want
to update metadata. to update metadata.
""" """
store = editable_modulestore('direct') store = editable_modulestore()
store.update_item(course, '**replace_user**') store.update_item(course, '**replace_user**')
updated_course = store.get_instance(course.id, course.location) updated_course = store.get_instance(course.id, course.location)
return updated_course return updated_course
......
...@@ -9,7 +9,7 @@ from django.core.exceptions import ValidationError ...@@ -9,7 +9,7 @@ from django.core.exceptions import ValidationError
from bulk_email.models import CourseEmailTemplate, COURSE_EMAIL_MESSAGE_BODY_TAG, CourseAuthorization from bulk_email.models import CourseEmailTemplate, COURSE_EMAIL_MESSAGE_BODY_TAG, CourseAuthorization
from courseware.courses import get_course_by_id from courseware.courses import get_course_by_id
from xmodule.modulestore import MONGO_MODULESTORE_TYPE from xmodule.modulestore import XML_MODULESTORE_TYPE
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -69,7 +69,7 @@ class CourseAuthorizationAdminForm(forms.ModelForm): # pylint: disable=R0924 ...@@ -69,7 +69,7 @@ class CourseAuthorizationAdminForm(forms.ModelForm): # pylint: disable=R0924
raise forms.ValidationError(msg) raise forms.ValidationError(msg)
# Now, try and discern if it is a Studio course - HTML editor doesn't work with XML courses # 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_id) == MONGO_MODULESTORE_TYPE is_studio_course = modulestore().get_modulestore_type(course_id) != XML_MODULESTORE_TYPE
if not is_studio_course: if not is_studio_course:
msg = "Course Email feature is only available for courses authored in Studio. " msg = "Course Email feature is only available for courses authored in Studio. "
msg += '"{0}" appears to be an XML backed course.'.format(course_id) msg += '"{0}" appears to be an XML backed course.'.format(course_id)
......
...@@ -11,7 +11,7 @@ from courseware.tests.tests import TEST_DATA_MONGO_MODULESTORE ...@@ -11,7 +11,7 @@ from courseware.tests.tests import TEST_DATA_MONGO_MODULESTORE
from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore import MONGO_MODULESTORE_TYPE from xmodule.modulestore import XML_MODULESTORE_TYPE
from mock import patch from mock import patch
...@@ -119,7 +119,7 @@ class CourseAuthorizationXMLFormTest(ModuleStoreTestCase): ...@@ -119,7 +119,7 @@ class CourseAuthorizationXMLFormTest(ModuleStoreTestCase):
def test_xml_course_authorization(self): def test_xml_course_authorization(self):
course_id = 'edX/toy/2012_Fall' course_id = 'edX/toy/2012_Fall'
# Assert this is an XML course # Assert this is an XML course
self.assertTrue(modulestore().get_modulestore_type(course_id) != MONGO_MODULESTORE_TYPE) self.assertEqual(modulestore().get_modulestore_type(course_id), XML_MODULESTORE_TYPE)
form_data = {'course_id': course_id, 'email_enabled': True} form_data = {'course_id': course_id, 'email_enabled': True}
form = CourseAuthorizationAdminForm(data=form_data) form = CourseAuthorizationAdminForm(data=form_data)
......
...@@ -229,7 +229,7 @@ class TestCourseGrader(TestSubmittingProblems): ...@@ -229,7 +229,7 @@ class TestCourseGrader(TestSubmittingProblems):
""" """
self.course.grading_policy = grading_policy self.course.grading_policy = grading_policy
store = editable_modulestore('direct') store = editable_modulestore()
store.update_item(self.course, '**replace_user**') store.update_item(self.course, '**replace_user**')
self.refresh_course() self.refresh_course()
......
...@@ -38,7 +38,7 @@ from external_auth.views import generate_password ...@@ -38,7 +38,7 @@ from external_auth.views import generate_password
from student.models import CourseEnrollment, UserProfile, Registration from student.models import CourseEnrollment, UserProfile, Registration
import track.views import track.views
from xmodule.contentstore.django import contentstore from xmodule.contentstore.django import contentstore
from xmodule.modulestore import MONGO_MODULESTORE_TYPE from xmodule.modulestore import XML_MODULESTORE_TYPE
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.store_utilities import delete_course from xmodule.modulestore.store_utilities import delete_course
from xmodule.modulestore.xml import XMLModuleStore from xmodule.modulestore.xml import XMLModuleStore
...@@ -530,8 +530,8 @@ class Courses(SysadminDashboardView): ...@@ -530,8 +530,8 @@ class Courses(SysadminDashboardView):
course_id, escape(str(err)) course_id, escape(str(err))
) )
is_mongo_course = (modulestore().get_modulestore_type(course_id) == MONGO_MODULESTORE_TYPE) is_xml_course = (modulestore().get_modulestore_type(course_id) == XML_MODULESTORE_TYPE)
if course_found and not is_mongo_course: if course_found and is_xml_course:
cdir = course.data_dir cdir = course.data_dir
self.def_ms.courses.pop(cdir) self.def_ms.courses.pop(cdir)
...@@ -546,7 +546,7 @@ class Courses(SysadminDashboardView): ...@@ -546,7 +546,7 @@ class Courses(SysadminDashboardView):
u"{0} = {1} ({2})</font>".format( u"{0} = {1} ({2})</font>".format(
cdir, course.id, course.display_name)) cdir, course.id, course.display_name))
elif course_found and is_mongo_course: elif course_found and not is_xml_course:
# delete course that is stored with mongodb backend # delete course that is stored with mongodb backend
loc = course.location loc = course.location
content_store = contentstore() content_store = contentstore()
......
...@@ -13,7 +13,7 @@ from django.conf import settings ...@@ -13,7 +13,7 @@ from django.conf import settings
from xmodule_modifiers import wrap_xblock from xmodule_modifiers import wrap_xblock
from xmodule.html_module import HtmlDescriptor from xmodule.html_module import HtmlDescriptor
from xmodule.modulestore import MONGO_MODULESTORE_TYPE from xmodule.modulestore import XML_MODULESTORE_TYPE
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xblock.field_data import DictFieldData from xblock.field_data import DictFieldData
from xblock.fields import ScopeIds from xblock.fields import ScopeIds
...@@ -34,7 +34,7 @@ def instructor_dashboard_2(request, course_id): ...@@ -34,7 +34,7 @@ def instructor_dashboard_2(request, course_id):
"""Display the instructor dashboard for a course.""" """Display the instructor dashboard for a course."""
course = get_course_by_id(course_id, depth=None) course = get_course_by_id(course_id, depth=None)
is_studio_course = (modulestore().get_modulestore_type(course_id) == MONGO_MODULESTORE_TYPE) is_studio_course = (modulestore().get_modulestore_type(course_id) != XML_MODULESTORE_TYPE)
access = { access = {
'admin': request.user.is_staff, 'admin': request.user.is_staff,
......
...@@ -24,7 +24,7 @@ from django.utils import timezone ...@@ -24,7 +24,7 @@ from django.utils import timezone
from xmodule_modifiers import wrap_xblock from xmodule_modifiers import wrap_xblock
import xmodule.graders as xmgraders import xmodule.graders as xmgraders
from xmodule.modulestore import MONGO_MODULESTORE_TYPE from xmodule.modulestore import XML_MODULESTORE_TYPE
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.html_module import HtmlDescriptor from xmodule.html_module import HtmlDescriptor
...@@ -831,7 +831,7 @@ def instructor_dashboard(request, course_id): ...@@ -831,7 +831,7 @@ def instructor_dashboard(request, course_id):
instructor_tasks = None instructor_tasks = None
# determine if this is a studio-backed course so we can provide a link to edit this course in studio # determine if this is a studio-backed course so we can provide a link to edit this course in studio
is_studio_course = modulestore().get_modulestore_type(course_id) == MONGO_MODULESTORE_TYPE is_studio_course = modulestore().get_modulestore_type(course_id) != XML_MODULESTORE_TYPE
studio_url = None studio_url = None
if is_studio_course: if is_studio_course:
......
...@@ -30,15 +30,24 @@ modulestore_options = { ...@@ -30,15 +30,24 @@ modulestore_options = {
MODULESTORE = { MODULESTORE = {
'default': { 'default': {
'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore', 'ENGINE': 'xmodule.modulestore.mixed.MixedModuleStore',
'DOC_STORE_CONFIG': DOC_STORE_CONFIG, 'OPTIONS': {
'OPTIONS': modulestore_options, 'reference_type': 'Location',
}, 'mappings': {},
'draft': { 'stores': {
'ENGINE': 'xmodule.modulestore.mongo.DraftMongoModuleStore', 'default': {
'DOC_STORE_CONFIG': DOC_STORE_CONFIG, 'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore',
'OPTIONS': modulestore_options, 'DOC_STORE_CONFIG': DOC_STORE_CONFIG,
}, 'OPTIONS': modulestore_options,
},
'draft': {
'ENGINE': 'xmodule.modulestore.mongo.DraftMongoModuleStore',
'DOC_STORE_CONFIG': DOC_STORE_CONFIG,
'OPTIONS': modulestore_options,
},
},
}
}
} }
CONTENTSTORE = { CONTENTSTORE = {
......
"""
This configuration is to run the MixedModuleStore on a localdev environment
"""
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .dev import *
MODULESTORE = {
'default': {
'ENGINE': 'xmodule.modulestore.mixed.MixedModuleStore',
'OPTIONS': {
'reference_type': 'Location',
'mappings': {
'MITx/2.01x/2013_Spring': 'xml'
},
'stores': {
'xml': {
'ENGINE': 'xmodule.modulestore.xml.XMLModuleStore',
'OPTIONS': {
'data_dir': DATA_DIR,
'default_class': 'xmodule.hidden_module.HiddenDescriptor',
}
},
'default': {
'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore',
'DOC_STORE_CONFIG': {
'host': 'localhost',
'db': 'xmodule',
'collection': 'modulestore',
},
'OPTIONS': {
'default_class': 'xmodule.hidden_module.HiddenDescriptor',
'fs_root': DATA_DIR,
'render_template': 'edxmako.shortcuts.render_to_string',
}
}
},
}
}
}
"""
Settings for the LMS that runs alongside the CMS on AWS
"""
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .dev import *
MODULESTORE = {
'default': {
'ENGINE': 'xmodule.modulestore.draft.DraftModuleStore',
'DOC_STORE_CONFIG': DOC_STORE_CONFIG,
'OPTIONS': modulestore_options
},
}
"""
This config file runs the dev environment, but with mongo as the datastore
"""
# We intentionally define lots of variables that aren't used, and
# want to import all variables from base settings files
# pylint: disable=W0401, W0614
from .dev import *
GITHUB_REPO_ROOT = ENV_ROOT / "data"
MODULESTORE = {
'default': {
'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore',
'DOC_STORE_CONFIG': {
'host': 'localhost',
'db': 'xmodule',
'collection': 'modulestore',
},
'OPTIONS': {
'default_class': 'xmodule.hidden_module.HiddenDescriptor',
'fs_root': GITHUB_REPO_ROOT,
'render_template': 'edxmako.shortcuts.render_to_string',
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment