diff --git a/linkedin-login.py b/linkedin-login.py new file mode 100644 index 0000000000..fcd90c39b3 --- /dev/null +++ b/linkedin-login.py @@ -0,0 +1,36 @@ +import urllib2 +import uuid + +CLIENT_ID = "77zv1vf44fo92m" +CLIENT_SECRET = "1M3wZUNA2aYHldbv" +REDIRECT_URI = "http://www.edx.org" +STATE = uuid.uuid4() +SCOPE = "%20".join([ + "r_basicprofile", + "r_fullprofile", + "r_emailaddress", + "r_network", + "r_contactinfo", + "rw_nus", + "rw_company_admin", + "rw_groups", + "w_messages"]) + +print "Go here:" +print ("https://www.linkedin.com/uas/oauth2/authorization?response_type=code" + "&client_id=%s&state=%s&redirect_uri=%s&scope=%s" % + (CLIENT_ID, STATE, REDIRECT_URI, SCOPE)) + +print "Enter authcode: ", +code = raw_input() + +url = ("https://www.linkedin.com/uas/oauth2/accessToken" + "?grant_type=authorization_code" + "&code=%s&redirect_uri=%s&client_id=%s&client_secret=%s" % ( + code, REDIRECT_URI, CLIENT_ID, CLIENT_SECRET)) +try: + print urllib2.urlopen(url).read() +except urllib2.HTTPError, e: + print "!!ERROR!!" + print e + print e.read() diff --git a/lms/djangoapps/linkedin/management/commands/mailusers.py b/lms/djangoapps/linkedin/management/commands/mailusers.py index aca7e35bfc..b046bd0445 100644 --- a/lms/djangoapps/linkedin/management/commands/mailusers.py +++ b/lms/djangoapps/linkedin/management/commands/mailusers.py @@ -5,7 +5,10 @@ LinkedIn profiles. import json +from courseware.courses import get_course_by_id from django.core.management.base import BaseCommand +from django.template import Context +from django.template.loader import get_template from optparse import make_option from certificates.models import GeneratedCertificate @@ -69,4 +72,10 @@ def send_email(user, certificate): Email a user that recently earned a certificate, inviting them to post their certificate on their LinkedIn profile. """ - print "EMAIL: ", user, certificate + template = get_template("linkedin_email.html") + course = get_course_by_id(certificate.course_id) + context = Context({ + 'student_name': user.profile.name, + 'course_name': 'XXX', + 'url': '#'}) + print template.render(context) diff --git a/lms/djangoapps/linkedin/templates/linkedin_email.html b/lms/djangoapps/linkedin/templates/linkedin_email.html new file mode 100644 index 0000000000..54db13d894 --- /dev/null +++ b/lms/djangoapps/linkedin/templates/linkedin_email.html @@ -0,0 +1,25 @@ +{% load i18n %} + + + + + + + +

{% blocktrans with name=student_name %} + Dear {{student_name}}, + {% endblocktrans %}

+ +

{% blocktrans with name=course_name %} + Congratulations on earning your certificate in {{course_name}}! + Since you have an account on LinkedIn, you can display your hard earned + credential for your colleagues to see. Click the button below to add the + certificate to your profile. + {% endblocktrans %}

+ +

+ in + {% blocktrans %}Add to profile{% endblocktrans %} +

+ +