DC MS DG; un-namespace single post JSON responses
This commit is contained in:
parent
34b9e1c7ca
commit
6e55d6c011
5 changed files with 12 additions and 21 deletions
|
|
@ -9,8 +9,7 @@ class PostPresenter
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_json(options = {})
|
def to_json(options = {})
|
||||||
{
|
self.post.as_api_response(:backbone).update(
|
||||||
:post => self.post.as_api_response(:backbone).update(
|
|
||||||
{
|
{
|
||||||
:user_like => self.user_like,
|
:user_like => self.user_like,
|
||||||
:user_participation => self.user_participation,
|
:user_participation => self.user_participation,
|
||||||
|
|
@ -23,10 +22,9 @@ class PostPresenter
|
||||||
:likes => self.likes,
|
:likes => self.likes,
|
||||||
:reshares => self.reshares,
|
:reshares => self.reshares,
|
||||||
:comments => self.comments,
|
:comments => self.comments,
|
||||||
:participations => self.participations
|
:participations => self.participations,
|
||||||
}),
|
|
||||||
:templateName => template_name
|
:templateName => template_name
|
||||||
}
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
def comments
|
def comments
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ app.models.Post = Backbone.Model.extend({
|
||||||
follow : function() {
|
follow : function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.participations.create({}, {success : function(resp){
|
this.participations.create({}, {success : function(resp){
|
||||||
self.set(resp.attributes.post)
|
self.set(resp)
|
||||||
self.trigger('interacted', self)
|
self.trigger('interacted', self)
|
||||||
}});
|
}});
|
||||||
},
|
},
|
||||||
|
|
@ -51,7 +51,7 @@ app.models.Post = Backbone.Model.extend({
|
||||||
participationModel.url = this.participations.url + "/" + participationModel.id;
|
participationModel.url = this.participations.url + "/" + participationModel.id;
|
||||||
|
|
||||||
participationModel.destroy({success : function(model, resp){
|
participationModel.destroy({success : function(model, resp){
|
||||||
self.set(resp.post);
|
self.set(resp);
|
||||||
self.trigger('interacted', this)
|
self.trigger('interacted', this)
|
||||||
}});
|
}});
|
||||||
},
|
},
|
||||||
|
|
@ -68,7 +68,7 @@ app.models.Post = Backbone.Model.extend({
|
||||||
like : function() {
|
like : function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.likes.create({}, {success : function(resp){
|
this.likes.create({}, {success : function(resp){
|
||||||
self.set(resp.get("post"))
|
self.set(resp)
|
||||||
self.trigger('interacted', self)
|
self.trigger('interacted', self)
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ app.models.Post = Backbone.Model.extend({
|
||||||
likeModel.url = this.likes.url + "/" + likeModel.id;
|
likeModel.url = this.likes.url + "/" + likeModel.id;
|
||||||
|
|
||||||
likeModel.destroy({success : function(model, resp) {
|
likeModel.destroy({success : function(model, resp) {
|
||||||
self.set(resp.post);
|
self.set(resp);
|
||||||
self.trigger('interacted', this)
|
self.trigger('interacted', this)
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,5 @@ app.models.Reshare = app.models.Post.extend({
|
||||||
|
|
||||||
reshareAuthor : function(){
|
reshareAuthor : function(){
|
||||||
return this.rootPost().reshareAuthor()
|
return this.rootPost().reshareAuthor()
|
||||||
},
|
|
||||||
|
|
||||||
parse: function(resp){
|
|
||||||
return resp.post
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,11 @@ app.pages.PostViewer = app.views.Base.extend({
|
||||||
this.authorView = new app.views.PostViewerAuthor({ model : this.model });
|
this.authorView = new app.views.PostViewerAuthor({ model : this.model });
|
||||||
this.interactionsView = new app.views.PostViewerInteractions({ model : this.model });
|
this.interactionsView = new app.views.PostViewerInteractions({ model : this.model });
|
||||||
this.navView = new app.views.PostViewerNav({ model : this.model });
|
this.navView = new app.views.PostViewerNav({ model : this.model });
|
||||||
|
|
||||||
this.postView = new app.views.Post({
|
this.postView = new app.views.Post({
|
||||||
model : this.model,
|
model : this.model,
|
||||||
className : this.options.postTemplateName + " post loaded",
|
className : this.model.get("templateName") + " post loaded",
|
||||||
templateName : "post-viewer/content/" + this.options.postTemplateName,
|
templateName : "post-viewer/content/" + this.model.get("templateName"),
|
||||||
attributes : {"data-template" : this.options.postTemplateName}
|
attributes : {"data-template" : this.model.get("templateName")}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,9 @@ app.Router = Backbone.Router.extend({
|
||||||
|
|
||||||
singlePost : function(id) {
|
singlePost : function(id) {
|
||||||
new app.models.Post({id : id}).fetch({success : function(resp){
|
new app.models.Post({id : id}).fetch({success : function(resp){
|
||||||
var postAttrs = resp.get("post");
|
|
||||||
|
|
||||||
var page = new app.pages.PostViewer({
|
var page = new app.pages.PostViewer({
|
||||||
model : new app.models.Post(postAttrs),
|
model : new app.models.Post(resp)
|
||||||
postTemplateName : resp.get("templateName")
|
|
||||||
}).render();
|
}).render();
|
||||||
|
|
||||||
$("#container").html(page.el);
|
$("#container").html(page.el);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue