Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
5b432ede
Commit
5b432ede
authored
Nov 21, 2016
by
Douglas Hall
Committed by
GitHub
Nov 21, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14031 from edx/douglashall/WL-833
WL-833 Allow for LinkedIn add to profile cert name override
parents
c575e7f2
1c8e859b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
3 deletions
+63
-3
common/djangoapps/student/models.py
+17
-3
common/djangoapps/student/tests/test_linkedin.py
+46
-0
No files found.
common/djangoapps/student/models.py
View file @
5b432ede
...
...
@@ -2065,11 +2065,25 @@ class LinkedInAddToProfileConfiguration(ConfigurationModel):
)
def
_cert_name
(
self
,
course_name
,
cert_mode
):
"""Name of the certification, for display on LinkedIn. """
return
self
.
MODE_TO_CERT_NAME
.
get
(
"""
Name of the certification, for display on LinkedIn.
Arguments:
course_name (unicode): The display name of the course.
cert_mode (str): The course mode of the user's certificate (e.g. "verified", "honor", "professional")
Returns:
str: The formatted string to display for the name field on the LinkedIn Add to Profile dialog.
"""
default_cert_name
=
self
.
MODE_TO_CERT_NAME
.
get
(
cert_mode
,
_
(
u"{platform_name} Certificate for {course_name}"
)
)
.
format
(
)
# Look for an override of the certificate name in the SOCIAL_SHARING_SETTINGS setting
share_settings
=
configuration_helpers
.
get_value
(
'SOCIAL_SHARING_SETTINGS'
,
settings
.
SOCIAL_SHARING_SETTINGS
)
cert_name
=
share_settings
.
get
(
'CERTIFICATE_LINKEDIN_MODE_TO_CERT_NAME'
,
{})
.
get
(
cert_mode
,
default_cert_name
)
return
cert_name
.
format
(
platform_name
=
configuration_helpers
.
get_value
(
'platform_name'
,
settings
.
PLATFORM_NAME
),
course_name
=
course_name
)
...
...
common/djangoapps/student/tests/test_linkedin.py
View file @
5b432ede
...
...
@@ -7,6 +7,7 @@ from urllib import urlencode, quote
from
django.conf
import
settings
from
django.test
import
TestCase
from
opaque_keys.edx.locator
import
CourseLocator
from
openedx.core.djangoapps.site_configuration.tests.test_util
import
with_site_configuration_context
from
student.models
import
LinkedInAddToProfileConfiguration
...
...
@@ -17,6 +18,16 @@ class LinkedInAddToProfileUrlTests(TestCase):
COURSE_KEY
=
CourseLocator
(
org
=
"edx"
,
course
=
"DemoX"
,
run
=
"Demo_Course"
)
COURSE_NAME
=
u"Test Course ☃"
CERT_URL
=
u"http://s3.edx/cert"
SITE_CONFIGURATION
=
{
'SOCIAL_SHARING_SETTINGS'
:
{
'CERTIFICATE_LINKEDIN_MODE_TO_CERT_NAME'
:
{
'honor'
:
u'{platform_name} Honor Code Credential for {course_name}'
,
'verified'
:
u'{platform_name} Verified Credential for {course_name}'
,
'professional'
:
u'{platform_name} Professional Credential for {course_name}'
,
'no-id-professional'
:
u'{platform_name} Professional Credential for {course_name}'
,
}
}
}
@ddt.data
(
(
'honor'
,
u'Honor+Code+Certificate+for+Test+Course+
%
E2
%98%83
'
),
...
...
@@ -51,6 +62,41 @@ class LinkedInAddToProfileUrlTests(TestCase):
self
.
assertEqual
(
actual_url
,
expected_url
)
@ddt.data
(
(
'honor'
,
u'Honor+Code+Credential+for+Test+Course+
%
E2
%98%83
'
),
(
'verified'
,
u'Verified+Credential+for+Test+Course+
%
E2
%98%83
'
),
(
'professional'
,
u'Professional+Credential+for+Test+Course+
%
E2
%98%83
'
),
(
'no-id-professional'
,
u'Professional+Credential+for+Test+Course+
%
E2
%98%83
'
),
(
'default_mode'
,
u'Certificate+for+Test+Course+
%
E2
%98%83
'
)
)
@ddt.unpack
def
test_linked_in_url_with_cert_name_override
(
self
,
cert_mode
,
expected_cert_name
):
config
=
LinkedInAddToProfileConfiguration
(
company_identifier
=
'0_mC_o2MizqdtZEmkVXjH4eYwMj4DnkCWrZP_D9'
,
enabled
=
True
)
expected_url
=
(
'http://www.linkedin.com/profile/add'
'?_ed=0_mC_o2MizqdtZEmkVXjH4eYwMj4DnkCWrZP_D9&'
'pfCertificationName={platform_name}+{expected_cert_name}&'
'pfCertificationUrl=http
%3
A
%2
F
%2
Fs3.edx
%2
Fcert&'
'source=o'
)
.
format
(
expected_cert_name
=
expected_cert_name
,
platform_name
=
quote
(
settings
.
PLATFORM_NAME
.
encode
(
'utf-8'
))
)
with
with_site_configuration_context
(
configuration
=
self
.
SITE_CONFIGURATION
):
actual_url
=
config
.
add_to_profile_url
(
self
.
COURSE_KEY
,
self
.
COURSE_NAME
,
cert_mode
,
self
.
CERT_URL
)
self
.
assertEqual
(
actual_url
,
expected_url
)
def
test_linked_in_url_tracking_code
(
self
):
config
=
LinkedInAddToProfileConfiguration
(
company_identifier
=
"abcd123"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment