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
625b859c
Commit
625b859c
authored
Nov 06, 2015
by
Cliff Dyer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10491 from edx/mobile/profile-default-privacy
Mobile/profile default privacy MA-1580
parents
e068765d
00b3051b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
18 deletions
+26
-18
lms/djangoapps/teams/tests/test_serializers.py
+1
-1
lms/djangoapps/teams/tests/test_views.py
+1
-1
openedx/core/djangoapps/user_api/accounts/serializers.py
+5
-5
openedx/core/djangoapps/user_api/accounts/tests/test_api.py
+3
-3
openedx/core/djangoapps/user_api/accounts/tests/test_views.py
+16
-8
No files found.
lms/djangoapps/teams/tests/test_serializers.py
View file @
625b859c
...
...
@@ -66,7 +66,7 @@ class MembershipSerializerTestCase(SerializerTestCase):
'image_url_small'
:
'http://testserver/static/default_30.png'
,
'has_image'
:
False
},
'account_privacy'
:
None
'account_privacy'
:
'private'
})
self
.
assertNotIn
(
'membership'
,
data
[
'team'
])
...
...
lms/djangoapps/teams/tests/test_views.py
View file @
625b859c
...
...
@@ -129,7 +129,7 @@ class TestDashboard(SharedModuleStoreTestCase):
team
.
add_user
(
self
.
user
)
# Check the query count on the dashboard again
with
self
.
assertNumQueries
(
20
):
with
self
.
assertNumQueries
(
19
):
self
.
client
.
get
(
self
.
teams_url
)
def
test_bad_course_id
(
self
):
...
...
openedx/core/djangoapps/user_api/accounts/serializers.py
View file @
625b859c
...
...
@@ -91,7 +91,7 @@ class UserReadOnlySerializer(serializers.Serializer):
"level_of_education"
:
AccountLegacyProfileSerializer
.
convert_empty_to_None
(
profile
.
level_of_education
),
"mailing_address"
:
profile
.
mailing_address
,
"requires_parental_consent"
:
profile
.
requires_parental_consent
(),
"account_privacy"
:
UserPreference
.
get_value
(
user
,
'account_privacy'
),
"account_privacy"
:
self
.
_get_profile_visibility
(
profile
,
user
),
}
return
self
.
_filter_fields
(
...
...
@@ -185,19 +185,19 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer, Rea
raise
serializers
.
ValidationError
(
"The language_proficiencies field must consist of unique languages"
)
return
value
def
transform_gender
(
self
,
user_profile
,
value
):
def
transform_gender
(
self
,
user_profile
,
value
):
# pylint: disable=unused-argument
""" Converts empty string to None, to indicate not set. Replaced by to_representation in version 3. """
return
AccountLegacyProfileSerializer
.
convert_empty_to_None
(
value
)
def
transform_country
(
self
,
user_profile
,
value
):
def
transform_country
(
self
,
user_profile
,
value
):
# pylint: disable=unused-argument
""" Converts empty string to None, to indicate not set. Replaced by to_representation in version 3. """
return
AccountLegacyProfileSerializer
.
convert_empty_to_None
(
value
)
def
transform_level_of_education
(
self
,
user_profile
,
value
):
def
transform_level_of_education
(
self
,
user_profile
,
value
):
# pylint: disable=unused-argument
""" Converts empty string to None, to indicate not set. Replaced by to_representation in version 3. """
return
AccountLegacyProfileSerializer
.
convert_empty_to_None
(
value
)
def
transform_bio
(
self
,
user_profile
,
value
):
def
transform_bio
(
self
,
user_profile
,
value
):
# pylint: disable=unused-argument
""" Converts empty string to None, to indicate not set. Replaced by to_representation in version 3. """
return
AccountLegacyProfileSerializer
.
convert_empty_to_None
(
value
)
...
...
openedx/core/djangoapps/user_api/accounts/tests/test_api.py
View file @
625b859c
...
...
@@ -25,7 +25,7 @@ from ...errors import (
from
..api
import
(
get_account_settings
,
update_account_settings
,
create_account
,
activate_account
,
request_password_change
)
from
..
import
USERNAME_MAX_LENGTH
,
EMAIL_MAX_LENGTH
,
PASSWORD_MAX_LENGTH
from
..
import
USERNAME_MAX_LENGTH
,
EMAIL_MAX_LENGTH
,
PASSWORD_MAX_LENGTH
,
PRIVATE_VISIBILITY
def
mock_render_to_string
(
template_name
,
context
):
...
...
@@ -278,7 +278,7 @@ class AccountSettingsOnCreationTest(TestCase):
},
'requires_parental_consent'
:
True
,
'language_proficiencies'
:
[],
'account_privacy'
:
None
'account_privacy'
:
PRIVATE_VISIBILITY
,
})
...
...
@@ -404,7 +404,7 @@ class AccountCreationActivationAndPasswordChangeTest(TestCase):
# Verify that the body of the message contains something that looks
# like an activation link
email_body
=
mail
.
outbox
[
0
]
.
body
result
=
re
.
search
(
'(?P<url>https?://[^
\
s]+)'
,
email_body
)
result
=
re
.
search
(
r
'(?P<url>https?://[^\s]+)'
,
email_body
)
self
.
assertIsNot
(
result
,
None
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in LMS'
)
...
...
openedx/core/djangoapps/user_api/accounts/tests/test_views.py
View file @
625b859c
...
...
@@ -241,7 +241,7 @@ class TestAccountAPI(UserAPITestCase):
self
.
create_mock_profile
(
self
.
user
)
with
self
.
assertNumQueries
(
9
):
response
=
self
.
send_get
(
self
.
different_client
)
self
.
_verify_full_shareable_account_response
(
response
)
self
.
_verify_full_shareable_account_response
(
response
,
account_privacy
=
ALL_USERS_VISIBILITY
)
# Note: using getattr so that the patching works even if there is no configuration.
# This is needed when testing CMS as the patching is still executed even though the
...
...
@@ -256,7 +256,7 @@ class TestAccountAPI(UserAPITestCase):
self
.
create_mock_profile
(
self
.
user
)
with
self
.
assertNumQueries
(
9
):
response
=
self
.
send_get
(
self
.
different_client
)
self
.
_verify_private_account_response
(
response
)
self
.
_verify_private_account_response
(
response
,
account_privacy
=
PRIVATE_VISIBILITY
)
@ddt.data
(
(
"client"
,
"user"
,
PRIVATE_VISIBILITY
),
...
...
@@ -305,7 +305,7 @@ class TestAccountAPI(UserAPITestCase):
"""
Internal helper to perform the actual assertions
"""
with
self
.
assertNumQueries
(
8
):
with
self
.
assertNumQueries
(
7
):
response
=
self
.
send_get
(
self
.
client
)
data
=
response
.
data
self
.
assertEqual
(
16
,
len
(
data
))
...
...
@@ -322,7 +322,7 @@ class TestAccountAPI(UserAPITestCase):
self
.
_verify_profile_image_data
(
data
,
False
)
self
.
assertTrue
(
data
[
"requires_parental_consent"
])
self
.
assertEqual
([],
data
[
"language_proficiencies"
])
self
.
assertEqual
(
None
,
data
[
"account_privacy"
])
self
.
assertEqual
(
PRIVATE_VISIBILITY
,
data
[
"account_privacy"
])
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
self
.
test_password
)
verify_get_own_information
()
...
...
@@ -344,7 +344,7 @@ class TestAccountAPI(UserAPITestCase):
legacy_profile
.
save
()
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
self
.
test_password
)
with
self
.
assertNumQueries
(
8
):
with
self
.
assertNumQueries
(
7
):
response
=
self
.
send_get
(
self
.
client
)
for
empty_field
in
(
"level_of_education"
,
"gender"
,
"country"
,
"bio"
):
self
.
assertIsNone
(
response
.
data
[
empty_field
])
...
...
@@ -403,6 +403,14 @@ class TestAccountAPI(UserAPITestCase):
Test the behavior of patch, when using the correct content_type.
"""
client
=
self
.
login_client
(
"client"
,
"user"
)
if
field
==
'account_privacy'
:
# Ensure the user has birth year set, and is over 13, so
# account_privacy behaves normally
legacy_profile
=
UserProfile
.
objects
.
get
(
id
=
self
.
user
.
id
)
legacy_profile
.
year_of_birth
=
2000
legacy_profile
.
save
()
response
=
self
.
send_patch
(
client
,
{
field
:
value
})
self
.
assertEqual
(
value
,
response
.
data
[
field
])
...
...
@@ -687,16 +695,16 @@ class TestAccountAPI(UserAPITestCase):
self
.
assertIsNotNone
(
data
[
"date_joined"
])
self
.
_verify_profile_image_data
(
data
,
False
)
self
.
assertTrue
(
data
[
"requires_parental_consent"
])
self
.
assertEqual
(
ALL_USERS
_VISIBILITY
,
data
[
"account_privacy"
])
self
.
assertEqual
(
PRIVATE
_VISIBILITY
,
data
[
"account_privacy"
])
else
:
self
.
_verify_private_account_response
(
response
,
requires_parental_consent
=
True
,
account_privacy
=
ALL_USERS
_VISIBILITY
response
,
requires_parental_consent
=
True
,
account_privacy
=
PRIVATE
_VISIBILITY
)
# Verify that the shared view is still private
response
=
self
.
send_get
(
client
,
query_parameters
=
'view=shared'
)
self
.
_verify_private_account_response
(
response
,
requires_parental_consent
=
True
,
account_privacy
=
ALL_USERS
_VISIBILITY
response
,
requires_parental_consent
=
True
,
account_privacy
=
PRIVATE
_VISIBILITY
)
...
...
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