Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
f1142967
Commit
f1142967
authored
Jun 05, 2014
by
Zia Fazal
Committed by
Xavier Antoviaque
Sep 26, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added avatar url field
added avatar url field
parent
4426b80d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
2 deletions
+18
-2
common/djangoapps/student/migrations/0035_auto__add_field_userprofile_avatar_url.py
+0
-0
common/djangoapps/student/models.py
+1
-0
lms/djangoapps/api_manager/users/tests.py
+6
-2
lms/djangoapps/api_manager/users/views.py
+11
-0
No files found.
common/djangoapps/student/migrations/0035_auto__add_field_userprofile_avatar_url.py
0 → 100644
View file @
f1142967
This diff is collapsed.
Click to expand it.
common/djangoapps/student/models.py
View file @
f1142967
...
...
@@ -250,6 +250,7 @@ class UserProfile(models.Model):
goals
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
allow_certificate
=
models
.
BooleanField
(
default
=
1
)
title
=
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
null
=
True
)
avatar_url
=
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
null
=
True
)
# pointer to avatar/image resource
def
get_meta
(
self
):
js_str
=
self
.
meta
...
...
lms/djangoapps/api_manager/users/tests.py
View file @
f1142967
...
...
@@ -232,7 +232,8 @@ class UsersApiTests(TestCase):
local_username
=
self
.
test_username
+
str
(
randint
(
11
,
99
))
data
=
{
'email'
:
self
.
test_email
,
'username'
:
local_username
,
'password'
:
self
.
test_password
,
'first_name'
:
self
.
test_first_name
,
'last_name'
:
self
.
test_last_name
,
'city'
:
self
.
test_city
,
'country'
:
'PK'
,
'level_of_education'
:
'b'
,
'year_of_birth'
:
'2000'
,
"gender"
:
'male'
,
"title"
:
'Software Engineer'
}
'last_name'
:
self
.
test_last_name
,
'city'
:
self
.
test_city
,
'country'
:
'PK'
,
'level_of_education'
:
'b'
,
'year_of_birth'
:
'2000'
,
'gender'
:
'male'
,
'title'
:
'Software Engineer'
,
'avatar_url'
:
'http://example.com/avatar.png'
}
response
=
self
.
do_post
(
test_uri
,
data
)
self
.
assertEqual
(
response
.
status_code
,
201
)
test_uri
=
test_uri
+
'/'
+
str
(
response
.
data
[
'id'
])
...
...
@@ -253,12 +254,14 @@ class UsersApiTests(TestCase):
"""
Create a user, then add the user profile with invalid year of birth
Profile Must be added with year_of_birth will be none
and avatar_url None
"""
test_uri
=
'/api/users'
local_username
=
self
.
test_username
+
str
(
randint
(
11
,
99
))
data
=
{
'email'
:
self
.
test_email
,
'username'
:
local_username
,
'password'
:
self
.
test_password
,
'first_name'
:
self
.
test_first_name
,
'last_name'
:
self
.
test_last_name
,
'city'
:
self
.
test_city
,
'country'
:
'PK'
,
'level_of_education'
:
'b'
,
'year_of_birth'
:
'abcd'
,
"gender"
:
'male'
,
"title"
:
'Software Engineer'
}
'last_name'
:
self
.
test_last_name
,
'city'
:
self
.
test_city
,
'country'
:
'PK'
,
'level_of_education'
:
'b'
,
'year_of_birth'
:
'abcd'
,
'gender'
:
'male'
,
'title'
:
'Software Engineer'
,
'avatar_url'
:
None
}
response
=
self
.
do_post
(
test_uri
,
data
)
self
.
assertEqual
(
response
.
status_code
,
201
)
test_uri_1
=
test_uri
+
'/'
+
str
(
response
.
data
[
'id'
])
...
...
@@ -871,6 +874,7 @@ class UsersApiTests(TestCase):
self
.
assertEqual
(
response
.
data
[
'country'
],
data
[
"country"
])
self
.
assertEqual
(
response
.
data
[
'gender'
],
data
[
"gender"
])
self
.
assertEqual
(
response
.
data
[
'title'
],
data
[
"title"
])
self
.
assertEqual
(
response
.
data
[
'avatar_url'
],
data
[
"avatar_url"
])
self
.
assertEqual
(
response
.
data
[
'level_of_education'
],
data
[
"level_of_education"
])
self
.
assertEqual
(
...
...
lms/djangoapps/api_manager/users/views.py
View file @
f1142967
...
...
@@ -60,6 +60,7 @@ def _serialize_user_profile(response_data, user_profile):
response_data
[
'level_of_education'
]
=
user_profile
.
level_of_education
response_data
[
'year_of_birth'
]
=
user_profile
.
year_of_birth
response_data
[
'gender'
]
=
user_profile
.
gender
response_data
[
'avatar_url'
]
=
user_profile
.
avatar_url
return
response_data
...
...
@@ -130,6 +131,7 @@ class UsersList(SecureAPIView):
* level_of_education
* year_of_birth, Four-digit integer value
* gender, Single-character value (M/F)
* avatar_url, pointer to the avatar/image resource
- POST Example:
{
...
...
@@ -146,6 +148,7 @@ class UsersList(SecureAPIView):
"level_of_education" : "hs",
"year_of_birth" : "1996",
"gender" : "F",
"avatar_url" : "http://example.com/avatar.png"
}
### Use Cases/Notes:
* GET requests for _all_ users are not currently allowed via the API
...
...
@@ -173,6 +176,7 @@ class UsersList(SecureAPIView):
year_of_birth
=
request
.
DATA
.
get
(
'year_of_birth'
,
''
)
gender
=
request
.
DATA
.
get
(
'gender'
,
''
)
title
=
request
.
DATA
.
get
(
'title'
,
''
)
avatar_url
=
request
.
DATA
.
get
(
'avatar_url'
,
None
)
# enforce password complexity as an optional feature
if
settings
.
FEATURES
.
get
(
'ENFORCE_PASSWORD_POLICY'
,
False
):
try
:
...
...
@@ -218,6 +222,7 @@ class UsersList(SecureAPIView):
profile
.
level_of_education
=
level_of_education
profile
.
gender
=
gender
profile
.
title
=
title
profile
.
avatar_url
=
avatar_url
try
:
profile
.
year_of_birth
=
int
(
year_of_birth
)
...
...
@@ -265,6 +270,7 @@ class UsersDetail(SecureAPIView):
* level_of_education
* year_of_birth, Four-digit integer value
* gender, Single-character value (M/F)
* avatar_url, pointer to the avatar/image resource
- POST Example:
{
...
...
@@ -281,6 +287,7 @@ class UsersDetail(SecureAPIView):
"level_of_education" : "hs",
"year_of_birth" : "1996",
"gender" : "F",
"avatar_url" : "http://example.com/avatar.png"
}
### Use Cases/Notes:
* Use the UsersDetail view to obtain the current state for a specific User
...
...
@@ -452,6 +459,10 @@ class UsersDetail(SecureAPIView):
title
=
request
.
DATA
.
get
(
'title'
)
if
title
:
existing_user_profile
.
title
=
title
avatar_url
=
request
.
DATA
.
get
(
'avatar_url'
)
if
avatar_url
:
existing_user_profile
.
avatar_url
=
avatar_url
existing_user_profile
.
save
()
return
Response
(
response_data
,
status
=
status
.
HTTP_200_OK
)
...
...
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