Commit c230f22b by asadiqbal

SOL-1097

parent 73722c47
......@@ -39,6 +39,8 @@ from certificates.tests.factories import (
BadgeAssertionFactory,
)
from util import organizations_helpers as organizations_api
from django.test.client import RequestFactory
import urllib
FEATURES_WITH_CERTS_ENABLED = settings.FEATURES.copy()
FEATURES_WITH_CERTS_ENABLED['CERTIFICATES_HTML_VIEW'] = True
......@@ -379,6 +381,7 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
self.user.profile.name = "Joe User"
self.user.profile.save()
self.client.login(username=self.user.username, password='foo')
self.request = RequestFactory().request()
self.cert = GeneratedCertificate.objects.create(
user=self.user,
......@@ -458,6 +461,19 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
template.save()
@override_settings(FEATURES=FEATURES_WITH_CERTS_ENABLED)
def test_linkedin_share_url(self):
"""
Test: LinkedIn share URL.
"""
self._add_course_certificates(count=1, signatory_count=1, is_active=True)
test_url = get_certificate_url(
user_id=self.user.id,
course_id=unicode(self.course.id)
)
response = self.client.get(test_url)
self.assertTrue(urllib.quote_plus(self.request.build_absolute_uri(test_url)) in response.content)
@override_settings(FEATURES=FEATURES_WITH_CERTS_ENABLED)
def test_rendering_course_organization_data(self):
"""
Test: organization data should render on certificate web view if course has organization.
......
......@@ -228,21 +228,6 @@ def _update_certificate_context(context, course, user, user_certificate):
if certificate_type_description:
context['certificate_type_description'] = certificate_type_description
# If enabled, show the LinkedIn "add to profile" button
# Clicking this button sends the user to LinkedIn where they
# can add the certificate information to their profile.
linkedin_config = LinkedInAddToProfileConfiguration.current()
if linkedin_config.enabled:
context['linked_in_url'] = linkedin_config.add_to_profile_url(
course.id,
course.display_name,
user_certificate.mode,
get_certificate_url(
user_id=user.id,
course_id=unicode(course.id)
)
)
# Translators: This line is displayed to a user who has completed a course and achieved a certification
context['accomplishment_banner_opening'] = _("{fullname}, you've earned a certificate!").format(
fullname=user_fullname
......@@ -377,6 +362,21 @@ def render_html_view(request, user_id, course_id):
# Append/Override the existing view context values with request-time values
_update_certificate_context(context, course, user, user_certificate)
# If enabled, show the LinkedIn "add to profile" button
# Clicking this button sends the user to LinkedIn where they
# can add the certificate information to their profile.
linkedin_config = LinkedInAddToProfileConfiguration.current()
if linkedin_config.enabled:
context['linked_in_url'] = linkedin_config.add_to_profile_url(
course.id,
course.display_name,
user_certificate.mode,
request.build_absolute_uri(get_certificate_url(
user_id=user.id,
course_id=unicode(course.id)
))
)
# Microsites will need to be able to override any hard coded
# content that was put into the context in the
# _update_certificate_context() call above. For example the
......
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