Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmccormick committed Jun 14, 2024
1 parent 3a8e11c commit 962b75a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion xblock/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class JsonHandlerError(Exception):
Raised by a function decorated with XBlock.json_handler to indicate that an
error response should be returned.
"""
def __init__(self, status_code: int, message: str):
def __init__(self, status_code: int, message: str | dict):
self.status_code = status_code
self.message = message

Expand Down
13 changes: 1 addition & 12 deletions xblock/reference/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Much of this still needs to be organized.
"""
from django.core.exceptions import ImproperlyConfigured
from djpyfs import djpyfs # type: ignore[import-untyped]

from xblock.fields import Field, NO_CACHE_VALUE
Expand Down Expand Up @@ -169,17 +168,7 @@ def load(self, instance, xblock):
Get the filesystem for the field specified in 'instance' and the
xblock in 'xblock' It is locally scoped.
"""

# TODO: Get xblock from context, once the plumbing is piped through
if djpyfs:
return djpyfs.get_filesystem(scope_key(instance, xblock))
else:
# The reference implementation relies on djpyfs
# https://github.com/openedx/django-pyfs
# For Django runtimes, you may use this reference
# implementation. Otherwise, you will need to
# patch pyfilesystem yourself to implement get_url.
raise NotImplementedError("djpyfs not available")
return djpyfs.get_filesystem(scope_key(instance, xblock))

def __repr__(self):
return "File system object"
7 changes: 5 additions & 2 deletions xblock/utils/studio_editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ def render_children(
'can_reorder': can_reorder,
}))

def student_view(self, context: dict[str, t.Any]) -> Fragment:
raise NotImplementedError("StudioContainer XBlocks must implement a student_view")

def author_view(self, context: dict[str, t.Any]) -> Fragment:
"""
Display a the studio editor when the user has clicked "View" to see the container view,
Expand Down Expand Up @@ -406,7 +409,7 @@ def preview_view(self, context: dict[str, t.Any]) -> Fragment:
return renderer(context)


class StudioContainerWithNestedXBlocksMixin(StudioContainerXBlockMixin):
class StudioContainerWithNestedXBlocksMixin(StudioContainerXBlockMixin): # pylint: disable=abstract-method
"""
An XBlock mixin providing interface for specifying allowed nested blocks and adding/previewing them in Studio.
"""
Expand Down Expand Up @@ -496,7 +499,7 @@ def _render_child_fragment(self, child: XBlock, context: dict[str, t.Any], view:
if child.scope_ids.block_type == 'html' and getattr(self.runtime, 'is_author_mode', False):
# html block doesn't support preview_view, and if we use student_view Studio will wrap
# it in HTML that we don't want in the preview. So just render its HTML directly:
child_fragment = Fragment(child.data)
child_fragment = Fragment(child.data) # type: ignore[attr-defined]
else:
child_fragment = child.render('student_view', context)

Expand Down

0 comments on commit 962b75a

Please sign in to comment.