Commit 2277aaca by Hasnain

WL-1060 | Made the dashboard social sharing site aware.

parent a1419b15
......@@ -6,6 +6,8 @@ import urllib
from django.conf import settings
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger(__name__)
COURSE_SHARING_UTM_PARAMETERS = {
......@@ -40,14 +42,17 @@ def get_link_for_about_page(course):
Returns the course sharing url, this can be one of course's social sharing url, marketing url, or
lms course about url.
"""
is_social_sharing_enabled = getattr(settings, 'SOCIAL_SHARING_SETTINGS', {}).get('CUSTOM_COURSE_URLS')
is_social_sharing_enabled = configuration_helpers.get_value(
'SOCIAL_SHARING_SETTINGS',
getattr(settings, 'SOCIAL_SHARING_SETTINGS', {})
).get('CUSTOM_COURSE_URLS')
if is_social_sharing_enabled and course.social_sharing_url:
course_about_url = course.social_sharing_url
elif settings.FEATURES.get('ENABLE_MKTG_SITE') and getattr(course, 'marketing_url', None):
course_about_url = course.marketing_url
else:
course_about_url = u'{about_base_url}/courses/{course_key}/about'.format(
about_base_url=settings.LMS_ROOT_URL,
about_base_url=configuration_helpers.get_value('LMS_ROOT_URL', settings.LMS_ROOT_URL),
course_key=unicode(course.id),
)
......
......@@ -2329,12 +2329,14 @@ SOCIAL_SHARING_SETTINGS = {
# Note: Ensure 'CUSTOM_COURSE_URLS' has a matching value in cms/envs/common.py
'CUSTOM_COURSE_URLS': False,
'DASHBOARD_FACEBOOK': False,
'FACEBOOK_BRAND': None,
'CERTIFICATE_FACEBOOK': False,
'CERTIFICATE_FACEBOOK_TEXT': None,
'CERTIFICATE_TWITTER': False,
'CERTIFICATE_TWITTER_TEXT': None,
'DASHBOARD_TWITTER': False,
'DASHBOARD_TWITTER_TEXT': None
'DASHBOARD_TWITTER_TEXT': None,
'TWITTER_BRAND': None
}
################# Social Media Footer Links #######################
......
......@@ -166,7 +166,7 @@ from util.course import get_link_for_about_page, get_encoded_course_sharing_utm_
% if share_settings.get('DASHBOARD_FACEBOOK', False):
<%
facebook_share_url = "{url}?{utm_params}".format(url=share_url.encode('utf-8'), utm_params=encoded_utm_parameters['facebook'])
share_text = _("I'm taking {course_name} online with edX.org. Check it out!").format(course_name=course_overview.display_name_with_default)
share_text = _("I'm taking {course_name} online with {facebook_brand}. Check it out!").format(course_name=course_overview.display_name_with_default, facebook_brand=share_settings.get('FACEBOOK_BRAND', 'edX.org'))
query_params = urllib.urlencode((('u', facebook_share_url), ('quote', share_text.encode('utf-8')),))
facebook_url = 'https://www.facebook.com/sharer/sharer.php?{query}'.format(query=query_params)
share_msg = _("Share {course_name} on Facebook").format(course_name=course_overview.display_name_with_default)
......@@ -187,7 +187,7 @@ from util.course import get_link_for_about_page, get_encoded_course_sharing_utm_
% if share_settings.get('DASHBOARD_TWITTER', False):
<%
twitter_share_url = "{url}?{utm_params}".format(url=share_url.encode('utf-8'), utm_params=encoded_utm_parameters['twitter'])
default_share_text = _("I'm taking {course_name} online with @edxonline. Check it out!").format(course_name=course_overview.display_name_with_default)
default_share_text = _("I'm taking {course_name} online with {twitter_brand}. Check it out!").format(course_name=course_overview.display_name_with_default, twitter_brand=share_settings.get('TWITTER_BRAND', '@edxonline'))
share_text = urllib.quote_plus(share_settings.get('DASHBOARD_TWITTER_TEXT', default_share_text.encode('utf-8')))
twitter_url = 'https://twitter.com/intent/tweet?text=' + share_text + '%20' + urllib.quote_plus(twitter_share_url)
share_msg = _("Share {course_name} on Twitter").format(course_name=course_overview.display_name_with_default)
......
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