diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index b438676e2395fb2b306b03837e4481fe1ce03e11..724dc439d9843b01ecf8c63a0b8d957e71d8f097 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -30,6 +30,7 @@ from .requests import _xmodule_recurse from .access import has_access from xmodule.x_module import XModuleDescriptor from xblock.plugin import PluginMissingError +from xblock.runtime import Mixologist __all__ = ['OPEN_ENDED_COMPONENT_TYPES', 'ADVANCED_COMPONENT_POLICY_KEY', @@ -137,6 +138,15 @@ def edit_subsection(request, location): ) +def load_mixed_class(category): + """ + Load an XBlock by category name, and apply all defined mixins + """ + component_class = XModuleDescriptor.load_class(category) + mixologist = Mixologist(settings.XBLOCK_MIXINS) + return mixologist.mix(component_class) + + @login_required def edit_unit(request, location): """ @@ -165,7 +175,7 @@ def edit_unit(request, location): component_templates = defaultdict(list) for category in COMPONENT_TYPES: - component_class = XModuleDescriptor.load_class(category) + component_class = load_mixed_class(category) # add the default template # TODO: Once mixins are defined per-application, rather than per-runtime, # this should use a cms mixed-in class. (cpennington) @@ -203,7 +213,7 @@ def edit_unit(request, location): # class? i.e., can an advanced have more than one entry in the # menu? one for default and others for prefilled boilerplates? try: - component_class = XModuleDescriptor.load_class(category) + component_class = load_mixed_class(category) component_templates['advanced'].append(( component_class.display_name.default or category, diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index 7fc669888e50406a7320eea14f3ada4e3b18661c..ccbb7fb5bb12dcb33221754b20ac1321ac54c4c4 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -2,6 +2,7 @@ import logging import sys from functools import partial +from django.conf import settings from django.http import HttpResponse, Http404, HttpResponseBadRequest, HttpResponseForbidden from django.core.urlresolvers import reverse from django.contrib.auth.decorators import login_required @@ -116,6 +117,7 @@ def preview_module_system(request, preview_id, descriptor): user=request.user, xblock_field_data=preview_field_data, can_execute_unsafe_code=(lambda: can_execute_unsafe_code(course_id)), + mixins=settings.XBLOCK_MIXINS, ) diff --git a/lms/djangoapps/open_ended_grading/tests.py b/lms/djangoapps/open_ended_grading/tests.py index f3f0748c84a7d8c6e0a125d014211d95ba8a0cec..27e6fd6059c5cb16d82b701a339d1438af12c757 100644 --- a/lms/djangoapps/open_ended_grading/tests.py +++ b/lms/djangoapps/open_ended_grading/tests.py @@ -169,7 +169,8 @@ class TestPeerGradingService(ModuleStoreTestCase, LoginEnrollmentTestCase): replace_urls=None, xblock_field_data=lambda d: d._field_data, s3_interface=test_util_open_ended.S3_INTERFACE, - open_ended_grading_interface=test_util_open_ended.OPEN_ENDED_GRADING_INTERFACE + open_ended_grading_interface=test_util_open_ended.OPEN_ENDED_GRADING_INTERFACE, + mixins=settings.XBLOCK_MIXINS, ) self.descriptor = peer_grading_module.PeerGradingDescriptor(self.system, field_data, ScopeIds(None, None, None, None)) self.peer_module = self.descriptor.xmodule(self.system)