Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------

Expand Down
2 changes: 1 addition & 1 deletion xblock/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.0
1.5.1
4 changes: 4 additions & 0 deletions xblock/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 22 additions & 1 deletion xblock/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
NoSuchUsage,
NoSuchDefinition,
FieldDataDeprecationWarning,
UserIdDeprecationWarning,
)

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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`.
Expand Down