diff --git a/cms/envs/common.py b/cms/envs/common.py index 5f8ebfdb1782385ed4f4a6bd471aae6262d8e761..b2e15a9eba61f0368439dec9e59416f8ea711faa 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -38,6 +38,7 @@ from warnings import simplefilter from lms.lib.xblock.mixin import LmsBlockMixin from dealer.git import git +from xmodule.modulestore.edit_info import EditInfoMixin ############################ FEATURE CONFIGURATION ############################# @@ -254,7 +255,7 @@ from xmodule.x_module import XModuleMixin # This should be moved into an XBlock Runtime/Application object # once the responsibility of XBlock creation is moved out of modulestore - cpennington -XBLOCK_MIXINS = (LmsBlockMixin, InheritanceMixin, XModuleMixin) +XBLOCK_MIXINS = (LmsBlockMixin, InheritanceMixin, XModuleMixin, EditInfoMixin) # Allow any XBlock in Studio # You should also enable the ALLOW_ALL_ADVANCED_COMPONENTS feature flag, so that diff --git a/common/lib/xmodule/xmodule/modulestore/edit_info.py b/common/lib/xmodule/xmodule/modulestore/edit_info.py new file mode 100644 index 0000000000000000000000000000000000000000..4dedccd42345ed17efa8be4f682fe924aa7435d2 --- /dev/null +++ b/common/lib/xmodule/xmodule/modulestore/edit_info.py @@ -0,0 +1,101 @@ +""" +Access methods to get EditInfo for xblocks +""" +from xblock.fields import XBlockMixin +from abc import ABCMeta, abstractmethod + + +class EditInfoMixin(XBlockMixin): + """ + Provides the interfaces for getting the edit info from XBlocks + """ + @property + def edited_by(self): + """ + The user id of the last user to change this xblock content, children, or settings. + """ + return self.runtime.get_edited_by(self) + + @property + def edited_on(self): + """ + The datetime of the last change to this xblock content, children, or settings. + """ + return self.runtime.get_edited_on(self) + + @property + def subtree_edited_by(self): + """ + The user id of the last user to change content, children, or settings in this xblock's subtree + """ + return self.runtime.get_subtree_edited_by(self) + + @property + def subtree_edited_on(self): + """ + The datetime of the last change content, children, or settings in this xblock's subtree + """ + return self.runtime.get_subtree_edited_on(self) + + @property + def published_by(self): + """ + The user id of the last user to publish this specific xblock (or a previous version of it). + """ + return self.runtime.get_published_by(self) + + @property + def published_on(self): + """ + The datetime of the last time this specific xblock was published. + """ + return self.runtime.get_published_on(self) + + +class EditInfoRuntimeMixin(object): + """ + An abstract mixin class for the functions which the :class: `EditInfoMixin` methods call on the runtime + """ + __metaclass__ = ABCMeta + + @abstractmethod + def get_edited_by(self, xblock): + """ + The datetime of the last change to this xblock content, children, or settings. + """ + pass + + @abstractmethod + def get_edited_on(self, xblock): + """ + The datetime of the last change to this xblock content, children, or settings. + """ + pass + + @abstractmethod + def get_subtree_edited_by(self, xblock): + """ + The user id of the last user to change content, children, or settings in this xblock's subtree + """ + pass + + @abstractmethod + def get_subtree_edited_on(self, xblock): + """ + The datetime of the last change content, children, or settings in this xblock's subtree + """ + pass + + @abstractmethod + def get_published_by(self, xblock): + """ + The user id of the last user to publish this specific xblock (or a previous version of it). + """ + pass + + @abstractmethod + def get_published_on(self, xblock): + """ + The datetime of the last time this specific xblock was published. + """ + pass diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index 3ce77b7b2f2335d836fbc9cf8ae874a396d30cf8..010e2c1fd0b8083daaa2d35f5f2a4727d0e1a08e 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -724,7 +724,7 @@ class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock): # leaving off original_version since it complicates creation w/o any obv value yet and is computable # by following previous until None # definition_locator is only used by mongostores which separate definitions from blocks - self.edited_by = self.edited_on = self.previous_version = self.update_version = self.definition_locator = None + self.previous_version = self.update_version = self.definition_locator = None self.xmodule_runtime = None @classmethod