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
c7519148
Unverified
Commit
c7519148
authored
Nov 29, 2017
by
Diana Huang
Committed by
GitHub
Nov 29, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16520 from edx/diana/logistration-updates
LEARNER-2813: Hide optional fields.
parents
1602a0e6
8693f2fd
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
229 additions
and
49 deletions
+229
-49
common/test/acceptance/pages/lms/login_and_register.py
+3
-1
lms/static/js/spec/student_account/register_spec.js
+13
-0
lms/static/js/student_account/views/FormView.js
+1
-1
lms/static/js/student_account/views/RegisterView.js
+150
-0
lms/static/sass/views/_login-register.scss
+20
-0
lms/templates/student_account/form_field.underscore
+1
-1
lms/templates/student_account/register.underscore
+10
-2
openedx/core/djangoapps/user_api/api.py
+14
-27
openedx/core/djangoapps/user_api/tests/test_views.py
+17
-17
No files found.
common/test/acceptance/pages/lms/login_and_register.py
View file @
c7519148
...
@@ -208,7 +208,7 @@ class CombinedLoginAndRegisterPage(PageObject):
...
@@ -208,7 +208,7 @@ class CombinedLoginAndRegisterPage(PageObject):
"""
"""
# Fill in the form
# Fill in the form
self
.
wait_for_element_visibility
(
'#register-
email'
,
'Email
field is shown'
)
self
.
wait_for_element_visibility
(
'#register-
honor_code'
,
'Honor code
field is shown'
)
if
email
:
if
email
:
self
.
q
(
css
=
"#register-email"
)
.
fill
(
email
)
self
.
q
(
css
=
"#register-email"
)
.
fill
(
email
)
if
full_name
:
if
full_name
:
...
@@ -223,6 +223,8 @@ class CombinedLoginAndRegisterPage(PageObject):
...
@@ -223,6 +223,8 @@ class CombinedLoginAndRegisterPage(PageObject):
self
.
q
(
css
=
"#register-favorite_movie"
)
.
fill
(
favorite_movie
)
self
.
q
(
css
=
"#register-favorite_movie"
)
.
fill
(
favorite_movie
)
if
terms_of_service
:
if
terms_of_service
:
self
.
q
(
css
=
"label[for='register-honor_code']"
)
.
click
()
self
.
q
(
css
=
"label[for='register-honor_code']"
)
.
click
()
self
.
q
(
css
=
"#register-honor_code"
)
.
click
()
EmptyPromise
(
lambda
:
self
.
q
(
css
=
'#register-honor_code:checked'
),
'Honor code field is checked'
)
.
fulfill
()
# Submit it
# Submit it
self
.
q
(
css
=
".register-button"
)
.
click
()
self
.
q
(
css
=
".register-button"
)
.
click
()
...
...
lms/static/js/spec/student_account/register_spec.js
View file @
c7519148
...
@@ -279,6 +279,8 @@
...
@@ -279,6 +279,8 @@
// Create a fake click event
// Create a fake click event
var
clickEvent
=
$
.
Event
(
'click'
);
var
clickEvent
=
$
.
Event
(
'click'
);
$
(
'#toggle_optional_fields'
).
click
();
// Simulate manual entry of registration form data
// Simulate manual entry of registration form data
fillData
();
fillData
();
...
@@ -481,6 +483,17 @@
...
@@ -481,6 +483,17 @@
expect
(
view
.
$submitButton
).
toHaveAttr
(
'disabled'
);
expect
(
view
.
$submitButton
).
toHaveAttr
(
'disabled'
);
});
});
it
(
'hides optional fields by default'
,
function
()
{
createRegisterView
(
this
);
expect
(
view
.
$
(
'.optional-fields'
)).
toHaveClass
(
'hidden'
);
});
it
(
'displays optional fields when checkbox is selected'
,
function
()
{
createRegisterView
(
this
);
$
(
'#toggle_optional_fields'
).
click
();
expect
(
view
.
$
(
'.optional-fields'
)).
not
.
toHaveClass
(
'hidden'
);
});
it
(
'displays a modal with the terms of service'
,
function
()
{
it
(
'displays a modal with the terms of service'
,
function
()
{
var
$modal
,
var
$modal
,
$content
;
$content
;
...
...
lms/static/js/student_account/views/FormView.js
View file @
c7519148
...
@@ -84,7 +84,7 @@
...
@@ -84,7 +84,7 @@
data
[
i
].
errorMessages
=
this
.
escapeStrings
(
data
[
i
].
errorMessages
);
data
[
i
].
errorMessages
=
this
.
escapeStrings
(
data
[
i
].
errorMessages
);
}
}
html
.
push
(
_
.
template
(
fieldTpl
)(
$
.
extend
(
data
[
i
],
{
html
.
push
(
HtmlUtils
.
template
(
fieldTpl
)(
$
.
extend
(
data
[
i
],
{
form
:
this
.
formType
,
form
:
this
.
formType
,
requiredStr
:
this
.
requiredStr
,
requiredStr
:
this
.
requiredStr
,
optionalStr
:
this
.
optionalStr
,
optionalStr
:
this
.
optionalStr
,
...
...
lms/static/js/student_account/views/RegisterView.js
View file @
c7519148
...
@@ -5,12 +5,14 @@
...
@@ -5,12 +5,14 @@
'underscore'
,
'underscore'
,
'gettext'
,
'gettext'
,
'edx-ui-toolkit/js/utils/string-utils'
,
'edx-ui-toolkit/js/utils/string-utils'
,
'edx-ui-toolkit/js/utils/html-utils'
,
'js/student_account/views/FormView'
,
'js/student_account/views/FormView'
,
'text!templates/student_account/form_status.underscore'
'text!templates/student_account/form_status.underscore'
],
],
function
(
function
(
$
,
_
,
gettext
,
$
,
_
,
gettext
,
StringUtils
,
StringUtils
,
HtmlUtils
,
FormView
,
FormView
,
formStatusTpl
formStatusTpl
)
{
)
{
...
@@ -65,6 +67,59 @@
...
@@ -65,6 +67,59 @@
this
.
listenTo
(
this
.
model
,
'validation'
,
this
.
renderLiveValidations
);
this
.
listenTo
(
this
.
model
,
'validation'
,
this
.
renderLiveValidations
);
},
},
renderFields
:
function
(
fields
,
className
)
{
var
html
=
[],
i
,
fieldTpl
=
this
.
fieldTpl
;
html
.
push
(
HtmlUtils
.
joinHtml
(
HtmlUtils
.
HTML
(
'<div class="'
),
className
,
HtmlUtils
.
HTML
(
'">'
)
));
for
(
i
=
0
;
i
<
fields
.
length
;
i
++
)
{
html
.
push
(
HtmlUtils
.
template
(
fieldTpl
)(
$
.
extend
(
fields
[
i
],
{
form
:
this
.
formType
,
requiredStr
:
this
.
requiredStr
,
optionalStr
:
this
.
optionalStr
,
supplementalText
:
fields
[
i
].
supplementalText
||
''
,
supplementalLink
:
fields
[
i
].
supplementalLink
||
''
})));
}
html
.
push
(
'</div>'
);
return
html
;
},
buildForm
:
function
(
data
)
{
var
html
=
[],
i
,
len
=
data
.
length
,
requiredFields
=
[],
optionalFields
=
[];
this
.
fields
=
data
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
data
[
i
].
errorMessages
)
{
// eslint-disable-next-line no-param-reassign
data
[
i
].
errorMessages
=
this
.
escapeStrings
(
data
[
i
].
errorMessages
);
}
if
(
data
[
i
].
required
)
{
requiredFields
.
push
(
data
[
i
]);
}
else
{
optionalFields
.
push
(
data
[
i
]);
}
}
html
=
this
.
renderFields
(
requiredFields
,
'required-fields'
);
html
.
push
.
apply
(
html
,
this
.
renderFields
(
optionalFields
,
'optional-fields'
));
this
.
render
(
html
.
join
(
''
));
},
render
:
function
(
html
)
{
render
:
function
(
html
)
{
var
fields
=
html
||
''
,
var
fields
=
html
||
''
,
formErrorsTitle
=
gettext
(
'An error occurred.'
);
formErrorsTitle
=
gettext
(
'An error occurred.'
);
...
@@ -102,6 +157,101 @@
...
@@ -102,6 +157,101 @@
return
this
;
return
this
;
},
},
postRender
:
function
()
{
var
inputs
=
[
this
.
$
(
'#register-name'
),
this
.
$
(
'#register-email'
),
this
.
$
(
'#register-username'
),
this
.
$
(
'#register-password'
),
this
.
$
(
'#register-country'
)
],
inputTipSelectors
=
[
'tip error'
,
'tip tip-input'
],
inputTipSelectorsHidden
=
[
'tip error hidden'
,
'tip tip-input hidden'
],
onInputFocus
=
function
()
{
// Apply on focus styles to input
$
(
this
).
prev
(
'label'
).
addClass
(
'focus-in'
)
.
removeClass
(
'focus-out'
);
// Show each input tip
$
(
this
).
siblings
().
each
(
function
()
{
if
(
inputTipSelectorsHidden
.
includes
(
$
(
this
).
attr
(
'class'
)))
{
$
(
this
).
removeClass
(
'hidden'
);
}
});
},
onInputFocusOut
=
function
()
{
// If input has no text apply focus out styles
if
(
$
(
this
).
val
().
length
===
0
)
{
$
(
this
).
prev
(
'label'
).
addClass
(
'focus-out'
)
.
removeClass
(
'focus-in'
);
}
// Hide each input tip
$
(
this
).
siblings
().
each
(
function
()
{
if
(
inputTipSelectors
.
includes
(
$
(
this
).
attr
(
'class'
)))
{
$
(
this
).
addClass
(
'hidden'
);
}
});
},
handleInputBehavior
=
function
(
input
)
{
// Initially put label in input
if
(
input
.
val
().
length
===
0
)
{
input
.
prev
(
'label'
).
addClass
(
'focus-out'
)
.
removeClass
(
'focus-in'
);
}
// Initially hide each input tip
input
.
siblings
().
each
(
function
()
{
if
(
inputTipSelectors
.
includes
(
$
(
this
).
attr
(
'class'
)))
{
$
(
this
).
addClass
(
'hidden'
);
}
});
input
.
focusin
(
onInputFocus
);
input
.
focusout
(
onInputFocusOut
);
},
handleAutocomplete
=
function
()
{
inputs
.
forEach
(
function
(
input
)
{
if
(
input
.
val
().
length
===
0
&&
!
input
.
is
(
':-webkit-autofill'
))
{
input
.
prev
(
'label'
).
addClass
(
'focus-out'
)
.
removeClass
(
'focus-in'
);
}
else
{
input
.
prev
(
'label'
).
addClass
(
'focus-in'
)
.
removeClass
(
'focus-out'
);
}
});
};
FormView
.
prototype
.
postRender
.
call
(
this
);
$
(
'.optional-fields'
).
addClass
(
'hidden'
);
$
(
'#toggle_optional_fields'
).
change
(
function
()
{
window
.
analytics
.
track
(
'edx.bi.user.register.optional_fields_selected'
);
$
(
'.optional-fields'
).
toggleClass
(
'hidden'
);
});
// We are swapping the order of these elements here because the honor code agreement
// is a required checkbox field and the optional fields toggle is a cosmetic
// improvement so that we don't have to show all the optional fields.
// xss-lint: disable=javascript-jquery-insert-into-target
$
(
'.checkbox-optional_fields_toggle'
).
insertBefore
(
'.optional-fields'
);
// xss-lint: disable=javascript-jquery-insert-into-target
$
(
'.checkbox-honor_code'
).
insertAfter
(
'.optional-fields'
);
// Clicking on links inside a label should open that link.
$
(
'label a'
).
click
(
function
(
ev
)
{
ev
.
stopPropagation
();
ev
.
preventDefault
();
window
.
open
(
$
(
this
).
attr
(
'href'
),
$
(
this
).
attr
(
'target'
));
});
$
(
'#register-country option:first'
).
html
(
''
);
inputs
.
forEach
(
function
(
input
)
{
if
(
input
.
length
>
0
)
{
handleInputBehavior
(
input
);
}
});
setTimeout
(
handleAutocomplete
,
1000
);
},
hideRequiredMessageExceptOnError
:
function
(
$el
)
{
hideRequiredMessageExceptOnError
:
function
(
$el
)
{
// We only handle blur if not in an error state.
// We only handle blur if not in an error state.
if
(
!
$el
.
hasClass
(
'error'
))
{
if
(
!
$el
.
hasClass
(
'error'
))
{
...
...
lms/static/sass/views/_login-register.scss
View file @
c7519148
...
@@ -292,6 +292,7 @@
...
@@ -292,6 +292,7 @@
width
:
100%
;
width
:
100%
;
margin
:
(
$baseline
/
2
)
0
0
0
;
margin
:
(
$baseline
/
2
)
0
0
0
;
&
.select-year_of_birth
{
&
.select-year_of_birth
{
@include
margin-left
(
15px
);
@include
margin-left
(
15px
);
}
}
...
@@ -313,6 +314,25 @@
...
@@ -313,6 +314,25 @@
font-family
:
$font-family-sans-serif
;
font-family
:
$font-family-sans-serif
;
font-style
:
normal
;
font-style
:
normal
;
font-weight
:
500
;
font-weight
:
500
;
&
.focus-in
{
position
:
relative
;
padding-top
:
0
;
padding-left
:
0
;
opacity
:
1
;
}
&
.focus-out
{
position
:
absolute
;
padding-top
:
5px
;
padding-left
:
9px
;
opacity
:
0
.75
;
z-index
:
1
;
}
a
{
z-index
:
1
;
}
}
}
#login-remember
{
#login-remember
{
...
...
lms/templates/student_account/form_field.underscore
View file @
c7519148
...
@@ -102,7 +102,7 @@
...
@@ -102,7 +102,7 @@
/>
/>
<% if ( type === 'checkbox' ) { %>
<% if ( type === 'checkbox' ) { %>
<label for="<%- form %>-<%- name %>">
<label for="<%- form %>-<%- name %>">
<span class="label-text"><%
- label
%></span>
<span class="label-text"><%
= HtmlUtils.HTML(label)
%></span>
<% if ( required && type !== 'hidden' ) { %>
<% if ( required && type !== 'hidden' ) { %>
<span id="<%- form %>-<%- name %>-required-label"
<span id="<%- form %>-<%- name %>-required-label"
class="label-required <% if ( !requiredStr ) { %>hidden<% } %>">
class="label-required <% if ( !requiredStr ) { %>hidden<% } %>">
...
...
lms/templates/student_account/register.underscore
View file @
c7519148
...
@@ -6,8 +6,6 @@
...
@@ -6,8 +6,6 @@
<a href="#login" class="form-toggle" data-type="login"><%- gettext("Sign in.") %></a>
<a href="#login" class="form-toggle" data-type="login"><%- gettext("Sign in.") %></a>
</div>
</div>
<h2><%- gettext('Create an Account')%></h2>
<form id="register" class="register-form" autocomplete="off" tabindex="-1" method="POST">
<form id="register" class="register-form" autocomplete="off" tabindex="-1" method="POST">
<% if (!context.currentProvider) { %>
<% if (!context.currentProvider) { %>
...
@@ -51,6 +49,16 @@
...
@@ -51,6 +49,16 @@
<%= context.fields %>
<%= context.fields %>
<div class="form-field checkbox-optional_fields_toggle">
<input type="checkbox" id="toggle_optional_fields" class="input-block checkbox"">
<label for="toggle_optional_fields">
<span class="label-text">
<%- gettext("Support education research by providing additional information") %>
</span>
</label>
</div>
<button type="submit" class="action action-primary action-update js-register register-button">
<button type="submit" class="action action-primary action-update js-register register-button">
<% if ( context.registerFormSubmitButtonText ) { %><%- context.registerFormSubmitButtonText %><% } else { %><%- gettext("Create Account") %><% } %>
<% if ( context.registerFormSubmitButtonText ) { %><%- context.registerFormSubmitButtonText %><% } else { %><%- gettext("Create Account") %><% } %>
</button>
</button>
...
...
openedx/core/djangoapps/user_api/api.py
View file @
c7519148
...
@@ -9,6 +9,7 @@ from django_countries import countries
...
@@ -9,6 +9,7 @@ from django_countries import countries
import
accounts
import
accounts
import
third_party_auth
import
third_party_auth
from
edxmako.shortcuts
import
marketing_link
from
edxmako.shortcuts
import
marketing_link
from
openedx.core.djangolib.markup
import
HTML
,
Text
from
openedx.core.djangoapps.site_configuration
import
helpers
as
configuration_helpers
from
openedx.core.djangoapps.site_configuration
import
helpers
as
configuration_helpers
from
openedx.core.djangoapps.user_api.helpers
import
FormDescription
from
openedx.core.djangoapps.user_api.helpers
import
FormDescription
from
openedx.features.enterprise_support.api
import
enterprise_customer_for_request
from
openedx.features.enterprise_support.api
import
enterprise_customer_for_request
...
@@ -277,10 +278,6 @@ class RegistrationFormFactory(object):
...
@@ -277,10 +278,6 @@ class RegistrationFormFactory(object):
# meant to hold the user's email address.
# meant to hold the user's email address.
email_label
=
_
(
u"Email"
)
email_label
=
_
(
u"Email"
)
# Translators: This example email address is used as a placeholder in
# a field on the registration form meant to hold the user's email address.
email_placeholder
=
_
(
u"username@domain.com"
)
# Translators: These instructions appear on the registration form, immediately
# Translators: These instructions appear on the registration form, immediately
# below a field meant to hold the user's email address.
# below a field meant to hold the user's email address.
email_instructions
=
_
(
u"This is what you will use to login."
)
email_instructions
=
_
(
u"This is what you will use to login."
)
...
@@ -289,7 +286,6 @@ class RegistrationFormFactory(object):
...
@@ -289,7 +286,6 @@ class RegistrationFormFactory(object):
"email"
,
"email"
,
field_type
=
"email"
,
field_type
=
"email"
,
label
=
email_label
,
label
=
email_label
,
placeholder
=
email_placeholder
,
instructions
=
email_instructions
,
instructions
=
email_instructions
,
restrictions
=
{
restrictions
=
{
"min_length"
:
accounts
.
EMAIL_MIN_LENGTH
,
"min_length"
:
accounts
.
EMAIL_MIN_LENGTH
,
...
@@ -308,6 +304,7 @@ class RegistrationFormFactory(object):
...
@@ -308,6 +304,7 @@ class RegistrationFormFactory(object):
# Translators: This label appears above a field on the registration form
# Translators: This label appears above a field on the registration form
# meant to confirm the user's email address.
# meant to confirm the user's email address.
email_label
=
_
(
u"Confirm Email"
)
email_label
=
_
(
u"Confirm Email"
)
error_msg
=
accounts
.
REQUIRED_FIELD_CONFIRM_EMAIL_MSG
error_msg
=
accounts
.
REQUIRED_FIELD_CONFIRM_EMAIL_MSG
form_desc
.
add_field
(
form_desc
.
add_field
(
...
@@ -330,10 +327,6 @@ class RegistrationFormFactory(object):
...
@@ -330,10 +327,6 @@ class RegistrationFormFactory(object):
# meant to hold the user's full name.
# meant to hold the user's full name.
name_label
=
_
(
u"Full Name"
)
name_label
=
_
(
u"Full Name"
)
# Translators: This example name is used as a placeholder in
# a field on the registration form meant to hold the user's name.
name_placeholder
=
_
(
u"Jane Q. Learner"
)
# Translators: These instructions appear on the registration form, immediately
# Translators: These instructions appear on the registration form, immediately
# below a field meant to hold the user's full name.
# below a field meant to hold the user's full name.
name_instructions
=
_
(
u"This name will be used on any certificates that you earn."
)
name_instructions
=
_
(
u"This name will be used on any certificates that you earn."
)
...
@@ -341,7 +334,6 @@ class RegistrationFormFactory(object):
...
@@ -341,7 +334,6 @@ class RegistrationFormFactory(object):
form_desc
.
add_field
(
form_desc
.
add_field
(
"name"
,
"name"
,
label
=
name_label
,
label
=
name_label
,
placeholder
=
name_placeholder
,
instructions
=
name_instructions
,
instructions
=
name_instructions
,
restrictions
=
{
restrictions
=
{
"max_length"
:
accounts
.
NAME_MAX_LENGTH
,
"max_length"
:
accounts
.
NAME_MAX_LENGTH
,
...
@@ -366,16 +358,10 @@ class RegistrationFormFactory(object):
...
@@ -366,16 +358,10 @@ class RegistrationFormFactory(object):
u"The name that will identify you in your courses. "
u"The name that will identify you in your courses. "
u"It cannot be changed later."
u"It cannot be changed later."
)
)
# Translators: This example username is used as a placeholder in
# a field on the registration form meant to hold the user's username.
username_placeholder
=
_
(
u"Jane_Q_Learner"
)
form_desc
.
add_field
(
form_desc
.
add_field
(
"username"
,
"username"
,
label
=
username_label
,
label
=
username_label
,
instructions
=
username_instructions
,
instructions
=
username_instructions
,
placeholder
=
username_placeholder
,
restrictions
=
{
restrictions
=
{
"min_length"
:
accounts
.
USERNAME_MIN_LENGTH
,
"min_length"
:
accounts
.
USERNAME_MIN_LENGTH
,
"max_length"
:
accounts
.
USERNAME_MAX_LENGTH
,
"max_length"
:
accounts
.
USERNAME_MAX_LENGTH
,
...
@@ -711,16 +697,17 @@ class RegistrationFormFactory(object):
...
@@ -711,16 +697,17 @@ class RegistrationFormFactory(object):
# form used to select the country in which the user lives.
# form used to select the country in which the user lives.
country_label
=
_
(
u"Country or Region of Residence"
)
country_label
=
_
(
u"Country or Region of Residence"
)
error_msg
=
accounts
.
REQUIRED_FIELD_COUNTRY_MSG
# If we set a country code, make sure it's uppercase for the sake of the form.
# pylint: disable=protected-access
default_country
=
form_desc
.
_field_overrides
.
get
(
'country'
,
{})
.
get
(
'defaultValue'
)
country_instructions
=
_
(
country_instructions
=
_
(
# Translators: These instructions appear on the registration form, immediately
# Translators: These instructions appear on the registration form, immediately
# below a field meant to hold the user's country.
# below a field meant to hold the user's country.
u"The country or region where you live."
u"The country or region where you live."
)
)
error_msg
=
accounts
.
REQUIRED_FIELD_COUNTRY_MSG
# 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
:
if
default_country
:
form_desc
.
override_field_properties
(
form_desc
.
override_field_properties
(
'country'
,
'country'
,
...
@@ -751,7 +738,6 @@ class RegistrationFormFactory(object):
...
@@ -751,7 +738,6 @@ class RegistrationFormFactory(object):
if
self
.
_is_field_visible
(
"terms_of_service"
):
if
self
.
_is_field_visible
(
"terms_of_service"
):
terms_label
=
_
(
u"Honor Code"
)
terms_label
=
_
(
u"Honor Code"
)
terms_link
=
marketing_link
(
"HONOR"
)
terms_link
=
marketing_link
(
"HONOR"
)
terms_text
=
_
(
u"Review the Honor Code"
)
# Combine terms of service and honor code checkboxes
# Combine terms of service and honor code checkboxes
else
:
else
:
...
@@ -759,13 +745,16 @@ class RegistrationFormFactory(object):
...
@@ -759,13 +745,16 @@ class RegistrationFormFactory(object):
# in order to register a new account.
# in order to register a new account.
terms_label
=
_
(
u"Terms of Service and Honor Code"
)
terms_label
=
_
(
u"Terms of Service and Honor Code"
)
terms_link
=
marketing_link
(
"HONOR"
)
terms_link
=
marketing_link
(
"HONOR"
)
terms_text
=
_
(
u"Review the Terms of Service and Honor Code"
)
# Translators: "Terms of Service" is a legal document users must agree to
# Translators: "Terms of Service" is a legal document users must agree to
# in order to register a new account.
# in order to register a new account.
label
=
_
(
u"I agree to the {platform_name} {terms_of_service}"
)
.
format
(
label
=
Text
(
_
(
u"I agree to the {platform_name} {terms_of_service_link_start}{terms_of_service}{terms_of_service_link_end}"
))
.
format
(
platform_name
=
configuration_helpers
.
get_value
(
"PLATFORM_NAME"
,
settings
.
PLATFORM_NAME
),
platform_name
=
configuration_helpers
.
get_value
(
"PLATFORM_NAME"
,
settings
.
PLATFORM_NAME
),
terms_of_service
=
terms_label
terms_of_service
=
terms_label
,
terms_of_service_link_start
=
HTML
(
"<a href='{terms_link}' target='_blank'>"
)
.
format
(
terms_link
=
terms_link
),
terms_of_service_link_end
=
HTML
(
"</a>"
),
)
)
# Translators: "Terms of Service" is a legal document users must agree to
# Translators: "Terms of Service" is a legal document users must agree to
...
@@ -784,8 +773,6 @@ class RegistrationFormFactory(object):
...
@@ -784,8 +773,6 @@ class RegistrationFormFactory(object):
error_messages
=
{
error_messages
=
{
"required"
:
error_msg
"required"
:
error_msg
},
},
supplementalLink
=
terms_link
,
supplementalText
=
terms_text
)
)
def
_add_terms_of_service_field
(
self
,
form_desc
,
required
=
True
):
def
_add_terms_of_service_field
(
self
,
form_desc
,
required
=
True
):
...
...
openedx/core/djangoapps/user_api/tests/test_views.py
View file @
c7519148
...
@@ -972,6 +972,7 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -972,6 +972,7 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
"default"
:
False
"default"
:
False
}
}
]
]
link_template
=
"<a href='/honor' target='_blank'>{link_label}</a>"
def
setUp
(
self
):
def
setUp
(
self
):
super
(
RegistrationViewTest
,
self
)
.
setUp
()
super
(
RegistrationViewTest
,
self
)
.
setUp
()
...
@@ -1006,7 +1007,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1006,7 +1007,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
u"type"
:
u"email"
,
u"type"
:
u"email"
,
u"required"
:
True
,
u"required"
:
True
,
u"label"
:
u"Email"
,
u"label"
:
u"Email"
,
u"placeholder"
:
u"username@domain.com"
,
u"instructions"
:
u"This is what you will use to login."
,
u"instructions"
:
u"This is what you will use to login."
,
u"restrictions"
:
{
u"restrictions"
:
{
"min_length"
:
EMAIL_MIN_LENGTH
,
"min_length"
:
EMAIL_MIN_LENGTH
,
...
@@ -1022,7 +1022,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1022,7 +1022,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
u"type"
:
u"text"
,
u"type"
:
u"text"
,
u"required"
:
True
,
u"required"
:
True
,
u"label"
:
u"Full Name"
,
u"label"
:
u"Full Name"
,
u"placeholder"
:
u"Jane Q. Learner"
,
u"instructions"
:
u"This name will be used on any certificates that you earn."
,
u"instructions"
:
u"This name will be used on any certificates that you earn."
,
u"restrictions"
:
{
u"restrictions"
:
{
"max_length"
:
255
"max_length"
:
255
...
@@ -1037,7 +1036,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1037,7 +1036,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
u"type"
:
u"text"
,
u"type"
:
u"text"
,
u"required"
:
True
,
u"required"
:
True
,
u"label"
:
u"Public Username"
,
u"label"
:
u"Public Username"
,
u"placeholder"
:
u"Jane_Q_Learner"
,
u"instructions"
:
u"The name that will identify you in your courses. "
u"instructions"
:
u"The name that will identify you in your courses. "
u"It cannot be changed later."
,
u"It cannot be changed later."
,
u"restrictions"
:
{
u"restrictions"
:
{
...
@@ -1074,7 +1072,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1074,7 +1072,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
u"type"
:
u"email"
,
u"type"
:
u"email"
,
u"required"
:
True
,
u"required"
:
True
,
u"label"
:
u"Email"
,
u"label"
:
u"Email"
,
u"placeholder"
:
u"username@domain.com"
,
u"instructions"
:
u"This is what you will use to login."
,
u"instructions"
:
u"This is what you will use to login."
,
u"restrictions"
:
{
u"restrictions"
:
{
"min_length"
:
EMAIL_MIN_LENGTH
,
"min_length"
:
EMAIL_MIN_LENGTH
,
...
@@ -1171,7 +1168,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1171,7 +1168,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
u"type"
:
u"email"
,
u"type"
:
u"email"
,
u"required"
:
True
,
u"required"
:
True
,
u"label"
:
u"Email"
,
u"label"
:
u"Email"
,
u"placeholder"
:
u"username@domain.com"
,
u"instructions"
:
u"This is what you will use to login."
,
u"instructions"
:
u"This is what you will use to login."
,
u"restrictions"
:
{
u"restrictions"
:
{
"min_length"
:
EMAIL_MIN_LENGTH
,
"min_length"
:
EMAIL_MIN_LENGTH
,
...
@@ -1189,7 +1185,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1189,7 +1185,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
u"type"
:
u"text"
,
u"type"
:
u"text"
,
u"required"
:
True
,
u"required"
:
True
,
u"label"
:
u"Full Name"
,
u"label"
:
u"Full Name"
,
u"placeholder"
:
u"Jane Q. Learner"
,
u"instructions"
:
u"This name will be used on any certificates that you earn."
,
u"instructions"
:
u"This name will be used on any certificates that you earn."
,
u"restrictions"
:
{
u"restrictions"
:
{
"max_length"
:
NAME_MAX_LENGTH
,
"max_length"
:
NAME_MAX_LENGTH
,
...
@@ -1206,7 +1201,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1206,7 +1201,6 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
u"type"
:
u"text"
,
u"type"
:
u"text"
,
u"required"
:
True
,
u"required"
:
True
,
u"label"
:
u"Public Username"
,
u"label"
:
u"Public Username"
,
u"placeholder"
:
u"Jane_Q_Learner"
,
u"instructions"
:
u"The name that will identify you in your courses. "
u"instructions"
:
u"The name that will identify you in your courses. "
u"It cannot be changed later."
,
u"It cannot be changed later."
,
u"restrictions"
:
{
u"restrictions"
:
{
...
@@ -1520,13 +1514,14 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1520,13 +1514,14 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
)
)
@mock.patch.dict
(
settings
.
FEATURES
,
{
"ENABLE_MKTG_SITE"
:
True
})
@mock.patch.dict
(
settings
.
FEATURES
,
{
"ENABLE_MKTG_SITE"
:
True
})
def
test_registration_honor_code_mktg_site_enabled
(
self
):
def
test_registration_honor_code_mktg_site_enabled
(
self
):
link_label
=
'Terms of Service and Honor Code'
link_template
=
"<a href='https://www.test.com/honor' target='_blank'>{link_label}</a>"
link_label
=
"Terms of Service and Honor Code"
self
.
_assert_reg_field
(
self
.
_assert_reg_field
(
{
"honor_code"
:
"required"
},
{
"honor_code"
:
"required"
},
{
{
"label"
:
u"I agree to the {platform_name} {link_label}"
.
format
(
"label"
:
u"I agree to the {platform_name} {link_label}"
.
format
(
platform_name
=
settings
.
PLATFORM_NAME
,
platform_name
=
settings
.
PLATFORM_NAME
,
link_label
=
link_
label
link_label
=
link_
template
.
format
(
link_label
=
link_label
)
),
),
"name"
:
"honor_code"
,
"name"
:
"honor_code"
,
"defaultValue"
:
False
,
"defaultValue"
:
False
,
...
@@ -1544,13 +1539,13 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1544,13 +1539,13 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
@override_settings
(
MKTG_URLS_LINK_MAP
=
{
"HONOR"
:
"honor"
})
@override_settings
(
MKTG_URLS_LINK_MAP
=
{
"HONOR"
:
"honor"
})
@mock.patch.dict
(
settings
.
FEATURES
,
{
"ENABLE_MKTG_SITE"
:
False
})
@mock.patch.dict
(
settings
.
FEATURES
,
{
"ENABLE_MKTG_SITE"
:
False
})
def
test_registration_honor_code_mktg_site_disabled
(
self
):
def
test_registration_honor_code_mktg_site_disabled
(
self
):
link_label
=
'Terms of Service and Honor Code'
link_label
=
"Terms of Service and Honor Code"
self
.
_assert_reg_field
(
self
.
_assert_reg_field
(
{
"honor_code"
:
"required"
},
{
"honor_code"
:
"required"
},
{
{
"label"
:
u"I agree to the {platform_name} {link_label}"
.
format
(
"label"
:
u"I agree to the {platform_name} {link_label}"
.
format
(
platform_name
=
settings
.
PLATFORM_NAME
,
platform_name
=
settings
.
PLATFORM_NAME
,
link_label
=
link_label
link_label
=
self
.
link_template
.
format
(
link_label
=
link_label
)
),
),
"name"
:
"honor_code"
,
"name"
:
"honor_code"
,
"defaultValue"
:
False
,
"defaultValue"
:
False
,
...
@@ -1575,12 +1570,13 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1575,12 +1570,13 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
# Honor code field should say ONLY honor code,
# Honor code field should say ONLY honor code,
# not "terms of service and honor code"
# not "terms of service and honor code"
link_label
=
'Honor Code'
link_label
=
'Honor Code'
link_template
=
"<a href='https://www.test.com/honor' target='_blank'>{link_label}</a>"
self
.
_assert_reg_field
(
self
.
_assert_reg_field
(
{
"honor_code"
:
"required"
,
"terms_of_service"
:
"required"
},
{
"honor_code"
:
"required"
,
"terms_of_service"
:
"required"
},
{
{
"label"
:
u"I agree to the {platform_name} {link_label}"
.
format
(
"label"
:
u"I agree to the {platform_name} {link_label}"
.
format
(
platform_name
=
settings
.
PLATFORM_NAME
,
platform_name
=
settings
.
PLATFORM_NAME
,
link_label
=
link_
label
link_label
=
link_
template
.
format
(
link_label
=
link_label
)
),
),
"name"
:
"honor_code"
,
"name"
:
"honor_code"
,
"defaultValue"
:
False
,
"defaultValue"
:
False
,
...
@@ -1596,7 +1592,7 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1596,7 +1592,7 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
)
)
# Terms of service field should also be present
# Terms of service field should also be present
link_label
=
'Terms of Service'
link_label
=
"Terms of Service"
self
.
_assert_reg_field
(
self
.
_assert_reg_field
(
{
"honor_code"
:
"required"
,
"terms_of_service"
:
"required"
},
{
"honor_code"
:
"required"
,
"terms_of_service"
:
"required"
},
{
{
...
@@ -1622,11 +1618,13 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1622,11 +1618,13 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
def
test_registration_separate_terms_of_service_mktg_site_disabled
(
self
):
def
test_registration_separate_terms_of_service_mktg_site_disabled
(
self
):
# Honor code field should say ONLY honor code,
# Honor code field should say ONLY honor code,
# not "terms of service and honor code"
# not "terms of service and honor code"
link_label
=
'Honor Code'
self
.
_assert_reg_field
(
self
.
_assert_reg_field
(
{
"honor_code"
:
"required"
,
"terms_of_service"
:
"required"
},
{
"honor_code"
:
"required"
,
"terms_of_service"
:
"required"
},
{
{
"label"
:
u"I agree to the {platform_name} Honor Code"
.
format
(
"label"
:
u"I agree to the {platform_name} {link_label}"
.
format
(
platform_name
=
settings
.
PLATFORM_NAME
platform_name
=
settings
.
PLATFORM_NAME
,
link_label
=
self
.
link_template
.
format
(
link_label
=
link_label
)
),
),
"name"
:
"honor_code"
,
"name"
:
"honor_code"
,
"defaultValue"
:
False
,
"defaultValue"
:
False
,
...
@@ -1640,12 +1638,14 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
...
@@ -1640,12 +1638,14 @@ class RegistrationViewTest(ThirdPartyAuthTestMixin, UserAPITestCase):
}
}
)
)
link_label
=
'Terms of Service'
# Terms of service field should also be present
# Terms of service field should also be present
self
.
_assert_reg_field
(
self
.
_assert_reg_field
(
{
"honor_code"
:
"required"
,
"terms_of_service"
:
"required"
},
{
"honor_code"
:
"required"
,
"terms_of_service"
:
"required"
},
{
{
"label"
:
u"I agree to the {platform_name} Terms of Service"
.
format
(
"label"
:
u"I agree to the {platform_name} {link_label}"
.
format
(
platform_name
=
settings
.
PLATFORM_NAME
platform_name
=
settings
.
PLATFORM_NAME
,
link_label
=
link_label
),
),
"name"
:
"terms_of_service"
,
"name"
:
"terms_of_service"
,
"defaultValue"
:
False
,
"defaultValue"
:
False
,
...
...
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