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
6e861f26
Commit
6e861f26
authored
Jan 29, 2016
by
Zia Fazal
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11352 from edx/ziafazal/WL-209
ziafazal/WL-209:Cert Social Sharing customization
parents
bae91014
463e8c82
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
128 additions
and
14 deletions
+128
-14
common/djangoapps/student/models.py
+4
-2
lms/djangoapps/certificates/tests/test_webview_views.py
+118
-6
lms/djangoapps/certificates/views/webview.py
+4
-6
lms/envs/test.py
+2
-0
No files found.
common/djangoapps/student/models.py
View file @
6e861f26
...
...
@@ -48,6 +48,7 @@ from xmodule_django.models import CourseKeyField, NoneToEmptyManager
from
certificates.models
import
GeneratedCertificate
from
course_modes.models
import
CourseMode
from
enrollment.api
import
_default_course_mode
from
microsite_configuration
import
microsite
import
lms.lib.comment_client
as
cc
from
openedx.core.djangoapps.commerce.utils
import
ecommerce_api_client
,
ECOMMERCE_DATE_FORMAT
from
openedx.core.djangoapps.content.course_overviews.models
import
CourseOverview
...
...
@@ -1854,8 +1855,9 @@ class LinkedInAddToProfileConfiguration(ConfigurationModel):
target (str): An identifier for the occurrance of the button.
"""
company_identifier
=
microsite
.
get_value
(
'LINKEDIN_COMPANY_ID'
,
self
.
company_identifier
)
params
=
OrderedDict
([
(
'_ed'
,
self
.
company_identifier
),
(
'_ed'
,
company_identifier
),
(
'pfCertificationName'
,
self
.
_cert_name
(
course_name
,
cert_mode
)
.
encode
(
'utf-8'
)),
(
'pfCertificationUrl'
,
cert_url
),
(
'source'
,
source
)
...
...
@@ -1875,7 +1877,7 @@ class LinkedInAddToProfileConfiguration(ConfigurationModel):
cert_mode
,
_
(
u"{platform_name} Certificate for {course_name}"
)
)
.
format
(
platform_name
=
settings
.
PLATFORM_NAME
,
platform_name
=
microsite
.
get_value
(
'platform_name'
,
settings
.
PLATFORM_NAME
)
,
course_name
=
course_name
)
...
...
lms/djangoapps/certificates/tests/test_webview_views.py
View file @
6e861f26
...
...
@@ -7,6 +7,8 @@ import mock
from
uuid
import
uuid4
from
nose.plugins.attrib
import
attr
from
mock
import
patch
from
urllib
import
urlencode
from
collections
import
OrderedDict
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
...
...
@@ -82,6 +84,7 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
self
.
user
.
profile
.
save
()
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
'foo'
)
self
.
request
=
RequestFactory
()
.
request
()
self
.
linknedin_url
=
'http://www.linkedin.com/profile/add?{params}'
self
.
cert
=
GeneratedCertificateFactory
.
create
(
user
=
self
.
user
,
...
...
@@ -172,20 +175,129 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
test_url
=
get_certificate_url
(
course_id
=
self
.
course
.
id
,
uuid
=
self
.
cert
.
verify_uuid
)
response
=
self
.
client
.
get
(
test_url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertIn
(
urllib
.
quote_plus
(
self
.
request
.
build_absolute_uri
(
test_url
)),
response
.
content
)
params
=
OrderedDict
([
(
'_ed'
,
'0_0dPSPyS070e0HsE9HNz_13_d11_'
,),
(
'pfCertificationName'
,
'{platform_name} Honor Code Certificate for {course_name}'
.
format
(
platform_name
=
settings
.
PLATFORM_NAME
,
course_name
=
self
.
course
.
display_name
,
),),
(
'pfCertificationUrl'
,
self
.
request
.
build_absolute_uri
(
test_url
),),
])
self
.
assertIn
(
self
.
linknedin_url
.
format
(
params
=
urlencode
(
params
)),
response
.
content
)
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
@mock.patch
(
"microsite_configuration.microsite.is_request_in_microsite"
,
_fake_is_request_in_microsite
)
def
test_linkedin_share_microsites
(
self
):
"""
Test: LinkedIn share URL should
not be visible when called from within a microsite (for now)
Test: LinkedIn share URL should
be visible when called from within a microsite.
"""
self
.
_add_course_certificates
(
count
=
1
,
signatory_count
=
1
,
is_active
=
True
)
test_url
=
get_certificate_url
(
course_id
=
self
.
cert
.
course_id
,
uuid
=
self
.
cert
.
verify_uuid
)
response
=
self
.
client
.
get
(
test_url
)
response
=
self
.
client
.
get
(
test_url
,
HTTP_HOST
=
settings
.
MICROSITE_TEST_HOSTNAME
)
self
.
assertEqual
(
response
.
status_code
,
200
)
# the linkedIn share URL with appropriate parameters should be present
params
=
OrderedDict
([
(
'_ed'
,
settings
.
MICROSITE_CONFIGURATION
[
'test_microsite'
][
'LINKEDIN_COMPANY_ID'
],),
(
'pfCertificationName'
,
'{platform_name} Honor Code Certificate for {course_name}'
.
format
(
platform_name
=
settings
.
MICROSITE_CONFIGURATION
[
'test_microsite'
][
'platform_name'
],
course_name
=
self
.
course
.
display_name
,
),),
(
'pfCertificationUrl'
,
'http://'
+
settings
.
MICROSITE_TEST_HOSTNAME
+
test_url
,),
])
self
.
assertIn
(
self
.
linknedin_url
.
format
(
params
=
urlencode
(
params
)),
response
.
content
)
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
@patch.dict
(
"django.conf.settings.SOCIAL_SHARING_SETTINGS"
,
{
"CERTIFICATE_FACEBOOK"
:
True
})
def
test_facebook_share_microsites
(
self
):
"""
Test: Facebook share URL should be visible when web cert called from within a white label
site and it should use white label site's FACEBOOK_APP_ID.
"""
self
.
_add_course_certificates
(
count
=
1
,
signatory_count
=
1
,
is_active
=
True
)
test_url
=
get_certificate_url
(
course_id
=
self
.
cert
.
course_id
,
uuid
=
self
.
cert
.
verify_uuid
)
response
=
self
.
client
.
get
(
test_url
,
HTTP_HOST
=
settings
.
MICROSITE_TEST_HOSTNAME
)
self
.
assertEqual
(
response
.
status_code
,
200
)
# the URL should not be present
self
.
assertNotIn
(
urllib
.
quote_plus
(
self
.
request
.
build_absolute_uri
(
test_url
)),
response
.
content
)
self
.
assertIn
(
"Post on Facebook"
,
response
.
content
)
self
.
assertIn
(
settings
.
MICROSITE_CONFIGURATION
[
'test_microsite'
][
'FACEBOOK_APP_ID'
],
response
.
content
)
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
@ddt.data
(
(
False
,
False
,
False
),
(
False
,
False
,
True
),
(
False
,
True
,
True
),
(
True
,
True
,
True
),
(
True
,
True
,
False
),
)
@ddt.unpack
def
test_social_sharing_availablity_microsites
(
self
,
facebook_sharing
,
twitter_sharing
,
linkedin_sharing
):
"""
Test: Facebook, Twitter and LinkedIn sharing availability for microsites.
"""
self
.
_add_course_certificates
(
count
=
1
,
signatory_count
=
1
,
is_active
=
True
)
test_url
=
get_certificate_url
(
course_id
=
self
.
cert
.
course_id
,
uuid
=
self
.
cert
.
verify_uuid
)
social_sharing_settings
=
dict
(
CERTIFICATE_FACEBOOK
=
facebook_sharing
,
CERTIFICATE_TWITTER
=
twitter_sharing
,
CERTIFICATE_LINKEDIN
=
linkedin_sharing
,
)
with
patch
(
"django.conf.settings.MICROSITE_CONFIGURATION"
,
{
"test_microsite"
:
dict
(
settings
.
MICROSITE_CONFIGURATION
[
'test_microsite'
],
SOCIAL_SHARING_SETTINGS
=
social_sharing_settings
,
)
}):
response
=
self
.
client
.
get
(
test_url
,
HTTP_HOST
=
settings
.
MICROSITE_TEST_HOSTNAME
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
"Post on Facebook"
in
response
.
content
,
facebook_sharing
)
self
.
assertEqual
(
"Share on Twitter"
in
response
.
content
,
twitter_sharing
)
self
.
assertEqual
(
"Add to LinkedIn Profile"
in
response
.
content
,
linkedin_sharing
)
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
def
test_facebook_default_text_microsites
(
self
):
"""
Test: Facebook sharing default text for microsites.
"""
self
.
_add_course_certificates
(
count
=
1
,
signatory_count
=
1
,
is_active
=
True
)
test_url
=
get_certificate_url
(
course_id
=
self
.
cert
.
course_id
,
uuid
=
self
.
cert
.
verify_uuid
)
facebook_text
=
"Facebook text on Test Microsite"
social_sharing_settings
=
dict
(
CERTIFICATE_FACEBOOK
=
True
,
CERTIFICATE_FACEBOOK_TEXT
=
facebook_text
,
)
with
patch
(
"django.conf.settings.MICROSITE_CONFIGURATION"
,
{
"test_microsite"
:
dict
(
settings
.
MICROSITE_CONFIGURATION
[
'test_microsite'
],
SOCIAL_SHARING_SETTINGS
=
social_sharing_settings
,
)
}):
response
=
self
.
client
.
get
(
test_url
,
HTTP_HOST
=
settings
.
MICROSITE_TEST_HOSTNAME
)
self
.
assertContains
(
response
,
facebook_text
)
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
def
test_twitter_default_text_microsites
(
self
):
"""
Test: Twitter sharing default text for microsites.
"""
self
.
_add_course_certificates
(
count
=
1
,
signatory_count
=
1
,
is_active
=
True
)
test_url
=
get_certificate_url
(
course_id
=
self
.
cert
.
course_id
,
uuid
=
self
.
cert
.
verify_uuid
)
twitter_text
=
"Twitter text on Test Microsite"
social_sharing_settings
=
dict
(
CERTIFICATE_TWITTER
=
True
,
CERTIFICATE_TWITTER_TEXT
=
twitter_text
,
)
with
patch
(
"django.conf.settings.MICROSITE_CONFIGURATION"
,
{
"test_microsite"
:
dict
(
settings
.
MICROSITE_CONFIGURATION
[
'test_microsite'
],
SOCIAL_SHARING_SETTINGS
=
social_sharing_settings
,
)
}):
response
=
self
.
client
.
get
(
test_url
,
HTTP_HOST
=
settings
.
MICROSITE_TEST_HOSTNAME
)
self
.
assertContains
(
response
,
twitter_text
)
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
def
test_rendering_course_organization_data
(
self
):
...
...
lms/djangoapps/certificates/views/webview.py
View file @
6e861f26
...
...
@@ -250,9 +250,9 @@ def _update_social_context(request, context, course, user, user_certificate, pla
"""
Updates context dictionary with info required for social sharing.
"""
share_settings
=
getattr
(
settings
,
'SOCIAL_SHARING_SETTINGS'
,
{}
)
share_settings
=
microsite
.
get_value
(
"SOCIAL_SHARING_SETTINGS"
,
settings
.
SOCIAL_SHARING_SETTINGS
)
context
[
'facebook_share_enabled'
]
=
share_settings
.
get
(
'CERTIFICATE_FACEBOOK'
,
False
)
context
[
'facebook_app_id'
]
=
getattr
(
settings
,
"FACEBOOK_APP_ID"
,
None
)
context
[
'facebook_app_id'
]
=
microsite
.
get_value
(
"FACEBOOK_APP_ID"
,
settings
.
FACEBOOK_APP_ID
)
context
[
'facebook_share_text'
]
=
share_settings
.
get
(
'CERTIFICATE_FACEBOOK_TEXT'
,
_
(
"I completed the {course_title} course on {platform_name}."
)
.
format
(
...
...
@@ -282,10 +282,8 @@ def _update_social_context(request, context, course, user, user_certificate, pla
# Clicking this button sends the user to LinkedIn where they
# can add the certificate information to their profile.
linkedin_config
=
LinkedInAddToProfileConfiguration
.
current
()
# posting certificates to LinkedIn is not currently
# supported in microsites/White Labels
if
linkedin_config
.
enabled
and
not
microsite
.
is_request_in_microsite
():
linkedin_share_enabled
=
share_settings
.
get
(
'CERTIFICATE_LINKEDIN'
,
linkedin_config
.
enabled
)
if
linkedin_share_enabled
:
context
[
'linked_in_url'
]
=
linkedin_config
.
add_to_profile_url
(
course
.
id
,
course
.
display_name
,
...
...
lms/envs/test.py
View file @
6e861f26
...
...
@@ -450,6 +450,8 @@ MICROSITE_CONFIGURATION = {
"ENABLE_SHOPPING_CART"
:
True
,
"ENABLE_PAID_COURSE_REGISTRATION"
:
True
,
"SESSION_COOKIE_DOMAIN"
:
"test_microsite.localhost"
,
"LINKEDIN_COMPANY_ID"
:
"test"
,
"FACEBOOK_APP_ID"
:
"12345678908"
,
"urls"
:
{
'ABOUT'
:
'testmicrosite/about'
,
'PRIVACY'
:
'testmicrosite/privacy'
,
...
...
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