chore: add go to course button for student already enrolled in the courses
chore: linting chore: update requested change
This commit is contained in:
committed by
leangseu-edx
parent
044f172cb1
commit
1b50e80437
@@ -3500,6 +3500,7 @@ class TestBasePublicVideoXBlockView(TestBasePublicVideoXBlock):
|
||||
class TestPublicVideoXBlockView(TestBasePublicVideoXBlock):
|
||||
"""Test Public Video XBlock View"""
|
||||
request = RequestFactory().get('/?utm_source=edx.org&utm_medium=referral&utm_campaign=video')
|
||||
request.user = AnonymousUser()
|
||||
base_block = PublicVideoXBlockView(request=request)
|
||||
default_utm_params = {'utm_source': 'edx.org', 'utm_medium': 'referral', 'utm_campaign': 'video'}
|
||||
|
||||
@@ -3631,6 +3632,41 @@ class TestPublicVideoXBlockView(TestBasePublicVideoXBlock):
|
||||
expected_url = reverse('about_course', kwargs={'course_id': str(self.course.id)})
|
||||
self.assert_url_with_params(url, expected_url, self.default_utm_params)
|
||||
|
||||
def test_get_public_video_cta_button_urls(self):
|
||||
"""
|
||||
Test that get_public_video_cta_button_urls returns correct urls.
|
||||
"""
|
||||
catalog_course_info = {'marketing_url': 'some_url'}
|
||||
self.setup_course()
|
||||
learn_more_url, enroll_url, go_to_course_url = \
|
||||
self.base_block.get_public_video_cta_button_urls(self.course, catalog_course_info)
|
||||
assert go_to_course_url == \
|
||||
get_learning_mfe_home_url(course_key=self.course.id, url_fragment='home')
|
||||
|
||||
assert learn_more_url == \
|
||||
self.base_block.get_learn_more_button_url(self.course, catalog_course_info,
|
||||
self.default_utm_params)
|
||||
assert enroll_url == self.base_block.build_url(
|
||||
reverse('register_user'),
|
||||
{
|
||||
'course_id': str(self.course.id),
|
||||
'enrollment_action': 'enroll',
|
||||
'email_opt_in': False,
|
||||
},
|
||||
self.default_utm_params,
|
||||
)
|
||||
|
||||
@ddt.data(True, False)
|
||||
def test_get_is_enrolled_in_course(self, mock_registered_for_course):
|
||||
"""
|
||||
Test that is_enrolled_in_course returns correct value.
|
||||
"""
|
||||
with patch('lms.djangoapps.courseware.views.views.registered_for_course',
|
||||
return_value=mock_registered_for_course):
|
||||
self.setup_course()
|
||||
assert views.registered_for_course(self.course, self.user) == mock_registered_for_course
|
||||
assert self.base_block.get_is_enrolled_in_course(self.course) == mock_registered_for_course
|
||||
|
||||
|
||||
class TestPublicVideoXBlockEmbedView(TestBasePublicVideoXBlock):
|
||||
"""Test Public Video XBlock Embed View"""
|
||||
|
||||
@@ -1792,7 +1792,8 @@ class PublicVideoXBlockView(BasePublicVideoXBlockView):
|
||||
'public_video_embed': False,
|
||||
})
|
||||
catalog_course_data = self.get_catalog_course_data(course)
|
||||
learn_more_url, enroll_url = self.get_public_video_cta_button_urls(course, catalog_course_data)
|
||||
learn_more_url, enroll_url, go_to_course_url = \
|
||||
self.get_public_video_cta_button_urls(course, catalog_course_data)
|
||||
social_sharing_metadata = self.get_social_sharing_metadata(course, video_block)
|
||||
context = {
|
||||
'fragment': fragment,
|
||||
@@ -1801,15 +1802,24 @@ class PublicVideoXBlockView(BasePublicVideoXBlockView):
|
||||
'social_sharing_metadata': social_sharing_metadata,
|
||||
'learn_more_url': learn_more_url,
|
||||
'enroll_url': enroll_url,
|
||||
'go_to_course_url': go_to_course_url,
|
||||
'allow_iframing': True,
|
||||
'disable_window_wrap': True,
|
||||
'disable_register_button': True,
|
||||
'edx_notes_enabled': False,
|
||||
'is_learning_mfe': True,
|
||||
'is_mobile_app': False,
|
||||
'is_enrolled_in_course': self.get_is_enrolled_in_course(course),
|
||||
}
|
||||
return 'public_video.html', context
|
||||
|
||||
def get_is_enrolled_in_course(self, course):
|
||||
"""
|
||||
Returns whether the user is enrolled in the course
|
||||
"""
|
||||
user = self.request.user
|
||||
return user and registered_for_course(course, user)
|
||||
|
||||
def get_catalog_course_data(self, course):
|
||||
"""
|
||||
Get information from the catalog service for this course
|
||||
@@ -1896,7 +1906,9 @@ class PublicVideoXBlockView(BasePublicVideoXBlockView):
|
||||
},
|
||||
utm_params
|
||||
)
|
||||
return learn_more_url, enroll_url
|
||||
go_to_course_url = get_learning_mfe_home_url(course_key=course.id,
|
||||
url_fragment='home')
|
||||
return learn_more_url, enroll_url, go_to_course_url
|
||||
|
||||
def get_utm_params(self):
|
||||
"""
|
||||
|
||||
@@ -562,7 +562,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
.btn-enroll{
|
||||
.btn-enroll,
|
||||
.btn-go-to-course{
|
||||
@extend %btn-shims;
|
||||
color: #FFFFFF;
|
||||
background: #D23228;
|
||||
|
||||
@@ -38,9 +38,15 @@ from django.utils.translation import gettext as _
|
||||
<a class="btn-learn-more btn" href="${learn_more_url}">
|
||||
${_("Learn more about this course")}
|
||||
</a>
|
||||
<a class="btn-enroll btn" href="${enroll_url}">
|
||||
${_("Enroll in this course")}
|
||||
</a>
|
||||
% if is_enrolled_in_course:
|
||||
<a class="btn-go-to-course btn" href="${go_to_course_url}">
|
||||
${_("Go to course")}
|
||||
</a>
|
||||
% else:
|
||||
<a class="btn-enroll btn" href="${enroll_url}">
|
||||
${_("Enroll in this course")}
|
||||
</a>
|
||||
% endif
|
||||
</div>
|
||||
</nav>
|
||||
</%block>
|
||||
|
||||
Reference in New Issue
Block a user