Skip to content

Commit e595356

Browse files
committed
feat: Adds Video XBlock extracted from edx-platform repository
1 parent e05dddb commit e595356

26 files changed

+4753
-1892
lines changed

requirements/base.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
django-statici18n
55
edx-i18n-tools
66
edx-opaque-keys
7+
edxval
78
nh3
89
oauthlib
910
openedx-django-pyfs

xblocks_contrib/video/ajax_handler_mixin.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
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
"""
2223
Turn Webob cgi.FieldStorage uploaded files into pure file objects.
23-
2424
Webob represents uploaded files as cgi.FieldStorage objects, which
2525
have a .file attribute. We wrap the FieldStorage object, delegating
2626
attribute access to the .file attribute. But the files have no
2727
name, so we carry the FieldStorage .filename attribute as the .name.
28-
2928
"""
3029
def __init__(self, webob_file):
3130
self.file = webob_file.file

xblocks_contrib/video/bumper_utils.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
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
"""
64

7-
85
import copy
96
import json
107
import logging

xblocks_contrib/video/cache_utils.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
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-
8-
import collections
9-
import functools
101
import itertools
11-
import zlib
12-
import pickle
13-
142
import wrapt
15-
from django.db.models.signals import post_save, post_delete
3+
164
from django.utils.encoding import force_str
175

18-
from edx_django_utils.cache import RequestCache, TieredCache
6+
from edx_django_utils.cache import RequestCache
197

208

219
def request_cached(namespace=None, arg_map_function=None, request_cache_getter=None):
@@ -82,7 +70,6 @@ def decorator(wrapped, instance, args, kwargs):
8270

8371
return decorator
8472

85-
8673
def _func_call_cache_key(func, arg_map_function, *args, **kwargs):
8774
"""
8875
Returns a cache key based on the function's module,
@@ -97,7 +84,6 @@ def _func_call_cache_key(func, arg_map_function, *args, **kwargs):
9784
cache_keys = [func.__module__, func.__name__] + converted_args + converted_kwargs
9885
return '.'.join(cache_keys)
9986

100-
10187
def _sorted_kwargs_list(kwargs):
10288
"""
10389
Returns a unique and deterministic ordered list from the given kwargs.

xblocks_contrib/video/constants.py

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
1-
# NOTE: Code has been copied from the following source files
2-
# https://github.com/openedx/edx-platform/blob/master/common/djangoapps/xblock_django/constants.py
31
"""
42
Constants used by DjangoXBlockUserService
53
"""
64

7-
# Optional attributes stored on the XBlockUser
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+
814

9-
# The anonymous user ID for the user in the course.
10-
ATTR_KEY_ANONYMOUS_USER_ID = 'edx-platform.anonymous_user_id'
11-
# The global (course-agnostic) anonymous user ID for the user.
12-
ATTR_KEY_DEPRECATED_ANONYMOUS_USER_ID = 'edx-platform.deprecated_anonymous_user_id'
13-
# The country code determined from the user's request IP address.
14-
ATTR_KEY_REQUEST_COUNTRY_CODE = 'edx-platform.request_country_code'
15-
# Whether the user is authenticated or anonymous.
16-
ATTR_KEY_IS_AUTHENTICATED = 'edx-platform.is_authenticated'
1715
# The personally identifiable user ID.
1816
ATTR_KEY_USER_ID = 'edx-platform.user_id'
19-
# The username.
20-
ATTR_KEY_USERNAME = 'edx-platform.username'
21-
# Whether the user is enrolled in the course as a Beta Tester.
22-
ATTR_KEY_USER_IS_BETA_TESTER = 'edx-platform.user_is_beta_tester'
23-
# Whether the user has staff access to the platform.
24-
ATTR_KEY_USER_IS_GLOBAL_STAFF = 'edx-platform.user_is_global_staff'
25-
# Whether the user is a course team member with 'Staff' or 'Admin' access.
26-
ATTR_KEY_USER_IS_STAFF = 'edx-platform.user_is_staff'
27-
# A dict containing user's entries from the `UserPreference` model.
28-
ATTR_KEY_USER_PREFERENCES = 'edx-platform.user_preferences'
29-
# The user's role in the course ('staff', 'instructor', or 'student').
30-
ATTR_KEY_USER_ROLE = 'edx-platform.user_role'
17+
# The country code determined from the user's request IP address.
18+
ATTR_KEY_REQUEST_COUNTRY_CODE = 'edx-platform.request_country_code'
19+
20+
COURSE_VIDEO_SHARING_PER_VIDEO = 'per-video'
21+
COURSE_VIDEO_SHARING_ALL_VIDEOS = 'all-on'
22+
COURSE_VIDEO_SHARING_NONE = 'all-off'

0 commit comments

Comments
 (0)