diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1f3b50187..1c6b22e53 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,11 @@ Change history for XBlock These are notable changes in XBlock. +1.5.1 - 2021-08-26 +------------------ + +* Deprecated the Runtime.user_id property in favor of the user service. + 1.5.0 - 2021-07-27 ------------------ diff --git a/xblock/VERSION.txt b/xblock/VERSION.txt index bc80560fa..26ca59460 100644 --- a/xblock/VERSION.txt +++ b/xblock/VERSION.txt @@ -1 +1 @@ -1.5.0 +1.5.1 diff --git a/xblock/exceptions.py b/xblock/exceptions.py index 9e58a62ec..04694c0aa 100644 --- a/xblock/exceptions.py +++ b/xblock/exceptions.py @@ -138,6 +138,10 @@ class FieldDataDeprecationWarning(DeprecationWarning): """Warning for use of deprecated _field_data accessor""" +class UserIdDeprecationWarning(DeprecationWarning): + """Warning for use of deprecated user_id accessor""" + + class XBlockParseException(Exception): """ Raised if parsing the XBlock olx fails. diff --git a/xblock/runtime.py b/xblock/runtime.py index 8bad3a85e..c518eda5a 100644 --- a/xblock/runtime.py +++ b/xblock/runtime.py @@ -29,6 +29,7 @@ NoSuchUsage, NoSuchDefinition, FieldDataDeprecationWarning, + UserIdDeprecationWarning, ) log = logging.getLogger(__name__) @@ -563,7 +564,7 @@ def __init__( self.default_class = default_class self.select = select - self.user_id = None + self._deprecated_per_instance_user_id = None # pylint: disable=invalid-name self.mixologist = Mixologist(mixins) self._view_name = None @@ -593,6 +594,26 @@ def field_data(self, field_data): warnings.warn("Runtime.field_data is deprecated", FieldDataDeprecationWarning, stacklevel=2) self._deprecated_per_instance_field_data = field_data + @property + def user_id(self): + """ + Access the current user ID. + + Deprecated in favor of a 'user' service. + """ + warnings.warn("Runtime.user_id is deprecated", UserIdDeprecationWarning, stacklevel=2) + return self._deprecated_per_instance_user_id + + @user_id.setter + def user_id(self, user_id): + """ + Set the current user ID. + + Deprecated in favor of a 'user' service. + """ + warnings.warn("Runtime.user_id is deprecated", UserIdDeprecationWarning, stacklevel=2) + self._deprecated_per_instance_user_id = user_id + def load_block_type(self, block_type): """ Returns a subclass of :class:`.XBlock` that corresponds to the specified `block_type`.