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
fad63938
Commit
fad63938
authored
Mar 12, 2015
by
cahrens
Committed by
Andy Armstrong
Apr 17, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New bio field in UserProfile.
parent
0a962bf9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
8 deletions
+25
-8
common/djangoapps/student/migrations/0047_add_bio_field.py
+0
-0
common/djangoapps/student/models.py
+1
-0
openedx/core/djangoapps/user_api/accounts/serializers.py
+2
-1
openedx/core/djangoapps/user_api/accounts/tests/test_views.py
+8
-2
openedx/core/djangoapps/user_api/accounts/views.py
+14
-5
No files found.
common/djangoapps/student/migrations/0047_add_bio_field.py
0 → 100644
View file @
fad63938
This diff is collapsed.
Click to expand it.
common/djangoapps/student/models.py
View file @
fad63938
...
@@ -249,6 +249,7 @@ class UserProfile(models.Model):
...
@@ -249,6 +249,7 @@ class UserProfile(models.Model):
country
=
CountryField
(
blank
=
True
,
null
=
True
)
country
=
CountryField
(
blank
=
True
,
null
=
True
)
goals
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
goals
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
allow_certificate
=
models
.
BooleanField
(
default
=
1
)
allow_certificate
=
models
.
BooleanField
(
default
=
1
)
bio
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
def
get_meta
(
self
):
# pylint: disable=missing-docstring
def
get_meta
(
self
):
# pylint: disable=missing-docstring
js_str
=
self
.
meta
js_str
=
self
.
meta
...
...
openedx/core/djangoapps/user_api/accounts/serializers.py
View file @
fad63938
...
@@ -21,7 +21,8 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer):
...
@@ -21,7 +21,8 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer):
class
Meta
:
class
Meta
:
model
=
UserProfile
model
=
UserProfile
fields
=
(
fields
=
(
"name"
,
"gender"
,
"goals"
,
"year_of_birth"
,
"level_of_education"
,
"language"
,
"country"
,
"mailing_address"
"name"
,
"gender"
,
"goals"
,
"year_of_birth"
,
"level_of_education"
,
"language"
,
"country"
,
"mailing_address"
,
"bio"
)
)
# Currently no read-only field, but keep this so view code doesn't need to know.
# Currently no read-only field, but keep this so view code doesn't need to know.
read_only_fields
=
()
read_only_fields
=
()
...
...
openedx/core/djangoapps/user_api/accounts/tests/test_views.py
View file @
fad63938
...
@@ -85,6 +85,7 @@ class UserAPITestCase(APITestCase):
...
@@ -85,6 +85,7 @@ class UserAPITestCase(APITestCase):
legacy_profile
.
year_of_birth
=
1900
legacy_profile
.
year_of_birth
=
1900
legacy_profile
.
goals
=
"world peace"
legacy_profile
.
goals
=
"world peace"
legacy_profile
.
mailing_address
=
"Park Ave"
legacy_profile
.
mailing_address
=
"Park Ave"
legacy_profile
.
bio
=
"Tired mother of twins"
legacy_profile
.
save
()
legacy_profile
.
save
()
...
@@ -110,7 +111,7 @@ class TestAccountAPI(UserAPITestCase):
...
@@ -110,7 +111,7 @@ class TestAccountAPI(UserAPITestCase):
self
.
assertIsNone
(
data
[
"profile_image"
])
self
.
assertIsNone
(
data
[
"profile_image"
])
self
.
assertIsNone
(
data
[
"time_zone"
])
self
.
assertIsNone
(
data
[
"time_zone"
])
self
.
assertIsNone
(
data
[
"languages"
])
self
.
assertIsNone
(
data
[
"languages"
])
self
.
assert
IsNone
(
data
[
"bio"
])
self
.
assert
Equal
(
"Tired mother of twins"
,
data
[
"bio"
])
def
_verify_private_account_response
(
self
,
response
):
def
_verify_private_account_response
(
self
,
response
):
"""
"""
...
@@ -139,6 +140,7 @@ class TestAccountAPI(UserAPITestCase):
...
@@ -139,6 +140,7 @@ class TestAccountAPI(UserAPITestCase):
self
.
assertEqual
(
self
.
user
.
email
,
data
[
"email"
])
self
.
assertEqual
(
self
.
user
.
email
,
data
[
"email"
])
self
.
assertTrue
(
data
[
"is_active"
])
self
.
assertTrue
(
data
[
"is_active"
])
self
.
assertIsNotNone
(
data
[
"date_joined"
])
self
.
assertIsNotNone
(
data
[
"date_joined"
])
self
.
assertEqual
(
"Tired mother of twins"
,
data
[
"bio"
])
def
test_anonymous_access
(
self
):
def
test_anonymous_access
(
self
):
"""
"""
...
@@ -243,7 +245,7 @@ class TestAccountAPI(UserAPITestCase):
...
@@ -243,7 +245,7 @@ class TestAccountAPI(UserAPITestCase):
self
.
assertEqual
(
12
,
len
(
data
))
self
.
assertEqual
(
12
,
len
(
data
))
self
.
assertEqual
(
self
.
user
.
username
,
data
[
"username"
])
self
.
assertEqual
(
self
.
user
.
username
,
data
[
"username"
])
self
.
assertEqual
(
self
.
user
.
first_name
+
" "
+
self
.
user
.
last_name
,
data
[
"name"
])
self
.
assertEqual
(
self
.
user
.
first_name
+
" "
+
self
.
user
.
last_name
,
data
[
"name"
])
for
empty_field
in
(
"year_of_birth"
,
"level_of_education"
,
"mailing_address"
):
for
empty_field
in
(
"year_of_birth"
,
"level_of_education"
,
"mailing_address"
,
"bio"
):
self
.
assertIsNone
(
data
[
empty_field
])
self
.
assertIsNone
(
data
[
empty_field
])
self
.
assertIsNone
(
data
[
"country"
])
self
.
assertIsNone
(
data
[
"country"
])
# TODO: what should the format of this be?
# TODO: what should the format of this be?
...
@@ -316,6 +318,10 @@ class TestAccountAPI(UserAPITestCase):
...
@@ -316,6 +318,10 @@ class TestAccountAPI(UserAPITestCase):
(
"language"
,
"Creole"
),
(
"language"
,
"Creole"
),
(
"goals"
,
"Smell the roses"
),
(
"goals"
,
"Smell the roses"
),
(
"mailing_address"
,
"Sesame Street"
),
(
"mailing_address"
,
"Sesame Street"
),
(
"bio"
,
"Lacrosse-playing superhero"
),
(
"bio"
,
u"壓是進界推日不復女"
),
# Note that we store the raw data, so it is up to client to escape the HTML.
(
"bio"
,
"<html>fancy text</html>"
),
# Note that email is tested below, as it is not immediately updated.
# Note that email is tested below, as it is not immediately updated.
)
)
@ddt.unpack
@ddt.unpack
...
...
openedx/core/djangoapps/user_api/accounts/views.py
View file @
fad63938
...
@@ -38,12 +38,13 @@ class AccountView(APIView):
...
@@ -38,12 +38,13 @@ class AccountView(APIView):
* name: The full name of the user.
* name: The full name of the user.
* email: The confirmed email address for the user. The request
* email: email for the user (the new email address must be
will not return an unconfirmed email address.
confirmed via a confirmation email, so GET will not reflect
the change until the address has been confirmed).
* date_joined: The date the account was created, in
* date_joined: The date the account was created, in
the string
the string format provided by datetime (for example,
format provided by datetime.
"2014-08-26T17:52:11Z")
.
For example, "2014-08-26T17:52:11Z"
.
* gender: One of the fullowing values:
* gender: One of the fullowing values:
...
@@ -77,6 +78,14 @@ class AccountView(APIView):
...
@@ -77,6 +78,14 @@ class AccountView(APIView):
* goals: The textual representation of the user's goals, or null.
* goals: The textual representation of the user's goals, or null.
* bio: null or textural representation of user biographical
information ("about me")
For all text fields, clients rendering the values should take care
to HTML escape them to avoid script injections, as the data is
stored exactly as specified. The intention is that plain text is
supported, not HTML.
If a user who does not have "is_staff" access requests account
If a user who does not have "is_staff" access requests account
information for a different user, only a subset of these fields is
information for a different user, only a subset of these fields is
returned. The fields returned depend on the configuration setting
returned. The fields returned depend on the configuration setting
...
...
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