diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 943f4e328753..451c3104887e 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -3096,6 +3096,41 @@ def test_access(self, is_waffle_enabled, is_public_video, expected_status_code): self.assertEqual(expected_status_code, response.status_code) self.assertEqual(expected_status_code, embed_response.status_code) + def test_get_org_logo_none(self): + # Given a course with no organizational logo + self.setup_course() + target_video = self.video_block_public + + # When I render the page + response = self.get_response(usage_key=target_video.location, is_embed=False) + content = response.content.decode('utf-8') + + # Then the page does not render an org logo + org_logo = re.search('', content) + self.assertIsNone(org_logo) + + @patch('lms.djangoapps.courseware.views.views.get_course_organization') + def test_get_org_logo(self, mock_get_org): + # Given a course with an organizational logo + self.setup_course() + target_video = self.video_block_public + + mock_org_logo_url = "/assets/foo" + mock_org_logo = MagicMock() + mock_org_logo.url = mock_org_logo_url + + mock_get_org.return_value = { + "logo": mock_org_logo + } + + # When I render the page + response = self.get_response(usage_key=target_video.location, is_embed=False) + content = response.content.decode('utf-8') + + # Then the page does render an org logo + org_logo = re.search(f'', content) + self.assertIsNotNone(org_logo) + class TestRenderXBlockSelfPaced(TestRenderXBlock): # lint-amnesty, pylint: disable=test-inherits-tests """ diff --git a/lms/djangoapps/courseware/views/views.py b/lms/djangoapps/courseware/views/views.py index 1bf598282a63..d37e4c292111 100644 --- a/lms/djangoapps/courseware/views/views.py +++ b/lms/djangoapps/courseware/views/views.py @@ -38,6 +38,7 @@ from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey, UsageKey from openedx_filters.learning.filters import CourseAboutRenderStarted +from organizations.api import get_course_organization from pytz import UTC from requests.exceptions import ConnectionError, Timeout # pylint: disable=redefined-builtin from rest_framework import status @@ -1785,9 +1786,11 @@ def get_template_and_context(self, course, video_block): }) course_about_page_url, enroll_url = self.get_public_video_cta_button_urls(course) social_sharing_metadata = self.get_social_sharing_metadata(course, video_block) + org_logo = self.get_organization_logo_from_course(course) context = { 'fragment': fragment, 'course': course, + 'org_logo': org_logo, 'social_sharing_metadata': social_sharing_metadata, 'learn_more_url': course_about_page_url, 'enroll_url': enroll_url, @@ -1799,6 +1802,16 @@ def get_template_and_context(self, course, video_block): } return 'public_video.html', context + def get_organization_logo_from_course(self, course): + """ + Get organization logo for this course + """ + course_org = get_course_organization(course.id) + + if course_org and course_org['logo']: + return course_org['logo'].url + return None + def get_social_sharing_metadata(self, course, video_block): """ Gather the information for the meta OpenGraph and Twitter-specific tags diff --git a/lms/static/sass/_experiments.scss b/lms/static/sass/_experiments.scss index 27c8452d8d43..5519ee9e8d48 100644 --- a/lms/static/sass/_experiments.scss +++ b/lms/static/sass/_experiments.scss @@ -516,9 +516,16 @@ // AU 972 Social Video Sharing Page .public-video-share-cta { position: relative; - float: right; z-index: 1; + .org-logo{ + height: 40px; + } + + .nav-links{ + float: right; + } + .btn-learn-more{ @extend %btn-shims; color: #00262B; diff --git a/lms/templates/public_video.html b/lms/templates/public_video.html index 46c87f140f13..82950f6c0b1a 100644 --- a/lms/templates/public_video.html +++ b/lms/templates/public_video.html @@ -21,8 +21,11 @@ <%block name="body_extra"> -