PDF Textbooks: fetch/save individual textbooks

Created a few RESTful API endpoints, which required creating and assigning
arbitrary IDs to PDF textbooks. Changed the Backbone views to save individual
models, instead of saving a whole collection.
This commit is contained in:
David Baumgold
2013-06-25 16:03:27 -04:00
parent 27e895393c
commit 77ae9a6a78
6 changed files with 143 additions and 14 deletions

View File

@@ -16,6 +16,13 @@ CMS.Models.Textbook = Backbone.AssociatedModel.extend({
isEmpty: function() {
return !this.get('name') && this.get('chapters').isEmpty();
},
url: function() {
if(this.isNew()) {
return CMS.URL.TEXTBOOK + "/new";
} else {
return CMS.URL.TEXTBOOK + "/" + this.id;
}
},
parse: function(response) {
var ret = $.extend(true, {}, response);
if("tab_title" in ret && !("name" in ret)) {