Move LicenseMixin and accompanying code to openedx/core/lib.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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',
|
||||
]
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
2
openedx/core/lib/license/__init__.py
Normal file
2
openedx/core/lib/license/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from .wrapper import wrap_with_license
|
||||
from .mixin import LicenseMixin
|
||||
@@ -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
|
||||
14
openedx/core/lib/license/wrapper.py
Normal file
14
openedx/core/lib/license/wrapper.py
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user