Skip to content
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

fix: suppress errors+warnings when video is used in a content library [FC-0062] #35544

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cms/djangoapps/contentstore/views/transcripts_ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,9 @@ def _get_item(request, data):
Returns the item.
"""
usage_key = UsageKey.from_string(data.get('locator'))
if not usage_key.context_key.is_course:
# TODO: implement transcript support for learning core / content libraries.
raise TranscriptsRequestValidationException(_('Transcripts are not yet supported in content libraries.'))
# This is placed before has_course_author_access() to validate the location,
# because has_course_author_access() raises r if location is invalid.
item = modulestore().get_item(usage_key)
Expand Down
2 changes: 1 addition & 1 deletion xmodule/video_block/transcripts_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ def get_transcript_from_learning_core(video_block, language, output_format, tran
"""
# TODO: Update to use Learning Core data models once static assets support
# has been added.
raise NotImplementedError("Transcripts not supported.")
raise NotFoundError("No transcript - transcripts not supported yet by learning core components.")


def get_transcript(video, lang=None, output_format=Transcript.SRT, youtube_id=None):
Expand Down
18 changes: 12 additions & 6 deletions xmodule/video_block/video_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def get_html(self, view=STUDENT_VIEW, context=None): # lint-amnesty, pylint: di
'hide_downloads': is_public_view or is_embed,
'id': self.location.html_id(),
'block_id': str(self.location),
'course_id': str(self.location.course_key),
'course_id': str(self.context_key),
'video_id': str(self.edx_video_id),
'user_id': self.get_user_id(),
'is_embed': is_embed,
Expand Down Expand Up @@ -510,8 +510,10 @@ def get_course_video_sharing_override(self):
"""
Return course video sharing options override or None
"""
if not self.context_key.is_course:
return False # Only courses support this feature at all (not libraries)
try:
course = get_course_by_id(self.course_id)
course = get_course_by_id(self.context_key)
return getattr(course, 'video_sharing_options', None)

# In case the course / modulestore does something weird
Expand All @@ -523,11 +525,13 @@ def is_public_sharing_enabled(self):
"""
Is public sharing enabled for this video?
"""
if not self.context_key.is_course:
return False # Only courses support this feature at all (not libraries)
try:
# Video share feature must be enabled for sharing settings to take effect
feature_enabled = PUBLIC_VIDEO_SHARE.is_enabled(self.location.course_key)
feature_enabled = PUBLIC_VIDEO_SHARE.is_enabled(self.context_key)
except Exception as err: # pylint: disable=broad-except
log.exception(f"Error retrieving course for course ID: {self.location.course_key}")
log.exception(f"Error retrieving course for course ID: {self.context_key}")
return False
if not feature_enabled:
return False
Expand All @@ -552,11 +556,13 @@ def is_transcript_feedback_enabled(self):
"""
Is transcript feedback enabled for this video?
"""
if not self.context_key.is_course:
return False # Only courses support this feature at all (not libraries)
try:
# Video transcript feedback must be enabled in order to show the widget
feature_enabled = TRANSCRIPT_FEEDBACK.is_enabled(self.location.course_key)
feature_enabled = TRANSCRIPT_FEEDBACK.is_enabled(self.context_key)
except Exception as err: # pylint: disable=broad-except
log.exception(f"Error retrieving course for course ID: {self.location.course_key}")
log.exception(f"Error retrieving course for course ID: {self.context_key}")
return False
return feature_enabled

Expand Down
Loading