Commit 22a7735a by David Baumgold

Added parse functions to handle backend representation of textbooks

parent 9e5df7e2
......@@ -45,6 +45,17 @@ CMS.Models.Textbook = Backbone.AssociatedModel.extend({
}],
isEmpty: function() {
return !this.get('name') && this.get('chapters').isEmpty();
},
parse: function(response) {
if("tab_title" in response && !("name" in response)) {
response.name = response.tab_title;
delete response.tab_title;
}
if("url" in response && !("chapters" in response)) {
response.chapters = {"url": response.url};
delete response.url;
}
return response;
}
})
CMS.Views.TextbookShow = Backbone.View.extend({
......@@ -207,6 +218,17 @@ CMS.Models.Chapter = Backbone.AssociatedModel.extend({
},
isEmpty: function() {
return !this.get('name') && !this.get('asset_path');
},
parse: function(response) {
if("title" in response && !("name" in response)) {
response.name = response.title;
delete response.title;
}
if("url" in response && !("asset_path" in response)) {
response.asset_path = response.url;
delete response.url;
}
return response;
}
})
CMS.Collections.ChapterSet = Backbone.Collection.extend({
......
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