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
bookshare
Commits
9ab49412
Commit
9ab49412
authored
Apr 04, 2015
by
Daniel W Bond
Browse files
trying to figure out peoplefinder incorporation
parent
17c478f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
bookshare/core/cas_callbacks.py
View file @
9ab49412
from
django.contrib.auth.models
import
User
from
django.conf
import
settings
from
.models
import
Student
import
requests
def
pfinfo
(
u_name
):
pf_url
=
"http://peoplefinder.b1.akshaykarthik.com/"
url
=
str
(
pf_url
)
+
"basic/all/"
+
str
(
u_name
)
try
:
metadata
=
requests
.
get
(
url
)
metadata
.
raise_for_status
()
except
requests
.
exceptions
.
RequestException
as
e
:
print
e
else
:
pf_json
=
metadata
.
json
()
name
=
pf_json
[
'results'
][
0
][
'name'
]
return
name
.
split
(
','
)
def
create_user
(
tree
):
username
=
tree
[
0
][
0
].
text
print
username
user
,
user_created
=
User
.
objects
.
get_or_create
(
username
=
username
)
if
user_created
:
user
.
email
=
"%s@%s"
%
(
username
,
settings
.
ORGANIZATION_EMAIL_DOMAIN
)
# print "hello"
# name_list = pfinfo(str(username))
# print "world"
# user.first_name = name_list[1].rstrip()
# print "something"
# 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