diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index 33f083a020..760db51924 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -240,6 +240,7 @@ def course_rerun_handler(request, course_key_string): GET html: return html page with form to rerun a course for the given course id """ + # Only global staff (PMs) are able to rerun courses during the soft launch if not GlobalStaff().has_user(request.user): raise PermissionDenied() course_key = CourseKey.from_string(course_key_string) @@ -407,7 +408,7 @@ def course_listing(request): def _get_rerun_link_for_item(course_key): - return '/course_rerun/{}/{}/{}'.format(course_key.org, course_key.course, course_key.run) + return reverse_course_url('course_rerun_handler', course_key) @login_required diff --git a/cms/static/js/index.js b/cms/static/js/index.js index de124f224b..91d8d71c96 100644 --- a/cms/static/js/index.js +++ b/cms/static/js/index.js @@ -7,7 +7,7 @@ define(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape"], url: $(this).data('dismiss-link'), type: 'DELETE', success: function(result) { - window.location.reload() + window.location.reload(); } }); }; diff --git a/cms/static/js/spec/views/pages/course_rerun_spec.js b/cms/static/js/spec/views/pages/course_rerun_spec.js index 077c395313..fc77d29536 100644 --- a/cms/static/js/spec/views/pages/course_rerun_spec.js +++ b/cms/static/js/spec/views/pages/course_rerun_spec.js @@ -1,5 +1,5 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers", "js/views/course_rerun"], - function ($, create_sinon, view_helpers, CourseRerunPage) { + function ($, create_sinon, view_helpers, CourseRerunUtils) { describe("Create course rerun page", function () { var selectors = { courseOrg: '.rerun-course-org', @@ -30,7 +30,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers" view_helpers.installMockAnalytics(); window.source_course_key = 'test_course_key'; appendSetFixtures(mockCreateCourseRerunHTML); - CourseRerunPage.onReady(); + CourseRerunUtils.onReady(); }); afterEach(function () { @@ -38,33 +38,33 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers" delete window.source_course_key; }); - describe("validateRequiredField", function () { - it("has a message for an empty string", function () { - var message = CourseRerunPage.validateRequiredField(''); + describe("Field validation", function () { + it("returns a message for an empty string", function () { + var message = CourseRerunUtils.validateRequiredField(''); expect(message).not.toBe(''); }); - it("does not have a message for a non empty string", function () { - var message = CourseRerunPage.validateRequiredField('edX'); + it("does not return a message for a non empty string", function () { + var message = CourseRerunUtils.validateRequiredField('edX'); expect(message).toBe(''); }); }); - describe("setNewCourseFieldInErr", function () { + describe("Error messages", function () { var setErrorMessage = function(selector, message) { var element = $(selector).parent(); - CourseRerunPage.setNewCourseFieldInErr(element, message); + CourseRerunUtils.setNewCourseFieldInErr(element, message); return element; }; - it("can show an error message", function () { + it("shows an error message", function () { var element = setErrorMessage(selectors.courseOrg, 'error message'); expect(element).toHaveClass(classes.error); expect(element.children(selectors.errorField)).not.toHaveClass(classes.hidden); expect(element.children(selectors.errorField)).toContainText('error message'); }); - it("can hide an error message", function () { + it("hides an error message", function () { var element = setErrorMessage(selectors.courseOrg, ''); expect(element).not.toHaveClass(classes.error); expect(element.children(selectors.errorField)).toHaveClass(classes.hidden); @@ -93,7 +93,7 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers" }); }); - it("can save course reruns", function () { + it("saves course reruns", function () { var requests = create_sinon.requests(this); window.source_course_key = 'test_course_key'; fillInFields('DemoX', 'DM101', '2014', 'Demo course'); diff --git a/cms/static/js/spec/views/pages/index_spec.js b/cms/static/js/spec/views/pages/index_spec.js index bffe8b5e3b..5eafbc476d 100644 --- a/cms/static/js/spec/views/pages/index_spec.js +++ b/cms/static/js/spec/views/pages/index_spec.js @@ -1,12 +1,12 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers", "js/index"], - function ($, create_sinon, view_helpers, IndexPage) { + function ($, create_sinon, view_helpers, IndexUtils) { describe("Course listing page", function () { var mockIndexPageHTML = readFixtures('mock/mock-index-page.underscore'); beforeEach(function () { view_helpers.installMockAnalytics(); appendSetFixtures(mockIndexPageHTML); - IndexPage.onReady(); + IndexUtils.onReady(); }); afterEach(function () { @@ -14,7 +14,6 @@ define(["jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers" delete window.source_course_key; }); - it("can dismiss notifications", function () { var requests = create_sinon.requests(this); $('.dismiss-button').click(); diff --git a/cms/static/js/views/course_rerun.js b/cms/static/js/views/course_rerun.js index 529e9029a9..e9860a0796 100644 --- a/cms/static/js/views/course_rerun.js +++ b/cms/static/js/views/course_rerun.js @@ -41,7 +41,7 @@ define(["domReady", "jquery", "underscore"], }, function (data) { if (data.url !== undefined) { - window.location = data.url + window.location = data.url; } else if (data.ErrMsg !== undefined) { $('.wrapper-error').addClass('is-shown').removeClass('is-hidden'); $('#course_rerun_error').html('
' + data.ErrMsg + '
'); @@ -64,7 +64,7 @@ define(["domReady", "jquery", "underscore"], $('#course_rerun_error').html(''); $('wrapper-error').removeClass('is-shown').addClass('is-hidden'); $('.rerun-course-save').off('click'); - window.location.href = '/course/' + window.location.href = '/course/'; }; var validateRequiredField = function (msg) { diff --git a/cms/static/js/views/pages/course_outline.js b/cms/static/js/views/pages/course_outline.js index 464c9d5516..87ba45309e 100644 --- a/cms/static/js/views/pages/course_outline.js +++ b/cms/static/js/views/pages/course_outline.js @@ -25,7 +25,7 @@ define(["jquery", "underscore", "gettext", "js/views/pages/base_page", "js/views self.outlineView.handleAddEvent(event); }); this.model.on('change', this.setCollapseExpandVisibility, this); - $('.dismiss-button').bind('click', this.dismissNotification) + $('.dismiss-button').bind('click', this.dismissNotification); }, setCollapseExpandVisibility: function() { diff --git a/common/djangoapps/course_action_state/migrations/0002_add_rerun_display_name.py b/common/djangoapps/course_action_state/migrations/0002_add_rerun_display_name.py index 8710b96bae..fc02006aff 100644 --- a/common/djangoapps/course_action_state/migrations/0002_add_rerun_display_name.py +++ b/common/djangoapps/course_action_state/migrations/0002_add_rerun_display_name.py @@ -73,4 +73,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['course_action_state'] \ No newline at end of file + complete_apps = ['course_action_state']