From 4157e5c0f6a7f216b0b7a4f2b3efb379e9643684 Mon Sep 17 00:00:00 2001
From: Renzo Lucioni
Date: Fri, 24 Oct 2014 09:20:31 -0400
Subject: [PATCH] i18n logistration
---
common/djangoapps/user_api/urls.py | 1 +
common/djangoapps/user_api/views.py | 214 +++++++++++++++---
.../js/spec_helpers/edx.utils.validate.js | 22 +-
lms/djangoapps/student_account/views.py | 1 +
lms/static/js/spec/main.js | 9 +-
lms/static/js/student_account/accessApp.js | 3 +-
.../js/student_account/models/LoginModel.js | 2 +-
.../models/PasswordResetModel.js | 8 +-
.../student_account/models/RegisterModel.js | 3 +-
.../js/student_account/views/AccessView.js | 39 ++--
.../js/student_account/views/FormView.js | 11 +-
.../js/student_account/views/LoginView.js | 13 +-
.../views/PasswordResetView.js | 18 --
.../js/student_account/views/RegisterView.js | 12 +-
lms/static/sass/views/_login-register.scss | 5 +
.../student_account/access.underscore | 8 +-
.../student_account/form_field.underscore | 4 +-
.../student_account/login.underscore | 17 +-
.../student_account/login_and_register.html | 11 +-
.../student_account/password_reset.underscore | 15 +-
.../student_account/register.underscore | 20 +-
21 files changed, 303 insertions(+), 133 deletions(-)
diff --git a/common/djangoapps/user_api/urls.py b/common/djangoapps/user_api/urls.py
index f73c4969fa..dc470ceed6 100644
--- a/common/djangoapps/user_api/urls.py
+++ b/common/djangoapps/user_api/urls.py
@@ -12,6 +12,7 @@ urlpatterns = patterns(
url(r'^v1/', include(user_api_router.urls)),
url(r'^v1/account/login_session/$', user_api_views.LoginSessionView.as_view(), name="user_api_login_session"),
url(r'^v1/account/registration/$', user_api_views.RegistrationView.as_view(), name="user_api_registration"),
+ url(r'^v1/account/password_reset/$', user_api_views.PasswordResetView.as_view(), name="user_api_password_reset"),
url(
r'^v1/preferences/(?P{})/users/$'.format(UserPreference.KEY_REGEX),
user_api_views.PreferenceUsersListView.as_view()
diff --git a/common/djangoapps/user_api/views.py b/common/djangoapps/user_api/views.py
index 17356fe31d..8c4b9ade5a 100644
--- a/common/djangoapps/user_api/views.py
+++ b/common/djangoapps/user_api/views.py
@@ -73,23 +73,39 @@ class LoginSessionView(APIView):
"""
form_desc = FormDescription("post", reverse("user_api_login_session"))
+ # Translators: This label appears above a field on the login form
+ # meant to hold the user's email address.
+ email_label = _(u"Email")
+
+ # Translators: This example email address is used as a placeholder in
+ # a field on the login form meant to hold the user's email address.
+ email_placeholder = _(u"username@domain.com")
+
+ # Translators: These instructions appear on the login form, immediately
+ # below a field meant to hold the user's email address.
+ email_instructions = _(
+ u"The email address you used to register with {platform_name}"
+ ).format(platform_name=settings.PLATFORM_NAME)
+
form_desc.add_field(
"email",
field_type="email",
- label=_(u"Email"),
- placeholder=_(u"username@domain.com"),
- instructions=_(
- u"The email address you used to register with {platform}"
- ).format(platform=settings.PLATFORM_NAME),
+ label=email_label,
+ placeholder=email_placeholder,
+ instructions=email_instructions,
restrictions={
"min_length": account_api.EMAIL_MIN_LENGTH,
"max_length": account_api.EMAIL_MAX_LENGTH,
}
)
+ # Translators: This label appears above a field on the login form
+ # meant to hold the user's password.
+ password_label = _(u"Password")
+
form_desc.add_field(
"password",
- label=_(u"Password"),
+ label=password_label,
field_type="password",
restrictions={
"min_length": account_api.PASSWORD_MIN_LENGTH,
@@ -97,10 +113,15 @@ class LoginSessionView(APIView):
}
)
+ # Translators: This phrase appears next to a checkbox on the login form
+ # which the user can check in order to remain logged in after their
+ # session ends.
+ remember_label = _(u"Remember me")
+
form_desc.add_field(
"remember",
field_type="checkbox",
- label=_("Remember me"),
+ label=remember_label,
default=False,
required=False,
)
@@ -252,14 +273,26 @@ class RegistrationView(APIView):
return shim_student_view(create_account)(request)
def _add_email_field(self, form_desc, required=True):
+ # Translators: This label appears above a field on the registration form
+ # meant to hold the user's email address.
+ 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
+ # below a field meant to hold the user's email address.
+ email_instructions = _(
+ u"The email address you used to register with {platform_name}"
+ ).format(platform_name=settings.PLATFORM_NAME)
+
form_desc.add_field(
"email",
field_type="email",
- label=_(u"Email"),
- placeholder=_(u"username@domain.com"),
- instructions=_(
- u"The email address you want to use with {platform}"
- ).format(platform=settings.PLATFORM_NAME),
+ label=email_label,
+ placeholder=email_placeholder,
+ instructions=email_instructions,
restrictions={
"min_length": account_api.EMAIL_MIN_LENGTH,
"max_length": account_api.EMAIL_MAX_LENGTH,
@@ -268,10 +301,18 @@ class RegistrationView(APIView):
)
def _add_name_field(self, form_desc, required=True):
+ # Translators: This label appears above a field on the registration form
+ # meant to hold the user's full name.
+ name_label = _(u"Full Name")
+
+ # Translators: These instructions appear on the registration form, immediately
+ # below a field meant to hold the user's full name.
+ name_instructions = _(u"The name that will appear on your certificates")
+
form_desc.add_field(
"name",
- label=_(u"Full Name"),
- instructions=_(u"The name that will appear on your certificates"),
+ label=name_label,
+ instructions=name_instructions,
restrictions={
"max_length": profile_api.FULL_NAME_MAX_LENGTH,
},
@@ -279,10 +320,20 @@ class RegistrationView(APIView):
)
def _add_username_field(self, form_desc, required=True):
+ # Translators: This label appears above a field on the registration form
+ # meant to hold the user's public username.
+ username_label = _(u"Username")
+
+ # Translators: These instructions appear on the registration form, immediately
+ # below a field meant to hold the user's public username.
+ username_instructions = _(
+ u"The name that will identify you in your courses"
+ )
+
form_desc.add_field(
"username",
- label=_(u"Username"),
- instructions=_(u"The name that will identify you in your courses"),
+ label=username_label,
+ instructions=username_instructions,
restrictions={
"min_length": account_api.USERNAME_MIN_LENGTH,
"max_length": account_api.USERNAME_MAX_LENGTH,
@@ -291,9 +342,14 @@ class RegistrationView(APIView):
)
def _add_password_field(self, form_desc, required=True):
+ # Translators: This label appears above a field on the registration form
+ # meant to hold the user's password.
+ password_label = _(u"Password")
+
form_desc.add_field(
"password",
- label=_(u"Password"),
+ label=password_label,
+ field_type="password",
restrictions={
"min_length": account_api.PASSWORD_MIN_LENGTH,
"max_length": account_api.PASSWORD_MAX_LENGTH,
@@ -302,57 +358,87 @@ class RegistrationView(APIView):
)
def _add_level_of_education_field(self, form_desc, required=True):
+ # Translators: This label appears above a dropdown menu on the registration
+ # form used to select the user's highest completed level of education.
+ education_level_label = _(u"Highest Level of Education Completed")
+
form_desc.add_field(
"level_of_education",
- label=_("Highest Level of Education Completed"),
+ label=education_level_label,
field_type="select",
options=self._options_with_default(UserProfile.LEVEL_OF_EDUCATION_CHOICES),
required=required
)
def _add_gender_field(self, form_desc, required=True):
+ # Translators: This label appears above a dropdown menu on the registration
+ # form used to select the user's gender.
+ gender_label = _(u"Gender")
+
form_desc.add_field(
"gender",
- label=_("Gender"),
+ label=gender_label,
field_type="select",
options=self._options_with_default(UserProfile.GENDER_CHOICES),
required=required
)
def _add_year_of_birth_field(self, form_desc, required=True):
+ # Translators: This label appears above a dropdown menu on the registration
+ # form used to select the user's year of birth.
+ yob_label = _(u"Year of Birth")
+
options = [(unicode(year), unicode(year)) for year in UserProfile.VALID_YEARS]
form_desc.add_field(
"year_of_birth",
- label=_("Year of Birth"),
+ label=yob_label,
field_type="select",
options=self._options_with_default(options),
required=required
)
def _add_mailing_address_field(self, form_desc, required=True):
+ # Translators: This label appears above a field on the registration form
+ # meant to hold the user's mailing address.
+ mailing_address_label = _(u"Mailing Address")
+
form_desc.add_field(
"mailing_address",
- label=_("Mailing Address"),
+ label=mailing_address_label,
field_type="textarea",
required=required
)
def _add_goals_field(self, form_desc, required=True):
+ # Translators: This phrase appears above a field on the registration form
+ # meant to hold the user's reasons for registering with edX.
+ goals_label = _(
+ u"If you'd like, tell us why you're interested in {platform_name}"
+ ).format(platform_name=settings.PLATFORM_NAME)
+
form_desc.add_field(
"goals",
- label=_("If you'd like, tell us why you're interested in edX."),
+ label=goals_label,
field_type="textarea",
required=required
)
def _add_city_field(self, form_desc, required=True):
+ # Translators: This label appears above a field on the registration form
+ # which allows the user to input the city in which they live.
+ city_label = _(u"City")
+
form_desc.add_field(
"city",
- label=_("City"),
+ label=city_label,
required=required
)
def _add_country_field(self, form_desc, required=True):
+ # Translators: This label appears above a dropdown menu on the registration
+ # form used to select the country in which the user lives.
+ country_label = _(u"Country")
+
sorted_countries = sorted(
countries.countries, key=lambda(__, name): unicode(name)
)
@@ -362,7 +448,7 @@ class RegistrationView(APIView):
]
form_desc.add_field(
"country",
- label=_("Country"),
+ label=country_label,
field_type="select",
options=self._options_with_default(options),
required=required
@@ -375,7 +461,8 @@ class RegistrationView(APIView):
# Combine terms of service and honor code checkboxes
else:
- # Translators: This is a legal document users must agree to in order to register a new account.
+ # Translators: This is a legal document users must agree to
+ # in order to register a new account.
terms_text = _(u"Terms of Service and Honor Code")
terms_link = u"{terms_text}".format(
@@ -383,11 +470,17 @@ class RegistrationView(APIView):
terms_text=terms_text
)
- # Translators: "Terms of service" is a legal document users must agree to in order to register a new account.
- label = _(u"I agree to the {terms_of_service}").format(terms_of_service=terms_link)
+ # Translators: "Terms of Service" is a legal document users must agree to
+ # in order to register a new account.
+ label = _(
+ u"I agree to the {terms_of_service}"
+ ).format(terms_of_service=terms_link)
- # Translators: "Terms of service" is a legal document users must agree to in order to register a new account.
- error_msg = _(u"You must agree to the {terms_of_service}").format(terms_of_service=terms_link)
+ # Translators: "Terms of Service" is a legal document users must agree to
+ # in order to register a new account.
+ error_msg = _(
+ u"You must agree to the {terms_of_service}"
+ ).format(terms_of_service=terms_link)
form_desc.add_field(
"honor_code",
@@ -401,17 +494,20 @@ class RegistrationView(APIView):
)
def _add_terms_of_service_field(self, form_desc, required=True):
- # Translators: This is a legal document users must agree to in order to register a new account.
+ # Translators: This is a legal document users must agree to
+ # in order to register a new account.
terms_text = _(u"Terms of Service")
terms_link = u"{terms_text}".format(
url=marketing_link("TOS"),
terms_text=terms_text
)
- # Translators: "Terms of service" is a legal document users must agree to in order to register a new account.
+ # Translators: "Terms of service" is a legal document users must agree to
+ # in order to register a new account.
label = _(u"I agree to the {terms_of_service}").format(terms_of_service=terms_link)
- # Translators: "Terms of service" is a legal document users must agree to in order to register a new account.
+ # Translators: "Terms of service" is a legal document users must agree to
+ # in order to register a new account.
error_msg = _("You must agree to the {terms_of_service}").format(terms_of_service=terms_link)
form_desc.add_field(
@@ -478,6 +574,60 @@ class RegistrationView(APIView):
restrictions={}
)
+class PasswordResetView(APIView):
+ """HTTP end-point for GETting a description of the password reset form. """
+
+ # This end-point is available to anonymous users,
+ # so do not require authentication.
+ authentication_classes = []
+
+ def get(self, request):
+ """Return a description of the password reset form.
+
+ This decouples clients from the API definition:
+ if the API decides to modify the form, clients won't need
+ to be updated.
+
+ See `user_api.helpers.FormDescription` for examples
+ of the JSON-encoded form description.
+
+ Arguments:
+ request (HttpRequest)
+
+ Returns:
+ HttpResponse
+
+ """
+ form_desc = FormDescription("post", reverse("password_change_request"))
+
+ # Translators: This label appears above a field on the password reset
+ # form meant to hold the user's email address.
+ email_label = _(u"Email")
+
+ # Translators: This example email address is used as a placeholder in
+ # a field on the password reset form meant to hold the user's email address.
+ email_placeholder = _(u"username@domain.com")
+
+ # Translators: These instructions appear on the password reset form,
+ # immediately below a field meant to hold the user's email address.
+ email_instructions = _(
+ u"The email address you used to register with {platform_name}"
+ ).format(platform_name=settings.PLATFORM_NAME)
+
+ form_desc.add_field(
+ "email",
+ field_type="email",
+ label=email_label,
+ placeholder=email_placeholder,
+ instructions=email_instructions,
+ restrictions={
+ "min_length": account_api.EMAIL_MIN_LENGTH,
+ "max_length": account_api.EMAIL_MAX_LENGTH,
+ }
+ )
+
+ return HttpResponse(form_desc.to_json(), content_type="application/json")
+
class UserViewSet(viewsets.ReadOnlyModelViewSet):
authentication_classes = (authentication.SessionAuthentication,)
diff --git a/common/static/js/spec_helpers/edx.utils.validate.js b/common/static/js/spec_helpers/edx.utils.validate.js
index bd9b1ff1ab..5215337f0c 100644
--- a/common/static/js/spec_helpers/edx.utils.validate.js
+++ b/common/static/js/spec_helpers/edx.utils.validate.js
@@ -1,6 +1,6 @@
var edx = edx || {};
-(function( $, _ ) {
+(function( $, _, gettext ) {
'use strict';
edx.utils = edx.utils || {};
@@ -10,10 +10,10 @@ var edx = edx || {};
validate: {
msg: {
- email: '
The email address you\'ve provided is invalid.
',
- min: '
<%= field %> must have at least <%= count %> characters.
',
- max: '
<%= field %> can only contain up to <%= count %> characters.
',
- required: '
<%= field %> is required.
',
+ email: '
<%- gettext("The email address you\'ve provided is invalid.") %>
',
+ min: '
<%- _.sprintf(gettext("%(field)s must have at least %(count)d characters"), context) %>
',
+ max: '
<%- _.sprintf(gettext("%(field)s can only contain up to %(count)d characters"), context) %>
',
+ required: '
<%- _.sprintf(gettext("%(field)s is required"), context) %>
',
custom: '
<%= content %>
'
},
@@ -123,13 +123,17 @@ var edx = edx || {};
tpl = _fn.validate.msg[key];
obj = {
- field: _fn.validate.str.capitalizeFirstLetter( name )
+ // We pass the context object to the template so that
+ // we can perform variable interpolation using sprintf
+ context: {
+ field: _fn.validate.str.capitalizeFirstLetter( name )
+ }
};
if ( key === 'min' ) {
- obj.count = $el.attr('minlength');
+ obj.context.count = $el.attr('minlength');
} else if ( key === 'max' ) {
- obj.count = $el.attr('maxlength');
+ obj.context.count = $el.attr('maxlength');
}
}
@@ -150,4 +154,4 @@ var edx = edx || {};
edx.utils.validate = utils.validate;
-})( jQuery, _ );
\ No newline at end of file
+})( jQuery, _, gettext );
diff --git a/lms/djangoapps/student_account/views.py b/lms/djangoapps/student_account/views.py
index f8f554bae5..36f778b80e 100644
--- a/lms/djangoapps/student_account/views.py
+++ b/lms/djangoapps/student_account/views.py
@@ -69,6 +69,7 @@ def login_and_registration_form(request, initial_mode="login"):
'disable_courseware_js': True,
'initial_mode': initial_mode,
'third_party_auth': json.dumps(_third_party_auth_context(request)),
+ 'platform_name': settings.PLATFORM_NAME,
}
return render_to_response('student_account/login_and_register.html', context)
diff --git a/lms/static/js/spec/main.js b/lms/static/js/spec/main.js
index acdb4b9565..20e41a02a5 100644
--- a/lms/static/js/spec/main.js
+++ b/lms/static/js/spec/main.js
@@ -275,7 +275,8 @@
exports: 'js/student_account/views/LoginView',
deps: [
'js/student_account/models/LoginModel',
- 'js/student_account/views/FormView'
+ 'js/student_account/views/FormView',
+ 'underscore.string'
]
},
'js/student_account/models/PasswordResetModel': {
@@ -297,7 +298,8 @@
exports: 'js/student_account/views/RegisterView',
deps: [
'js/student_account/models/RegisterModel',
- 'js/student_account/views/FormView'
+ 'js/student_account/views/FormView',
+ 'underscore.string'
]
},
'js/student_account/views/AccessView': {
@@ -305,7 +307,8 @@
deps: [
'js/student_account/views/LoginView',
'js/student_account/views/PasswordResetView',
- 'js/student_account/views/RegisterView'
+ 'js/student_account/views/RegisterView',
+ 'underscore.string'
]
},
},
diff --git a/lms/static/js/student_account/accessApp.js b/lms/static/js/student_account/accessApp.js
index 1981015b55..9b41e41439 100644
--- a/lms/static/js/student_account/accessApp.js
+++ b/lms/static/js/student_account/accessApp.js
@@ -8,6 +8,7 @@ var edx = edx || {};
return new edx.student.account.AccessView({
mode: $('#login-and-registration-container').data('initial-mode'),
- thirdPartyAuth: $('#login-and-registration-container').data('third-party-auth')
+ thirdPartyAuth: $('#login-and-registration-container').data('third-party-auth'),
+ platformName: $('#login-and-registration-container').data('platform-name')
});
})(jQuery);
diff --git a/lms/static/js/student_account/models/LoginModel.js b/lms/static/js/student_account/models/LoginModel.js
index 7930d281ca..22f46db41a 100644
--- a/lms/static/js/student_account/models/LoginModel.js
+++ b/lms/static/js/student_account/models/LoginModel.js
@@ -49,4 +49,4 @@ var edx = edx || {};
});
}
});
-})(jQuery, _, Backbone, gettext);
\ No newline at end of file
+})(jQuery, _, Backbone, gettext);
diff --git a/lms/static/js/student_account/models/PasswordResetModel.js b/lms/static/js/student_account/models/PasswordResetModel.js
index bfc1997fa9..64a1e37932 100644
--- a/lms/static/js/student_account/models/PasswordResetModel.js
+++ b/lms/static/js/student_account/models/PasswordResetModel.js
@@ -12,14 +12,18 @@ var edx = edx || {};
email: ''
},
- urlRoot: '/account/password',
+ urlRoot: '',
+
+ initialize: function( obj ) {
+ this.urlRoot = obj.url;
+ },
sync: function(method, model) {
var headers = {
'X-CSRFToken': $.cookie('csrftoken')
};
- // Is just expecting email address
+ // Only expects an email address.
$.ajax({
url: model.urlRoot,
type: 'POST',
diff --git a/lms/static/js/student_account/models/RegisterModel.js b/lms/static/js/student_account/models/RegisterModel.js
index a389a1c1f3..b5f93774b7 100644
--- a/lms/static/js/student_account/models/RegisterModel.js
+++ b/lms/static/js/student_account/models/RegisterModel.js
@@ -52,9 +52,8 @@ var edx = edx || {};
window.location.href = url;
})
.fail( function( error ) {
- console.log('RegisterModel.save() FAILURE!!!!!');
model.trigger('error', error);
});
}
});
-})(jQuery, _, Backbone, gettext);
\ No newline at end of file
+})(jQuery, _, Backbone, gettext);
diff --git a/lms/static/js/student_account/views/AccessView.js b/lms/static/js/student_account/views/AccessView.js
index 807866cead..3465d333bc 100644
--- a/lms/static/js/student_account/views/AccessView.js
+++ b/lms/static/js/student_account/views/AccessView.js
@@ -25,12 +25,19 @@ var edx = edx || {};
activeForm: '',
initialize: function( obj ) {
+ /* Mix non-conflicting functions from underscore.string
+ * (all but include, contains, and reverse) into the
+ * Underscore namespace
+ */
+ _.mixin(_.str.exports())
+
this.tpl = $(this.tpl).html();
this.activeForm = obj.mode || 'login';
this.thirdPartyAuth = obj.thirdPartyAuth || {
currentProvider: null,
providers: []
};
+ this.platformName = obj.platformName;
this.render();
},
@@ -52,11 +59,7 @@ var edx = edx || {};
},
loadForm: function( type ) {
- if ( type === 'reset' ) {
- this.load.reset( this );
- } else {
- this.getFormData( type, this.load[type], this );
- }
+ this.getFormData( type, this.load[type], this );
},
load: {
@@ -68,27 +71,21 @@ var edx = edx || {};
context.subview.login = new edx.student.account.LoginView({
fields: data.fields,
model: model,
- thirdPartyAuth: context.thirdPartyAuth
+ thirdPartyAuth: context.thirdPartyAuth,
+ platformName: context.platformName
});
// Listen for 'password-help' event to toggle sub-views
context.listenTo( context.subview.login, 'password-help', context.resetPassword );
},
- reset: function( context ) {
- var model = new edx.student.account.PasswordResetModel(),
- data = [{
- label: 'Email',
- instructions: 'The email address you used to register with edX',
- name: 'email',
- required: true,
- type: 'email',
- restrictions: [],
- defaultValue: ''
- }];
+ reset: function( data, context ) {
+ var model = new edx.student.account.PasswordResetModel({
+ url: data.submit_url
+ });
context.subview.passwordHelp = new edx.student.account.PasswordResetView({
- fields: data,
+ fields: data.fields,
model: model
});
},
@@ -101,7 +98,8 @@ var edx = edx || {};
context.subview.register = new edx.student.account.RegisterView({
fields: data.fields,
model: model,
- thirdPartyAuth: context.thirdPartyAuth
+ thirdPartyAuth: context.thirdPartyAuth,
+ platformName: context.platformName
});
}
},
@@ -109,7 +107,8 @@ var edx = edx || {};
getFormData: function( type, callback, context ) {
var urls = {
login: 'login_session',
- register: 'registration'
+ register: 'registration',
+ reset: 'password_reset'
};
$.ajax({
diff --git a/lms/static/js/student_account/views/FormView.js b/lms/static/js/student_account/views/FormView.js
index 989db79b87..66663d363a 100644
--- a/lms/static/js/student_account/views/FormView.js
+++ b/lms/static/js/student_account/views/FormView.js
@@ -44,7 +44,7 @@ var edx = edx || {};
* default init steps
*/
preRender: function( data ) {
- /* custom code goes here */
+ /* Custom code goes here */
return data;
},
@@ -89,7 +89,7 @@ var edx = edx || {};
this.render( html.join('') );
},
- /* Helper method ot toggle display
+ /* Helper method to toggle display
* including accessibility considerations
*/
element: {
@@ -143,7 +143,7 @@ var edx = edx || {};
key = $el.attr('name') || false;
if ( key ) {
- test = this.validate( elements[i], this.formType );
+ test = this.validate( elements[i] );
if ( test.isValid ) {
obj[key] = $el.attr('type') === 'checkbox' ? $el.is(':checked') : $el.val();
@@ -204,8 +204,9 @@ var edx = edx || {};
this.element.hide( this.$errors );
}
},
- validate: function( $el, form ) {
- return edx.utils.validate( $el, form );
+
+ validate: function( $el ) {
+ return edx.utils.validate( $el );
}
});
diff --git a/lms/static/js/student_account/views/LoginView.js b/lms/static/js/student_account/views/LoginView.js
index 132a885378..2812d0c3c1 100644
--- a/lms/static/js/student_account/views/LoginView.js
+++ b/lms/static/js/student_account/views/LoginView.js
@@ -24,15 +24,21 @@ var edx = edx || {};
preRender: function( data ) {
this.providers = data.thirdPartyAuth.providers || [];
this.currentProvider = data.thirdPartyAuth.currentProvider || '';
+ this.platformName = data.platformName;
},
render: function( html ) {
var fields = html || '';
$(this.el).html( _.template( this.tpl, {
- fields: fields,
- currentProvider: this.currentProvider,
- providers: this.providers
+ // We pass the context object to the template so that
+ // we can perform variable interpolation using sprintf
+ context: {
+ fields: fields,
+ currentProvider: this.currentProvider,
+ providers: this.providers,
+ platformName: this.platformName
+ }
}));
this.postRender();
@@ -94,5 +100,4 @@ var edx = edx || {};
}
}
});
-
})(jQuery, _, gettext);
diff --git a/lms/static/js/student_account/views/PasswordResetView.js b/lms/static/js/student_account/views/PasswordResetView.js
index 3474e7e3c5..979cfbb0d7 100644
--- a/lms/static/js/student_account/views/PasswordResetView.js
+++ b/lms/static/js/student_account/views/PasswordResetView.js
@@ -43,24 +43,6 @@ var edx = edx || {};
this.element.hide( $el.find('#password-reset-form') );
this.element.show( $el.find('.js-reset-success') );
- },
-
- submitForm: function( event ) {
- var data = this.getFormData();
-
- event.preventDefault();
-
- if ( !_.compact(this.errors).length ) {
- this.model.set( data );
- this.model.save();
- this.toggleErrorMsg( false );
- } else {
- this.toggleErrorMsg( true );
- }
- },
-
- validate: function( $el ) {
- return edx.utils.validate( $el );
}
});
diff --git a/lms/static/js/student_account/views/RegisterView.js b/lms/static/js/student_account/views/RegisterView.js
index c455741b19..872f42ae76 100644
--- a/lms/static/js/student_account/views/RegisterView.js
+++ b/lms/static/js/student_account/views/RegisterView.js
@@ -21,15 +21,21 @@ var edx = edx || {};
preRender: function( data ) {
this.providers = data.thirdPartyAuth.providers || [];
this.currentProvider = data.thirdPartyAuth.currentProvider || '';
+ this.platformName = data.platformName;
},
render: function( html ) {
var fields = html || '';
$(this.el).html( _.template( this.tpl, {
- fields: fields,
- currentProvider: this.currentProvider,
- providers: this.providers
+ // We pass the context object to the template so that
+ // we can perform variable interpolation using sprintf
+ context: {
+ fields: fields,
+ currentProvider: this.currentProvider,
+ providers: this.providers,
+ platformName: this.platformName
+ }
}));
this.postRender();
diff --git a/lms/static/sass/views/_login-register.scss b/lms/static/sass/views/_login-register.scss
index 4fea19578e..65c072d552 100644
--- a/lms/static/sass/views/_login-register.scss
+++ b/lms/static/sass/views/_login-register.scss
@@ -99,6 +99,11 @@
/** The forms **/
.form-wrapper {
padding-top: 25px;
+
+ form {
+ @include clearfix;
+ clear: both;
+ }
}
.login-form {
diff --git a/lms/templates/student_account/access.underscore b/lms/templates/student_account/access.underscore
index 46be42e50f..edf09cb0f1 100644
--- a/lms/templates/student_account/access.underscore
+++ b/lms/templates/student_account/access.underscore
@@ -1,12 +1,12 @@
-
Welcome!
-
Log in or register to take courses from the world's best universities.
+
<%- gettext("Welcome!") %>
+
<%- gettext("Log in or register to take courses from the world's best universities.") %>
\ No newline at end of file
+
diff --git a/lms/templates/student_account/login.underscore b/lms/templates/student_account/login.underscore
index 8075c79ed5..f22513a525 100644
--- a/lms/templates/student_account/login.underscore
+++ b/lms/templates/student_account/login.underscore
@@ -1,21 +1,24 @@
-<% _.each( providers, function( provider) { %>
+<% _.each( context.providers, function( provider ) { %>
<% }); %>
diff --git a/lms/templates/student_account/login_and_register.html b/lms/templates/student_account/login_and_register.html
index c66caa2753..6cc9dcf12b 100644
--- a/lms/templates/student_account/login_and_register.html
+++ b/lms/templates/student_account/login_and_register.html
@@ -6,16 +6,16 @@
<%block name="pagetitle">${_("Log in or Register")}%block>
<%block name="js_extra">
-
+
<%static:js group='student_account'/>
%block>
<%block name="header_extras">
-% for template_name in ["account", "access", "form_field", "login", "register", "password_reset"]:
-
+ % for template_name in ["account", "access", "form_field", "login", "register", "password_reset"]:
+
% endfor
%block>
@@ -24,5 +24,6 @@
class="login-register"
data-initial-mode="${initial_mode}"
data-third-party-auth='${third_party_auth}'
+ data-platform-name='${platform_name}'
/>
diff --git a/lms/templates/student_account/password_reset.underscore b/lms/templates/student_account/password_reset.underscore
index c9a54eaebe..04d66532a9 100644
--- a/lms/templates/student_account/password_reset.underscore
+++ b/lms/templates/student_account/password_reset.underscore
@@ -1,27 +1,28 @@
-
Reset Password
+
<%- gettext("Reset Password") %>
-
-
Enter the email address you used to create your account. We'll send you a link you can use to reset your password.
+
<%- gettext("Enter the email address you used to create your account. We'll send you a link you can use to reset your password.") %>
-
Password Reset Email Sent
+
<%- gettext("Password Reset Email Sent") %>
-
We've sent instructions for resetting your password to the email address you provided.
+
+ <%- gettext("We've sent instructions for resetting your password to the email address you provided.") %>
+
diff --git a/lms/templates/student_account/register.underscore b/lms/templates/student_account/register.underscore
index dc9e1e37b8..ae2f00a787 100644
--- a/lms/templates/student_account/register.underscore
+++ b/lms/templates/student_account/register.underscore
@@ -1,21 +1,25 @@
-<% if (currentProvider) { %>
+<% if (context.currentProvider) { %>
-
You've successfully logged into <%- currentProvider %>. We just need a little more information before you start learning with edX.
+
+ <%- _.sprintf(gettext("You've successfully logged into %(currentProvider)s."), context) %>
+ <%- _.sprintf(gettext("We just need a little more information before you start learning with %(platformName)s."), context) %>
+