Skip to content

Commit 8ec6d2e

Browse files
committed
feat: Adds the Video XBlock code extracted from the edx-platform
1 parent 8aebf6a commit 8ec6d2e

23 files changed

+3850
-459
lines changed

xblocks_contrib/video/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/*
2+
3+

xblocks_contrib/video/ajax_handler_mixin.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
# NOTE: Code has been copied from the following source file
2-
# https://github.com/openedx/edx-platform/blob/master/xmodule/x_module.py#L739
1+
from xblock.core import XBlock
2+
from webob.multidict import MultiDict
3+
from webob import Response
34

4-
class XModuleToXBlockMixin:
5+
class AjaxHandlerMixin:
56
"""
6-
Common code needed by XModule and XBlocks converted from XModules.
7+
Mixin that provides AJAX handling for Video XBlock
78
"""
89
@property
910
def ajax_url(self):
1011
"""
1112
Returns the URL for the ajax handler.
1213
"""
13-
return self.runtime.handler_url(self, 'xmodule_handler', '', '').rstrip('/?')
14+
return self.runtime.handler_url(self, 'ajax_handler', '', '').rstrip('/?')
1415

1516
@XBlock.handler
16-
def xmodule_handler(self, request, suffix=None):
17+
def ajax_handler(self, request, suffix=None):
1718
"""
18-
XBlock handler that wraps `handle_ajax`
19+
XBlock handler that wraps `ajax_handler`
1920
"""
2021
class FileObjForWebobFiles:
2122
"""

xblocks_contrib/video/bumper_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# NOTE: Code has been copied from the following source files
2-
# https://github.com/openedx/edx-platform/blob/master/xmodule/video_block/bumper_utils.py
31
"""
42
Utils for video bumper
53
"""

xblocks_contrib/video/cache_utils.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
# NOTE: Code has been copied from the following source files
2-
# https://github.com/openedx/edx-platform/blob/master/openedx/core/lib/cache_utils.py
3-
"""
4-
Utilities related to caching.
5-
"""
6-
7-
81
import itertools
9-
102
import wrapt
3+
114
from django.utils.encoding import force_str
125

136
from edx_django_utils.cache import RequestCache

xblocks_contrib/video/constants.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
Constants used by DjangoXBlockUserService
3+
"""
4+
5+
# This is the view that will be rendered to display the XBlock in the LMS.
6+
# It will also be used to render the block in "preview" mode in Studio, unless
7+
# the XBlock also implements author_view.
8+
STUDENT_VIEW = 'student_view'
9+
10+
# This is the view that will be rendered to display the XBlock in the LMS for unenrolled learners.
11+
# Implementations of this view should assume that a user and user data are not available.
12+
PUBLIC_VIEW = 'public_view'
13+
14+
# The personally identifiable user ID.
15+
ATTR_KEY_USER_ID = 'edx-platform.user_id'
16+
# The country code determined from the user's request IP address.
17+
ATTR_KEY_REQUEST_COUNTRY_CODE = 'edx-platform.request_country_code'

xblocks_contrib/video/content.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
# NOTE: Original code has been copied from the following file:
2-
# https://github.com/openedx/edx-platform/blob/farhan/extract-video-xblock/xmodule/contentstore/content.py#L28
1+
from opaque_keys import InvalidKeyError
2+
from opaque_keys.edx.keys import AssetKey
3+
from opaque_keys.edx.locator import AssetLocator
34

4-
5-
class StaticContent: # lint-amnesty, pylint: disable=missing-class-docstring
5+
"""
6+
Methods of this class has been copied from the
7+
StaticContent class in edx-platform/xmodule/contentstore/content.py
8+
"""
9+
class VideoBlockStaticContent: # lint-amnesty, pylint: disable=missing-class-docstring
610
def __init__(self, loc, name, content_type, data, last_modified_at=None, thumbnail_location=None, import_path=None,
711
length=None, locked=False, content_digest=None):
812
self.location = loc

xblocks_contrib/video/mixin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# NOTE: Code has been copied from the following source files
2-
# https://github.com/openedx/edx-platform/blob/master/openedx/core/lib/license/mixin.py
31
"""
4-
License mixin for XBlocks and XModules
2+
License mixin for XBlocks
53
"""
64

75
from xblock.core import XBlockMixin

0 commit comments

Comments
 (0)