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
5d363df5
Commit
5d363df5
authored
Jun 23, 2017
by
Jesse Shapiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow lower- and mixed-case country default values
parent
4622b24a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
openedx/core/djangoapps/user_api/tests/test_views.py
+12
-4
openedx/core/djangoapps/user_api/views.py
+8
-0
No files found.
openedx/core/djangoapps/user_api/tests/test_views.py
View file @
5d363df5
...
...
@@ -935,7 +935,15 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
}
)
def
test_register_form_third_party_auth_running_google
(
self
):
@ddt.data
(
(
'pk'
,
'PK'
),
(
'Pk'
,
'PK'
),
(
'pK'
,
'PK'
),
(
'PK'
,
'PK'
),
(
'us'
,
'US'
),
)
@ddt.unpack
def
test_register_form_third_party_auth_running_google
(
self
,
input_country_code
,
expected_country_code
):
no_extra_fields_setting
=
{}
country_options
=
(
[
...
...
@@ -948,7 +956,7 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
{
"value"
:
country_code
,
"name"
:
unicode
(
country_name
),
"default"
:
True
if
country_code
==
"PK"
else
False
"default"
:
True
if
country_code
==
expected_country_code
else
False
}
for
country_code
,
country_name
in
SORTED_COUNTRIES
]
...
...
@@ -960,7 +968,7 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
email
=
"bob@example.com"
,
fullname
=
"Bob"
,
username
=
"Bob123"
,
country
=
"PK"
country
=
input_country_code
):
self
.
_assert_password_field_hidden
(
no_extra_fields_setting
)
self
.
_assert_social_auth_provider_present
(
no_extra_fields_setting
,
provider
)
...
...
@@ -1025,7 +1033,7 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
{
u"label"
:
u"Country"
,
u"name"
:
u"country"
,
u"defaultValue"
:
u"PK"
,
u"defaultValue"
:
expected_country_code
,
u"type"
:
u"select"
,
u"required"
:
True
,
u"options"
:
country_options
,
...
...
openedx/core/djangoapps/user_api/views.py
View file @
5d363df5
...
...
@@ -787,6 +787,14 @@ class RegistrationView(APIView):
country_label
=
_
(
u"Country"
)
error_msg
=
_
(
u"Please select your Country."
)
# If we set a country code, make sure it's uppercase for the sake of the form.
default_country
=
form_desc
.
_field_overrides
.
get
(
'country'
,
{})
.
get
(
'defaultValue'
)
if
default_country
:
form_desc
.
override_field_properties
(
'country'
,
default
=
default_country
.
upper
()
)
form_desc
.
add_field
(
"country"
,
label
=
country_label
,
...
...
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