Skip to content

Commit de0c3d6

Browse files
committed
feat: Adds the Video XBlock code extracted from the edx-platform
1 parent 9f7e6fe commit de0c3d6

24 files changed

+3856
-471
lines changed

requirements/base.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
-c constraints.txt
33

44
django-statici18n
5+
edx-django-utils
56
edx-i18n-tools
67
edx-opaque-keys
78
nh3
89
oauthlib
910
openedx-django-pyfs
11+
wrapt
1012
XBlock

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: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
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+
""" Mixin that provides AJAX handling for Video XBlock """
2+
from webob import Response
3+
from webob.multidict import MultiDict
4+
from xblock.core import XBlock
35

4-
class XModuleToXBlockMixin:
6+
7+
class AjaxHandlerMixin:
58
"""
6-
Common code needed by XModule and XBlocks converted from XModules.
9+
Mixin that provides AJAX handling for Video XBlock
710
"""
811
@property
912
def ajax_url(self):
1013
"""
1114
Returns the URL for the ajax handler.
1215
"""
13-
return self.runtime.handler_url(self, 'xmodule_handler', '', '').rstrip('/?')
16+
return self.runtime.handler_url(self, 'ajax_handler', '', '').rstrip('/?')
1417

1518
@XBlock.handler
16-
def xmodule_handler(self, request, suffix=None):
19+
def ajax_handler(self, request, suffix=None):
1720
"""
18-
XBlock handler that wraps `handle_ajax`
21+
XBlock handler that wraps `ajax_handler`
1922
"""
2023
class FileObjForWebobFiles:
2124
"""

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,15 +1,8 @@
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-
1+
""" Cache Utils for Video Block """
82
import itertools
93

104
import wrapt
115
from django.utils.encoding import force_str
12-
136
from edx_django_utils.cache import RequestCache
147

158

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: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
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+
""" Video Block Static Content, class copied from StaticContent class in edx-platform/xmodule/contentstore/content.py """
2+
from opaque_keys import InvalidKeyError
3+
from opaque_keys.edx.keys import AssetKey
4+
from opaque_keys.edx.locator import AssetLocator
35

4-
5-
class StaticContent: # lint-amnesty, pylint: disable=missing-class-docstring
6+
class VideoBlockStaticContent: # lint-amnesty, pylint: disable=missing-class-docstring
67
def __init__(self, loc, name, content_type, data, last_modified_at=None, thumbnail_location=None, import_path=None,
78
length=None, locked=False, content_digest=None):
89
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)