Commit fabd8a97 by Will Daly

Fix validation for checkboxes in forms.

Remove hard-coded TOS checkbox in registration template.
Disable new dashboard in settings; expose password reset end-point in student account app.
Added empty JS tests for new JavaScript
parent ed0c383a
......@@ -18,6 +18,11 @@ var edx = edx || {};
},
charLength: function( $el ) {
var type = $el.attr("type");
if (type !== "text" && type !== "textarea" && type !== "password") {
return true;
}
// Cannot assume there will be both min and max
var min = $el.attr('minlength') || 0,
max = $el.attr('maxlength') || false,
......@@ -35,7 +40,12 @@ var edx = edx || {};
},
required: function( $el ) {
return $el.attr('required') ? $el.val() : true;
if ($el.attr("type") === "checkbox") {
return $el.attr('required') ? $el.prop("checked") : true;
}
else {
return $el.attr('required') ? $el.val() : true;
}
},
email: {
......@@ -66,6 +76,6 @@ var edx = edx || {};
})();
edx.utils.validate = utils.validate
edx.utils.validate = utils.validate;
})( jQuery, _ );
\ No newline at end of file
......@@ -6,6 +6,7 @@ urlpatterns = patterns(
'student_account.views',
url(r'^login/$', 'login_and_registration_form', {'initial_mode': 'login'}, name='account_login'),
url(r'^register/$', 'login_and_registration_form', {'initial_mode': 'register'}, name='account_register'),
url(r'^password$', 'password_change_request_handler', name='password_change_request'),
)
if settings.FEATURES.get('ENABLE_NEW_DASHBOARD'):
......@@ -14,5 +15,4 @@ if settings.FEATURES.get('ENABLE_NEW_DASHBOARD'):
url(r'^$', 'index', name='account_index'),
url(r'^email$', 'email_change_request_handler', name='email_change_request'),
url(r'^email/confirmation/(?P<key>[^/]*)$', 'email_change_confirmation_handler', name='email_change_confirm'),
url(r'^password$', 'password_change_request_handler', name='password_change_request'),
)
......@@ -286,7 +286,7 @@ FEATURES = {
'ENABLE_VIDEO_ABSTRACTION_LAYER_API': False,
# Enable the new dashboard, account, and profile pages
'ENABLE_NEW_DASHBOARD': True,
'ENABLE_NEW_DASHBOARD': False,
}
# Ignore static asset files on import which match this pattern
......@@ -1036,6 +1036,7 @@ student_account_js = [
'js/student_account/views/AccessView.js',
'js/student_account/accessApp.js',
]
student_profile_js = sorted(rooted_glob(PROJECT_ROOT / 'static', 'js/student_profile/**/*.js'))
PIPELINE_CSS = {
......
......@@ -216,6 +216,7 @@
exports: 'js/student_account/account',
deps: ['jquery', 'underscore', 'backbone', 'gettext', 'jquery.cookie']
},
'js/student_profile/profile': {
exports: 'js/student_profile/profile',
deps: ['jquery', 'underscore', 'backbone', 'gettext', 'jquery.cookie']
......@@ -231,6 +232,7 @@
exports: 'js/dashboard/donation',
deps: ['jquery', 'underscore', 'gettext']
},
// Backbone classes loaded explicitly until they are converted to use RequireJS
'js/models/cohort': {
exports: 'CohortModel',
......@@ -257,7 +259,42 @@
'js/views/notification': {
exports: 'NotificationView',
deps: ['backbone', 'jquery', 'underscore']
}
},
// Student account registration/login
// Loaded explicitly until these are converted to RequireJS
'js/student_account/models/LoginModel': {
exports: 'js/student_account/models/LoginModel',
deps: ['jquery', 'underscore', 'backbone', 'gettext', 'jquery.cookie']
},
'js/student_account/views/LoginView': {
exports: 'js/student_account/views/LoginView',
deps: ['js/student_account/models/LoginModel']
},
'js/student_account/models/PasswordResetModel': {
exports: 'js/student_account/models/PasswordResetModel',
deps: ['jquery', 'underscore', 'backbone', 'gettext', 'jquery.cookie']
},
'js/student_account/views/PasswordResetView': {
exports: 'js/student_account/views/PasswordResetView',
deps: ['js/student_account/models/PasswordResetModel']
},
'js/student_account/models/RegisterModel': {
exports: 'js/student_account/models/RegisterModel',
deps: ['jquery', 'underscore', 'backbone', 'gettext', 'jquery.cookie']
},
'js/student_account/views/RegisterView': {
exports: 'js/student_account/views/RegisterView',
deps: ['js/student_account/models/RegisterModel']
},
'js/student_account/views/AccessView': {
exports: 'js/student_account/views/AccessView',
deps: [
'js/student_account/views/LoginView',
'js/student_account/views/PasswordResetView',
'js/student_account/views/RegisterView'
]
},
},
});
......@@ -270,7 +307,11 @@
'lms/include/js/spec/views/notification_spec.js',
'lms/include/js/spec/dashboard/donation.js',
'lms/include/js/spec/student_account/account.js',
'lms/include/js/spec/student_profile/profile.js'
'lms/include/js/spec/student_account/access_spec.js',
'lms/include/js/spec/student_account/login_spec.js',
'lms/include/js/spec/student_account/register_spec.js',
'lms/include/js/spec/student_account/password_reset_spec.js',
'lms/include/js/spec/student_profile/profile.js',
]);
}).call(this, requirejs, define);
define(['js/student_account/views/AccessView'],
function() {
'use strict';
describe("edx.student.account.AccessView", function() {
it("initially displays the correct form", function() {
// TODO
});
it("toggles between the login and registration forms", function() {
// TODO
});
it("displays the reset password form", function() {
// TODO
});
});
}
);
\ No newline at end of file
define(['js/student_account/views/LoginView'],
function() {
'use strict';
describe("edx.student.account.LoginView", function() {
it("logs the user in", function() {
// TODO
});
it("displays third party auth login buttons", function() {
// TODO
});
it("validates the email field", function() {
// TODO
});
it("validates the password field", function() {
// TODO
});
it("displays login errors", function() {
// TODO
});
it("displays an error if the form definition could not be loaded", function() {
// TODO
});
it("displays an error if the server could not be contacted while logging in", function() {
// TODO
});
it("allows the user to navigate to the password assistance form", function() {
// TODO
});
});
}
);
\ No newline at end of file
define(['js/student_account/views/PasswordResetView'],
function() {
'use strict';
describe("edx.student.account.PasswordResetView", function() {
it("allows the user to request a new password", function() {
// TODO
});
it("validates the email field", function() {
// TODO
});
it("displays password reset errors", function() {
// TODO
});
it("displays an error if the server could not be contacted", function() {
// TODO
});
});
}
);
\ No newline at end of file
define(['js/student_account/views/RegisterView'],
function() {
'use strict';
describe("edx.student.account.RegisterView", function() {
it("registers a new user", function() {
// TODO
});
it("displays third party auth registration buttons", function() {
// TODO
});
it("validates form fields", function() {
// TODO
});
it("displays registration errors", function() {
// TODO
});
it("displays an error if the form definition could not be loaded", function() {
// TODO
});
it("displays an error if the server could not be contacted while registering", function() {
// TODO
});
});
}
);
\ No newline at end of file
......@@ -7,6 +7,4 @@
</div>
<%= fields %>
<button class="action action-primary action-update js-login">Log in</button>
<button type="submit" class="button button-primary button-facebook"><span class="icon icon-facebook"></span>Sign in with Facebook</button>
<button type="submit" class="button button-primary button-google"><span class="icon icon-google-plus"></span>Sign in with Google</button>
</form>
\ No newline at end of file
......@@ -5,11 +5,6 @@
<p>Please enter a valid password</p>
</div>
</div>
<button type="submit" class="button button-primary button-facebook"><span class="icon icon-facebook"></span>Sign up with Facebook</button>
<button type="submit" class="button button-primary button-google"><span class="icon icon-google-plus"></span>Sign up with Google</button>
<%= fields %>
<input id="register-termsofservice" type="checkbox" name="termsofservice">
<label for="register-termsofservice">I agree to the <a href="#">Terms of Service and Honor Code</a> *</label>
<button class="action action-primary action-update js-register">Create My edX Account</button>
</form>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment