-
Notifications
You must be signed in to change notification settings - Fork 4.2k
chore: Introduce a new service VideoConfig for the Extracted Video XBlock #37383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| """ | ||
| Django app configuration for the XBlock tagging app | ||
| """ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class TaggingConfig(AppConfig): | ||
| """ | ||
| Django app configuration for the XBlock tagging app | ||
| """ | ||
| name = 'cms.lib.xblock.tagging' | ||
| verbose_name = 'XBlock Tagging' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| """ | ||
| Video configuration utilities | ||
| """ | ||
|
|
||
| import logging | ||
|
|
||
| from django.conf import settings | ||
|
|
||
| from openedx.core.djangoapps.video_config.toggles import PUBLIC_VIDEO_SHARE | ||
| from openedx.core.lib.courses import get_course_by_id | ||
| from xmodule.course_block import ( | ||
| COURSE_VIDEO_SHARING_ALL_VIDEOS, | ||
| COURSE_VIDEO_SHARING_NONE, | ||
| ) | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class VideoSharingUtils: | ||
| """ | ||
| Provides utility methods for video sharing functionality. | ||
| """ | ||
|
|
||
| @staticmethod | ||
| def get_public_video_url(video_block): | ||
| """ | ||
| Returns the public video url for a video block. | ||
|
|
||
| Args: | ||
| video_block: The video XBlock instance | ||
|
|
||
| Returns: | ||
| str: The public video URL | ||
| """ | ||
| return fr'{settings.LMS_ROOT_URL}/videos/{str(video_block.location)}' | ||
|
|
||
| @staticmethod | ||
| def is_public_sharing_enabled(video_block): | ||
| """ | ||
| Check if public sharing is enabled for a video. | ||
|
|
||
| Args: | ||
| video_block: The video XBlock instance | ||
|
|
||
| Returns: | ||
| bool: True if public sharing is enabled, False otherwise | ||
| """ | ||
| if not video_block.context_key.is_course: | ||
| return False # Only courses support this feature (not libraries) | ||
|
|
||
| try: | ||
| # Video share feature must be enabled for sharing settings to take effect | ||
| feature_enabled = PUBLIC_VIDEO_SHARE.is_enabled(video_block.context_key) | ||
| except Exception as err: # pylint: disable=broad-except | ||
| log.exception(f"Error retrieving course for course ID: {video_block.context_key}") | ||
| return False | ||
|
|
||
| if not feature_enabled: | ||
| return False | ||
|
|
||
| # Check if the course specifies a general setting | ||
| course_video_sharing_option = VideoSharingUtils.get_course_video_sharing_override(video_block) | ||
|
|
||
| # Course can override all videos to be shared | ||
| if course_video_sharing_option == COURSE_VIDEO_SHARING_ALL_VIDEOS: | ||
| return True | ||
|
|
||
| # ... or no videos to be shared | ||
| elif course_video_sharing_option == COURSE_VIDEO_SHARING_NONE: | ||
| return False | ||
|
|
||
| # ... or can fall back to per-video setting | ||
| # Equivalent to COURSE_VIDEO_SHARING_PER_VIDEO or None / unset | ||
| else: | ||
| return video_block.public_access | ||
|
|
||
| @staticmethod | ||
| def get_course_video_sharing_override(video_block): | ||
| """ | ||
| Return course video sharing options override or None | ||
|
|
||
| Args: | ||
| video_block: The video XBlock instance | ||
|
|
||
| Returns: | ||
| Course video sharing option or None | ||
| """ | ||
| if not video_block.context_key.is_course: | ||
| return False # Only courses support this feature (not libraries) | ||
|
|
||
| try: | ||
| course = get_course_by_id(video_block.context_key) | ||
| return getattr(course, 'video_sharing_options', None) | ||
| except Exception as err: # pylint: disable=broad-except | ||
| log.exception(f"Error retrieving course for course ID: {video_block.course_id}") | ||
| return None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes this change necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These logs pushed me to do this change.
Logs are taken from e33585a commit test run.
Issue fixed by creating the AppConfig class for tagging app.