fix: share link should show even if video download is disabled (#31902)
* fix: share link should show even if video download is disabled * fixup! fix: share link should show even if video download is disabled * chore: update test * chore: linting --------- Co-authored-by: Leangseu Kim <lkim@edx.org>
This commit is contained in:
@@ -48,6 +48,7 @@ from xmodule.x_module import PUBLIC_VIEW, STUDENT_VIEW
|
||||
|
||||
from common.djangoapps.xblock_django.constants import ATTR_KEY_REQUEST_COUNTRY_CODE
|
||||
from lms.djangoapps.courseware.tests.helpers import get_context_dict_from_string
|
||||
from lms.djangoapps.courseware.toggles import PUBLIC_VIDEO_SHARE
|
||||
from openedx.core.djangoapps.video_pipeline.config.waffle import DEPRECATE_YOUTUBE
|
||||
from openedx.core.djangoapps.waffle_utils.models import WaffleFlagCourseOverrideModel
|
||||
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase
|
||||
@@ -237,14 +238,21 @@ class TestVideoPublicAccess(BaseTestVideoXBlock):
|
||||
}
|
||||
METADATA = {}
|
||||
|
||||
@ddt.data(True, False)
|
||||
def test_public_video_url(self, is_lms_platform):
|
||||
@ddt.data(
|
||||
(True, False),
|
||||
(False, False),
|
||||
(True, True),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_public_video_url(self, is_lms_platform, enable_public_share):
|
||||
"""Test public video url."""
|
||||
assert self.item_descriptor.public_access is True
|
||||
with patch.object(self.item_descriptor, '_is_lms_platform', return_value=is_lms_platform):
|
||||
with patch.object(self.item_descriptor, '_is_lms_platform', return_value=is_lms_platform), \
|
||||
patch.object(PUBLIC_VIDEO_SHARE, 'is_enabled', return_value=enable_public_share):
|
||||
context = self.item_descriptor.render(STUDENT_VIEW).content
|
||||
# public video url iif is_lms_platform and public_access are true
|
||||
assert bool(get_context_dict_from_string(context)['public_video_url']) is is_lms_platform
|
||||
# public video url iif PUBLIC_VIDEO_SHARE waffle and is_lms_platform, public_access are true
|
||||
assert bool(get_context_dict_from_string(context)['public_video_url']) \
|
||||
is (is_lms_platform and enable_public_share)
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
|
||||
@@ -46,27 +46,31 @@ from openedx.core.djangolib.js_utils import (
|
||||
|
||||
<div class="focus_grabber last"></div>
|
||||
|
||||
% if (download_video_link or track or handout or branding_info) and not hide_downloads:
|
||||
% if (download_video_link or track or handout or branding_info or public_video_url) and not hide_downloads:
|
||||
<h3 class="hd hd-4 downloads-heading sr" id="video-download-transcripts_${id}">${_('Downloads and transcripts')}</h3>
|
||||
<div class="wrapper-downloads" role="region" aria-labelledby="video-download-transcripts_${id}">
|
||||
% if download_video_link:
|
||||
<div class="wrapper-download-video">
|
||||
<h4 class="hd hd-5">${_('Video')}</h4>
|
||||
<a class="btn-link video-sources video-download-button" href="${download_video_link}">
|
||||
${_('Download video file')}
|
||||
</a>
|
||||
% if public_video_url:
|
||||
<br/>
|
||||
<a
|
||||
class="btn-link"
|
||||
id="twitter-share-button"
|
||||
href="${public_video_url}"
|
||||
target="_blank"
|
||||
>
|
||||
${_('Share on Twitter')}
|
||||
</a>
|
||||
% endif
|
||||
</div>
|
||||
% if download_video_link or public_video_url:
|
||||
<div class="wrapper-download-video">
|
||||
<h4 class="hd hd-5">${_('Video')}</h4>
|
||||
% if download_video_link:
|
||||
<a class="btn-link video-sources video-download-button" href="${download_video_link}">
|
||||
${_('Download video file')}
|
||||
</a>
|
||||
% endif
|
||||
% if download_video_link and public_video_url:
|
||||
<br>
|
||||
% endif
|
||||
% if public_video_url:
|
||||
<a
|
||||
class="btn-link"
|
||||
id="twitter-share-button"
|
||||
href="${public_video_url}"
|
||||
target="_blank"
|
||||
>
|
||||
${_('Share on Twitter')}
|
||||
</a>
|
||||
% endif
|
||||
</div>
|
||||
% endif
|
||||
% if track:
|
||||
<div class="wrapper-download-transcripts">
|
||||
|
||||
@@ -494,10 +494,14 @@ class VideoBlock(
|
||||
"""
|
||||
Returns the public video url
|
||||
"""
|
||||
return urljoin(
|
||||
settings.LMS_ROOT_URL,
|
||||
reverse('render_public_video_xblock', kwargs={'usage_key_string': str(self.location)})
|
||||
) if self.public_access and self._is_lms_platform() else None
|
||||
if self.public_access and self._is_lms_platform():
|
||||
from lms.djangoapps.courseware.toggles import PUBLIC_VIDEO_SHARE
|
||||
if PUBLIC_VIDEO_SHARE.is_enabled(self.location.course_key):
|
||||
return urljoin(
|
||||
settings.LMS_ROOT_URL,
|
||||
reverse('render_public_video_xblock', kwargs={'usage_key_string': str(self.location)})
|
||||
)
|
||||
return None
|
||||
|
||||
def validate(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user