Commit 2839ad87 by Ben McMorran

PR cleanup

parent 46932ee0
......@@ -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
......
......@@ -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();
}
});
};
......
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');
......
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();
......
......@@ -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('<p>' + data.ErrMsg + '</p>');
......@@ -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) {
......
......@@ -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() {
......
......@@ -73,4 +73,4 @@ class Migration(SchemaMigration):
}
}
complete_apps = ['course_action_state']
\ No newline at end of file
complete_apps = ['course_action_state']
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