diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index a10e263856810ccb7a9430d8da506a462f29df11..65694915b3e57c1d77e42a982dc8fb6fbf34c4bc 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -15,6 +15,7 @@ from django.utils.translation import ugettext as _ from edxmako.shortcuts import render_to_string from lms.djangoapps.lms_xblock.field_data import LmsFieldData from opaque_keys.edx.keys import UsageKey +from openedx.core.lib.license import wrap_with_license from openedx.core.lib.partitions.partitions_service import PartitionService from openedx.core.lib.xblock_utils import ( replace_static_urls, @@ -34,7 +35,6 @@ from xblock_django.user_service import DjangoXBlockUserService from xmodule.contentstore.django import contentstore from xmodule.error_module import ErrorDescriptor from xmodule.exceptions import NotFoundError, ProcessingError -from xmodule.mixin import wrap_with_license from xmodule.modulestore.django import ModuleI18nService, modulestore from xmodule.services import SettingsService from xmodule.studio_editable import has_author_view diff --git a/cms/envs/common.py b/cms/envs/common.py index 3593c00fc7461a77454cef6ae55382ba23d06b71..277713227849efd0691a0c2d677e44b318e399d8 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -106,7 +106,7 @@ from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin from cms.lib.xblock.authoring_mixin import AuthoringMixin import dealer.git from xmodule.modulestore.edit_info import EditInfoMixin -from xmodule.mixin import LicenseMixin +from openedx.core.lib.license import LicenseMixin ############################ FEATURE CONFIGURATION ############################# @@ -280,6 +280,7 @@ MAKO_TEMPLATES['main'] = [ COMMON_ROOT / 'static', # required to statically include common Underscore templates OPENEDX_ROOT / 'core' / 'djangoapps' / 'cors_csrf' / 'templates', OPENEDX_ROOT / 'core' / 'djangoapps' / 'dark_lang' / 'templates', + OPENEDX_ROOT / 'core' / 'lib' / 'license' / 'templates', CMS_ROOT / 'djangoapps' / 'pipeline_js' / 'templates', ] diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 8ee3776a7d18a41bac8f69b953de2a2f6034b255..a209249c1f0177479822a553644c5c111316dca5 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -16,7 +16,7 @@ from pytz import utc from xblock.fields import Boolean, Dict, Float, Integer, List, Scope, String from xmodule import course_metadata_utils from xmodule.graders import grader_from_conf -from xmodule.mixin import LicenseMixin +from openedx.core.lib.license import LicenseMixin from xmodule.seq_module import SequenceDescriptor, SequenceModule from xmodule.tabs import CourseTabList, InvalidTabsException diff --git a/common/lib/xmodule/xmodule/video_module/video_module.py b/common/lib/xmodule/xmodule/video_module/video_module.py index cc384f3802bebfe841fd8f9a838756d4ca3417fe..ac22e978b5a3b77948b520cbc5640a1802f288cf 100644 --- a/common/lib/xmodule/xmodule/video_module/video_module.py +++ b/common/lib/xmodule/xmodule/video_module/video_module.py @@ -46,7 +46,7 @@ from .video_xfields import VideoFields from .video_handlers import VideoStudentViewHandlers, VideoStudioViewHandlers from xmodule.video_module import manage_video_subtitles_save -from xmodule.mixin import LicenseMixin +from openedx.core.lib.license import LicenseMixin # The following import/except block for edxval is temporary measure until # edxval is a proper XBlock Runtime Service. diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 3a276749ccf28023b273f2d723389d17fde8ffe3..c34b744fe61a2d473928b83e16ef6e6db1eb0e91 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -76,7 +76,7 @@ from xmodule.contentstore.django import contentstore from xmodule.error_module import ErrorDescriptor, NonStaffErrorDescriptor from xmodule.exceptions import NotFoundError, ProcessingError from xmodule.lti_module import LTIModule -from xmodule.mixin import wrap_with_license +from openedx.core.lib.license import wrap_with_license from xmodule.modulestore.django import modulestore from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.x_module import XModuleDescriptor diff --git a/lms/envs/common.py b/lms/envs/common.py index 543271b61b16142f31c1e7531c9b74486470bc6e..9732fbc353ad7805cfc9ba40c13f6dad312926a5 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -40,7 +40,7 @@ from django.utils.translation import ugettext_lazy as _ from .discussionsettings import * from xmodule.modulestore.modulestore_settings import update_module_store_settings from xmodule.modulestore.edit_info import EditInfoMixin -from xmodule.mixin import LicenseMixin +from openedx.core.lib.license import LicenseMixin from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin ################################### FEATURES ################################### @@ -502,6 +502,7 @@ MAKO_TEMPLATES['main'] = [ COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates', OPENEDX_ROOT / 'core' / 'djangoapps' / 'cors_csrf' / 'templates', OPENEDX_ROOT / 'core' / 'djangoapps' / 'dark_lang' / 'templates', + OPENEDX_ROOT / 'core' / 'lib' / 'license' / 'templates', ] # Django templating diff --git a/openedx/core/lib/license/__init__.py b/openedx/core/lib/license/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..ab669fd620c74443ed15f3f3e1c150cf2730fd99 --- /dev/null +++ b/openedx/core/lib/license/__init__.py @@ -0,0 +1,2 @@ +from .wrapper import wrap_with_license +from .mixin import LicenseMixin diff --git a/common/lib/xmodule/xmodule/mixin.py b/openedx/core/lib/license/mixin.py similarity index 82% rename from common/lib/xmodule/xmodule/mixin.py rename to openedx/core/lib/license/mixin.py index 1447f41342ba999650771e6695c7e61809a43444..49342e573e4c3414d2acd110dba6ec9cd29d2d46 100644 --- a/common/lib/xmodule/xmodule/mixin.py +++ b/openedx/core/lib/license/mixin.py @@ -1,5 +1,5 @@ """ -Reusable mixins for XBlocks and/or XModules +License mixin for XBlocks and XModules """ from xblock.fields import Scope, String, XBlockMixin @@ -51,14 +51,3 @@ class LicenseMixin(XBlockMixin): """ if getattr(self, "license", default): node.set('license', self.license) - - -def wrap_with_license(block, view, frag, context): # pylint: disable=unused-argument - """ - In the LMS, display the custom license underneath the XBlock. - """ - license = getattr(block, "license", None) # pylint: disable=redefined-builtin - if license: - context = {"license": license} - frag.content += block.runtime.render_template('license_wrapper.html', context) - return frag diff --git a/common/templates/license.html b/openedx/core/lib/license/templates/license.html similarity index 100% rename from common/templates/license.html rename to openedx/core/lib/license/templates/license.html diff --git a/common/templates/license_wrapper.html b/openedx/core/lib/license/templates/license_wrapper.html similarity index 100% rename from common/templates/license_wrapper.html rename to openedx/core/lib/license/templates/license_wrapper.html diff --git a/openedx/core/lib/license/wrapper.py b/openedx/core/lib/license/wrapper.py new file mode 100644 index 0000000000000000000000000000000000000000..2d1701540820f68a0a9c09f087c53100816a01c2 --- /dev/null +++ b/openedx/core/lib/license/wrapper.py @@ -0,0 +1,14 @@ +""" +Code to wrap web fragments with a license. +""" + + +def wrap_with_license(block, view, frag, context): # pylint: disable=unused-argument + """ + In the LMS, display the custom license underneath the XBlock. + """ + license = getattr(block, "license", None) # pylint: disable=redefined-builtin + if license: + context = {"license": license} + frag.content += block.runtime.render_template('license_wrapper.html', context) + return frag