From 1782f72555d8605eaed9920a15e55c7a3fb113fa Mon Sep 17 00:00:00 2001 From: asadiqbal Date: Mon, 6 Jul 2015 17:05:38 +0500 Subject: [PATCH 1/3] Students can share their certificate view on Twitter --- lms/envs/common.py | 2 ++ .../certificates/_accomplishment-banner.html | 28 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index 1bbd35295b..6a13d69c73 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -390,6 +390,8 @@ FEATURES = { 'DASHBOARD_FACEBOOK': False, 'CERTIFICATE_FACEBOOK': False, 'CERTIFICATE_FACEBOOK_TEXT': None, + 'CERTIFICATE_TWITTER': False, + 'CERTIFICATE_TWITTER_TEXT': None, 'DASHBOARD_TWITTER': False, 'DASHBOARD_TWITTER_TEXT': None }, diff --git a/lms/templates/certificates/_accomplishment-banner.html b/lms/templates/certificates/_accomplishment-banner.html index a20056d261..acd3396558 100644 --- a/lms/templates/certificates/_accomplishment-banner.html +++ b/lms/templates/certificates/_accomplishment-banner.html @@ -32,6 +32,13 @@ from django.core.urlresolvers import reverse Logger.log('edx.certificate.shared', data); }); }); + + function popupWindow(url, title, width, height) { + // popup a window at center of the screen. + var left = (screen.width/2)-(width/2); + var top = (screen.height/2)-(height/2); + return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width='+width+', height='+height+', top='+top+', left='+left); + }
@@ -46,14 +53,18 @@ from django.core.urlresolvers import reverse % if share_settings: <% facebook_share_text = _("I completed the {course_title} course on {platform_name}.").format(course_title=accomplishment_course_title, platform_name=platform_name) + twitter_share_text = _("I completed a course on {platform_name}. See my certificate here!").format(platform_name=platform_name) + share_url = request.build_absolute_uri(reverse('cert_html_view', kwargs=dict(user_id=str(user.id),course_id=unicode(course_id)))) if share_settings.get('CERTIFICATE_FACEBOOK_TEXT', None): facebook_share_text = share_settings.get('CERTIFICATE_FACEBOOK_TEXT') + if share_settings.get('CERTIFICATE_TWITTER_TEXT', None): + twitter_share_text = share_settings.get('CERTIFICATE_TWITTER_TEXT') %> % if share_settings.get('CERTIFICATE_FACEBOOK', False): ${_("Post on Facebook")} %endif + % if share_settings.get('CERTIFICATE_TWITTER', False): + <% twitter_url = 'https://twitter.com/intent/tweet?text=' + twitter_share_text + '&url='+ share_url%> + + %endif %endif %if linked_in_url: From 68ee36e84e02f0447d581a0304d25bbd229383a4 Mon Sep 17 00:00:00 2001 From: asadiqbal Date: Mon, 13 Jul 2015 13:54:01 +0500 Subject: [PATCH 2/3] update the code as per suggestions --- .../certificates/_accomplishment-banner.html | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/lms/templates/certificates/_accomplishment-banner.html b/lms/templates/certificates/_accomplishment-banner.html index acd3396558..da133f34b2 100644 --- a/lms/templates/certificates/_accomplishment-banner.html +++ b/lms/templates/certificates/_accomplishment-banner.html @@ -53,7 +53,7 @@ from django.core.urlresolvers import reverse % if share_settings: <% facebook_share_text = _("I completed the {course_title} course on {platform_name}.").format(course_title=accomplishment_course_title, platform_name=platform_name) - twitter_share_text = _("I completed a course on {platform_name}. See my certificate here!").format(platform_name=platform_name) + twitter_share_text = _("I completed a course on {platform_name}. Take a look at my certificate.").format(platform_name=platform_name) share_url = request.build_absolute_uri(reverse('cert_html_view', kwargs=dict(user_id=str(user.id),course_id=unicode(course_id)))) if share_settings.get('CERTIFICATE_FACEBOOK_TEXT', None): facebook_share_text = share_settings.get('CERTIFICATE_FACEBOOK_TEXT') @@ -61,32 +61,26 @@ from django.core.urlresolvers import reverse twitter_share_text = share_settings.get('CERTIFICATE_TWITTER_TEXT') %> % if share_settings.get('CERTIFICATE_FACEBOOK', False): - + });"> ${_("Post on Facebook")} - + %endif % if share_settings.get('CERTIFICATE_TWITTER', False): <% twitter_url = 'https://twitter.com/intent/tweet?text=' + twitter_share_text + '&url='+ share_url%> - + + ${_("Tweet this Accomplishment. Pop up window.")} + %endif %endif From 19d6012033539419f5e3f950576709ef14b6a166 Mon Sep 17 00:00:00 2001 From: asadiqbal Date: Mon, 13 Jul 2015 15:57:50 +0500 Subject: [PATCH 3/3] bokchoy update --- common/test/acceptance/pages/lms/certificate_page.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/test/acceptance/pages/lms/certificate_page.py b/common/test/acceptance/pages/lms/certificate_page.py index 63319d6a39..e2a161caa8 100644 --- a/common/test/acceptance/pages/lms/certificate_page.py +++ b/common/test/acceptance/pages/lms/certificate_page.py @@ -56,4 +56,4 @@ class CertificatePage(PageObject): """ returns Facebook share button """ - return self.q(css='a.action-share-facebook') + return self.q(css='button.action-share-facebook')