Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
roomlist
Commits
8ac74f4c
Commit
8ac74f4c
authored
Apr 09, 2015
by
Daniel W Bond
Browse files
cas callbacking with peoplefinder
parent
acfc3e5e
Changes
1
Show whitespace changes
Inline
Side-by-side
roomlist/accounts/cas_callbacks.py
View file @
8ac74f4c
...
...
@@ -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
()
...
...
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