Commit 13590af2 by asadiqbal

Update the link with marketing url from course metadata.

parent 0f82df69
...@@ -606,6 +606,37 @@ class BasketSummaryViewTests(EnterpriseServiceMockMixin, DiscoveryTestMixin, Dis ...@@ -606,6 +606,37 @@ class BasketSummaryViewTests(EnterpriseServiceMockMixin, DiscoveryTestMixin, Dis
self.assertEqual(line_data['course_start'], expected_result) self.assertEqual(line_data['course_start'], expected_result)
self.assertEqual(line_data['course_end'], expected_result) self.assertEqual(line_data['course_end'], expected_result)
def test_course_about_url(self):
"""
Test that in case of bulk enrollment, We have the marketing url from course metadata
if present in response.
"""
course_run_info = {
"course": "edX+DemoX",
"title": 'course title here',
"short_description": 'Foo',
"start": "2013-02-05T05:00:00Z",
"image": {
"src": "/path/to/image.jpg",
},
'enrollment_end': None,
'marketing_url': '/path/to/marketing/site'
}
self.mock_access_token_response()
course, __, enrollment_code = self.prepare_course_seat_and_enrollment_code()
self.create_basket_and_add_product(enrollment_code)
self.mock_course_run_detail_endpoint(
course,
self.site_configuration.discovery_api_url,
course_run_info
)
response = self.client.get(self.path)
self.assertEqual(response.status_code, 200)
messages = list(response.context['messages'])
self.assertEqual(len(messages), 1)
self.assertContains(response, '/path/to/marketing/site', status_code=200)
def test_failed_enterprise_consent_sends_message(self): def test_failed_enterprise_consent_sends_message(self):
""" """
Test that if we receive an indication via a query parameter that data sharing Test that if we receive an indication via a query parameter that data sharing
......
...@@ -140,6 +140,7 @@ class BasketSummaryView(BasketView): ...@@ -140,6 +140,7 @@ class BasketSummaryView(BasketView):
short_description = None short_description = None
course_start = None course_start = None
course_end = None course_end = None
course = None
try: try:
course = get_course_info_from_catalog(self.request.site, product) course = get_course_info_from_catalog(self.request.site, product)
...@@ -161,7 +162,10 @@ class BasketSummaryView(BasketView): ...@@ -161,7 +162,10 @@ class BasketSummaryView(BasketView):
if self.request.basket.num_items == 1 and product.is_enrollment_code_product: if self.request.basket.num_items == 1 and product.is_enrollment_code_product:
course_key = CourseKey.from_string(product.attr.course_key) course_key = CourseKey.from_string(product.attr.course_key)
course_about = get_lms_course_about_url(course_key=course_key) if course and course.get('marketing_url', None):
course_about_url = course['marketing_url']
else:
course_about_url = get_lms_course_about_url(course_key=course_key)
messages.info( messages.info(
self.request, self.request,
_( _(
...@@ -173,7 +177,7 @@ class BasketSummaryView(BasketView): ...@@ -173,7 +177,7 @@ class BasketSummaryView(BasketView):
strong_end='</strong>', strong_end='</strong>',
paragraph_start='<p>', paragraph_start='<p>',
paragraph_end='</p>', paragraph_end='</p>',
link_start='<a href="{course_about}">'.format(course_about=course_about), link_start='<a href="{course_about}">'.format(course_about=course_about_url),
link_end='</a>' link_end='</a>'
), ),
extra_tags='safe' extra_tags='safe'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment