Commit f1369b91 by John Eskew

Move LicenseMixin and accompanying code to openedx/core/lib.

parent 643d9eda
...@@ -15,6 +15,7 @@ from django.utils.translation import ugettext as _ ...@@ -15,6 +15,7 @@ from django.utils.translation import ugettext as _
from edxmako.shortcuts import render_to_string from edxmako.shortcuts import render_to_string
from lms.djangoapps.lms_xblock.field_data import LmsFieldData from lms.djangoapps.lms_xblock.field_data import LmsFieldData
from opaque_keys.edx.keys import UsageKey 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.partitions.partitions_service import PartitionService
from openedx.core.lib.xblock_utils import ( from openedx.core.lib.xblock_utils import (
replace_static_urls, replace_static_urls,
...@@ -34,7 +35,6 @@ from xblock_django.user_service import DjangoXBlockUserService ...@@ -34,7 +35,6 @@ from xblock_django.user_service import DjangoXBlockUserService
from xmodule.contentstore.django import contentstore from xmodule.contentstore.django import contentstore
from xmodule.error_module import ErrorDescriptor from xmodule.error_module import ErrorDescriptor
from xmodule.exceptions import NotFoundError, ProcessingError from xmodule.exceptions import NotFoundError, ProcessingError
from xmodule.mixin import wrap_with_license
from xmodule.modulestore.django import ModuleI18nService, modulestore from xmodule.modulestore.django import ModuleI18nService, modulestore
from xmodule.services import SettingsService from xmodule.services import SettingsService
from xmodule.studio_editable import has_author_view from xmodule.studio_editable import has_author_view
......
...@@ -106,7 +106,7 @@ from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin ...@@ -106,7 +106,7 @@ from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin
from cms.lib.xblock.authoring_mixin import AuthoringMixin from cms.lib.xblock.authoring_mixin import AuthoringMixin
import dealer.git import dealer.git
from xmodule.modulestore.edit_info import EditInfoMixin from xmodule.modulestore.edit_info import EditInfoMixin
from xmodule.mixin import LicenseMixin from openedx.core.lib.license import LicenseMixin
############################ FEATURE CONFIGURATION ############################# ############################ FEATURE CONFIGURATION #############################
...@@ -280,6 +280,7 @@ MAKO_TEMPLATES['main'] = [ ...@@ -280,6 +280,7 @@ MAKO_TEMPLATES['main'] = [
COMMON_ROOT / 'static', # required to statically include common Underscore templates COMMON_ROOT / 'static', # required to statically include common Underscore templates
OPENEDX_ROOT / 'core' / 'djangoapps' / 'cors_csrf' / 'templates', OPENEDX_ROOT / 'core' / 'djangoapps' / 'cors_csrf' / 'templates',
OPENEDX_ROOT / 'core' / 'djangoapps' / 'dark_lang' / 'templates', OPENEDX_ROOT / 'core' / 'djangoapps' / 'dark_lang' / 'templates',
OPENEDX_ROOT / 'core' / 'lib' / 'license' / 'templates',
CMS_ROOT / 'djangoapps' / 'pipeline_js' / 'templates', CMS_ROOT / 'djangoapps' / 'pipeline_js' / 'templates',
] ]
......
...@@ -16,7 +16,7 @@ from pytz import utc ...@@ -16,7 +16,7 @@ from pytz import utc
from xblock.fields import Boolean, Dict, Float, Integer, List, Scope, String from xblock.fields import Boolean, Dict, Float, Integer, List, Scope, String
from xmodule import course_metadata_utils from xmodule import course_metadata_utils
from xmodule.graders import grader_from_conf 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.seq_module import SequenceDescriptor, SequenceModule
from xmodule.tabs import CourseTabList, InvalidTabsException from xmodule.tabs import CourseTabList, InvalidTabsException
......
...@@ -46,7 +46,7 @@ from .video_xfields import VideoFields ...@@ -46,7 +46,7 @@ from .video_xfields import VideoFields
from .video_handlers import VideoStudentViewHandlers, VideoStudioViewHandlers from .video_handlers import VideoStudentViewHandlers, VideoStudioViewHandlers
from xmodule.video_module import manage_video_subtitles_save 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 # The following import/except block for edxval is temporary measure until
# edxval is a proper XBlock Runtime Service. # edxval is a proper XBlock Runtime Service.
......
...@@ -76,7 +76,7 @@ from xmodule.contentstore.django import contentstore ...@@ -76,7 +76,7 @@ from xmodule.contentstore.django import contentstore
from xmodule.error_module import ErrorDescriptor, NonStaffErrorDescriptor from xmodule.error_module import ErrorDescriptor, NonStaffErrorDescriptor
from xmodule.exceptions import NotFoundError, ProcessingError from xmodule.exceptions import NotFoundError, ProcessingError
from xmodule.lti_module import LTIModule 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.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.x_module import XModuleDescriptor from xmodule.x_module import XModuleDescriptor
......
...@@ -40,7 +40,7 @@ from django.utils.translation import ugettext_lazy as _ ...@@ -40,7 +40,7 @@ from django.utils.translation import ugettext_lazy as _
from .discussionsettings import * from .discussionsettings import *
from xmodule.modulestore.modulestore_settings import update_module_store_settings from xmodule.modulestore.modulestore_settings import update_module_store_settings
from xmodule.modulestore.edit_info import EditInfoMixin 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 from lms.djangoapps.lms_xblock.mixin import LmsBlockMixin
################################### FEATURES ################################### ################################### FEATURES ###################################
...@@ -502,6 +502,7 @@ MAKO_TEMPLATES['main'] = [ ...@@ -502,6 +502,7 @@ MAKO_TEMPLATES['main'] = [
COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates', COMMON_ROOT / 'djangoapps' / 'pipeline_mako' / 'templates',
OPENEDX_ROOT / 'core' / 'djangoapps' / 'cors_csrf' / 'templates', OPENEDX_ROOT / 'core' / 'djangoapps' / 'cors_csrf' / 'templates',
OPENEDX_ROOT / 'core' / 'djangoapps' / 'dark_lang' / 'templates', OPENEDX_ROOT / 'core' / 'djangoapps' / 'dark_lang' / 'templates',
OPENEDX_ROOT / 'core' / 'lib' / 'license' / 'templates',
] ]
# Django templating # Django templating
......
from .wrapper import wrap_with_license
from .mixin import LicenseMixin
""" """
Reusable mixins for XBlocks and/or XModules License mixin for XBlocks and XModules
""" """
from xblock.fields import Scope, String, XBlockMixin from xblock.fields import Scope, String, XBlockMixin
...@@ -51,14 +51,3 @@ class LicenseMixin(XBlockMixin): ...@@ -51,14 +51,3 @@ class LicenseMixin(XBlockMixin):
""" """
if getattr(self, "license", default): if getattr(self, "license", default):
node.set('license', self.license) 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
"""
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
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