Commit 8ac74f4c authored by Daniel W Bond's avatar Daniel W Bond
Browse files

cas callbacking with peoplefinder

parent acfc3e5e
......@@ -4,6 +4,21 @@ from accounts.models import Student
from django.conf import settings
import requests
def pfinfo(uname):
base_url = "http://peoplefinder.b1.akshaykarthik.com/"
url = base_url + "basic/all/" + str(uname)
try:
metadata = requests.get(url)
metadata.raise_for_status()
except requests.exceptions.RequestException as e:
print e
else:
pfjson = metadata.json()
name = pfjson['results'][0]['name']
return name.split(',')
def create_user(tree):
username = tree[0][0].text
......@@ -11,7 +26,13 @@ def create_user(tree):
if user_created:
user.email = "%s@%s" % (username, settings.ORGANIZATION_EMAIL_DOMAIN)
name_list = pfinfo(username)
user.first_name = name_list[1].rstrip()
user.last_name = name_list[0]
user.save()
new_student = Student.objects.create(user=user)
new_student.save()
......
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