Commit 9f2e96d4 by Sofiya Semenova

ed-1260 Course teams unable to save changes to dates

parent c9f75f6b
...@@ -2,7 +2,7 @@ define([ ...@@ -2,7 +2,7 @@ define([
'jquery', 'js/models/settings/course_details', 'js/views/settings/main' 'jquery', 'js/models/settings/course_details', 'js/views/settings/main'
], function($, CourseDetailsModel, MainView) { ], function($, CourseDetailsModel, MainView) {
'use strict'; 'use strict';
return function(detailsUrl, showMinGradeWarning) { return function(detailsUrl, showMinGradeWarning, showCertificateAvailableDate) {
var model; var model;
// highlighting labels when fields are focused in // highlighting labels when fields are focused in
$('form :input') $('form :input')
...@@ -15,6 +15,7 @@ define([ ...@@ -15,6 +15,7 @@ define([
model = new CourseDetailsModel(); model = new CourseDetailsModel();
model.urlRoot = detailsUrl; model.urlRoot = detailsUrl;
model.showCertificateAvailableDate = showCertificateAvailableDate;
model.fetch({ model.fetch({
success: function(model) { success: function(model) {
var editor = new MainView({ var editor = new MainView({
......
...@@ -60,7 +60,7 @@ define(['backbone', 'underscore', 'gettext', 'js/models/validation_helpers', 'js ...@@ -60,7 +60,7 @@ define(['backbone', 'underscore', 'gettext', 'js/models/validation_helpers', 'js
if (newattrs.end_date && newattrs.enrollment_end && newattrs.end_date < newattrs.enrollment_end) { if (newattrs.end_date && newattrs.enrollment_end && newattrs.end_date < newattrs.enrollment_end) {
errors.enrollment_end = gettext('The enrollment end date cannot be after the course end date.'); errors.enrollment_end = gettext('The enrollment end date cannot be after the course end date.');
} }
if (!this.get('self_paced') && newattrs.end_date && newattrs.certificate_available_date && if (this.showCertificateAvailableDate && newattrs.end_date && newattrs.certificate_available_date &&
newattrs.certificate_available_date < newattrs.end_date) { newattrs.certificate_available_date < newattrs.end_date) {
errors.certificate_available_date = gettext( errors.certificate_available_date = gettext(
'The certificate available date must be later than the course end date.' 'The certificate available date must be later than the course end date.'
......
...@@ -350,10 +350,12 @@ define([ ...@@ -350,10 +350,12 @@ define([
AjaxHelpers.respondWithJson(requests, expectedJson); AjaxHelpers.respondWithJson(requests, expectedJson);
}); });
it('should disallow save with a certificate available date before end date', function() { it('should disallow save with a certificate available date before end date', function() {
this.model.showCertificateAvailableDate = true;
$('#course-end-date').val('01/01/2030').trigger('change'); $('#course-end-date').val('01/01/2030').trigger('change');
expect(this.view.$('.message-error')).toExist(); expect(this.view.$('.message-error')).toExist();
}); });
it('should allow save with a certificate available date before end date for self-paced course', function() { it('should allow save with a certificate available date before end date for self-paced course', function() {
this.model.showCertificateAvailableDate = false;
this.model.set('self_paced', true); this.model.set('self_paced', true);
$('#course-end-date').val('01/01/2030').trigger('change'); $('#course-end-date').val('01/01/2030').trigger('change');
expect(this.view.$('.message-error')).not.toExist(); expect(this.view.$('.message-error')).not.toExist();
......
...@@ -38,7 +38,8 @@ CMS.URL.UPLOAD_ASSET = '${upload_asset_url | n, js_escaped_string}' ...@@ -38,7 +38,8 @@ CMS.URL.UPLOAD_ASSET = '${upload_asset_url | n, js_escaped_string}'
require(["js/factories/settings"], function(SettingsFactory) { require(["js/factories/settings"], function(SettingsFactory) {
SettingsFactory( SettingsFactory(
"${details_url | n, js_escaped_string}", "${details_url | n, js_escaped_string}",
${show_min_grade_warning | n, dump_js_escaped_json} ${show_min_grade_warning | n, dump_js_escaped_json},
${can_show_certificate_available_date_field(context_course) | n, dump_js_escaped_json}
); );
}); });
</%block> </%block>
......
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