Commit 06f40019 by David Baumgold

Use window.course instead of window.section

parent 0d349037
define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js/models/section", define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js/models/course",
"js/collections/textbook", "js/views/show_textbook", "js/views/edit_textbook", "js/views/list_textbooks", "js/collections/textbook", "js/views/show_textbook", "js/views/edit_textbook", "js/views/list_textbooks",
"js/views/edit_chapter", "js/views/feedback_prompt", "js/views/feedback_notification", "js/views/edit_chapter", "js/views/feedback_prompt", "js/views/feedback_notification",
"sinon", "jasmine-stealth"], "sinon", "jasmine-stealth"],
(Textbook, Chapter, ChapterSet, Section, TextbookSet, ShowTextbook, EditTextbook, ListTexbook, EditChapter, Prompt, Notification, sinon) -> (Textbook, Chapter, ChapterSet, Course, TextbookSet, ShowTextbook, EditTextbook, ListTexbook, EditChapter, Prompt, Notification, sinon) ->
feedbackTpl = readFixtures('system-feedback.underscore') feedbackTpl = readFixtures('system-feedback.underscore')
beforeEach -> beforeEach ->
...@@ -30,7 +30,7 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js ...@@ -30,7 +30,7 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js
@promptSpies = spyOnConstructor(Prompt, "Warning", ["show", "hide"]) @promptSpies = spyOnConstructor(Prompt, "Warning", ["show", "hide"])
@promptSpies.show.andReturn(@promptSpies) @promptSpies.show.andReturn(@promptSpies)
window.section = new Section({ window.course = new Course({
id: "5", id: "5",
name: "Course Name", name: "Course Name",
url_name: "course_name", url_name: "course_name",
...@@ -40,7 +40,7 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js ...@@ -40,7 +40,7 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js
}); });
afterEach -> afterEach ->
delete window.section delete window.course
describe "Basic", -> describe "Basic", ->
it "should render properly", -> it "should render properly", ->
...@@ -285,11 +285,11 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js ...@@ -285,11 +285,11 @@ define ["js/models/textbook", "js/models/chapter", "js/collections/chapter", "js
@view = new EditChapter({model: @model}) @view = new EditChapter({model: @model})
spyOn(@view, "remove").andCallThrough() spyOn(@view, "remove").andCallThrough()
CMS.URL.UPLOAD_ASSET = "/upload" CMS.URL.UPLOAD_ASSET = "/upload"
window.section = new Section({name: "abcde"}) window.course = new Course({name: "abcde"})
afterEach -> afterEach ->
delete CMS.URL.UPLOAD_ASSET delete CMS.URL.UPLOAD_ASSET
delete window.section delete window.course
it "can render", -> it "can render", ->
@view.render() @view.render()
......
...@@ -53,7 +53,7 @@ define(["backbone", "underscore", "underscore.string", "jquery", "gettext", "js/ ...@@ -53,7 +53,7 @@ define(["backbone", "underscore", "underscore.string", "jquery", "gettext", "js/
}); });
var msg = new FileUploadModel({ var msg = new FileUploadModel({
title: _.template(gettext("Upload a new PDF to “<%= name %>”"), title: _.template(gettext("Upload a new PDF to “<%= name %>”"),
{name: section.escape('name')}), {name: course.escape('name')}),
message: "Files must be in PDF format.", message: "Files must be in PDF format.",
mimeTypes: ['application/pdf'] mimeTypes: ['application/pdf']
}); });
......
...@@ -16,7 +16,7 @@ define(["backbone", "underscore", "gettext", "js/views/feedback_notification", " ...@@ -16,7 +16,7 @@ define(["backbone", "underscore", "gettext", "js/views/feedback_notification", "
render: function() { render: function() {
var attrs = $.extend({}, this.model.attributes); var attrs = $.extend({}, this.model.attributes);
attrs.bookindex = this.model.collection.indexOf(this.model); attrs.bookindex = this.model.collection.indexOf(this.model);
attrs.course = window.section.attributes; attrs.course = window.course.attributes;
this.$el.html(this.template(attrs)); this.$el.html(this.template(attrs));
return this; return this;
}, },
......
...@@ -23,13 +23,6 @@ CMS.URL.TEXTBOOKS = "${textbook_url}" ...@@ -23,13 +23,6 @@ CMS.URL.TEXTBOOKS = "${textbook_url}"
CMS.URL.LMS_BASE = "${settings.LMS_BASE}" CMS.URL.LMS_BASE = "${settings.LMS_BASE}"
require(["js/models/section", "js/collections/textbook", "js/views/list_textbooks"], require(["js/models/section", "js/collections/textbook", "js/views/list_textbooks"],
function(Section, TextbookCollection, ListTextbooksView) { function(Section, TextbookCollection, ListTextbooksView) {
window.section = new Section({
name: "${course.display_name_with_default | h}",
url_name: "${course.location.name | h}",
org: "${course.location.org | h}",
num: "${course.location.course | h}",
revision: "${course.location.revision | h}"
});
var textbooks = new TextbookCollection(${json.dumps(course.pdf_textbooks)}, {parse: true}); var textbooks = new TextbookCollection(${json.dumps(course.pdf_textbooks)}, {parse: true});
var tbView = new ListTextbooksView({collection: textbooks}); var tbView = new ListTextbooksView({collection: textbooks});
......
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