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
|
||||
|
||||
def to_json(options = {})
|
||||
{
|
||||
:post => self.post.as_api_response(:backbone).update(
|
||||
self.post.as_api_response(:backbone).update(
|
||||
{
|
||||
:user_like => self.user_like,
|
||||
:user_participation => self.user_participation,
|
||||
|
|
@ -23,10 +22,9 @@ class PostPresenter
|
|||
:likes => self.likes,
|
||||
:reshares => self.reshares,
|
||||
:comments => self.comments,
|
||||
:participations => self.participations
|
||||
}),
|
||||
:templateName => template_name
|
||||
}
|
||||
:participations => self.participations,
|
||||
:templateName => template_name
|
||||
})
|
||||
end
|
||||
|
||||
def comments
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ app.models.Post = Backbone.Model.extend({
|
|||
follow : function() {
|
||||
var self = this;
|
||||
this.participations.create({}, {success : function(resp){
|
||||
self.set(resp.attributes.post)
|
||||
self.set(resp)
|
||||
self.trigger('interacted', self)
|
||||
}});
|
||||
},
|
||||
|
|
@ -51,7 +51,7 @@ app.models.Post = Backbone.Model.extend({
|
|||
participationModel.url = this.participations.url + "/" + participationModel.id;
|
||||
|
||||
participationModel.destroy({success : function(model, resp){
|
||||
self.set(resp.post);
|
||||
self.set(resp);
|
||||
self.trigger('interacted', this)
|
||||
}});
|
||||
},
|
||||
|
|
@ -68,7 +68,7 @@ app.models.Post = Backbone.Model.extend({
|
|||
like : function() {
|
||||
var self = this;
|
||||
this.likes.create({}, {success : function(resp){
|
||||
self.set(resp.get("post"))
|
||||
self.set(resp)
|
||||
self.trigger('interacted', self)
|
||||
}});
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ app.models.Post = Backbone.Model.extend({
|
|||
likeModel.url = this.likes.url + "/" + likeModel.id;
|
||||
|
||||
likeModel.destroy({success : function(model, resp) {
|
||||
self.set(resp.post);
|
||||
self.set(resp);
|
||||
self.trigger('interacted', this)
|
||||
}});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,5 @@ app.models.Reshare = app.models.Post.extend({
|
|||
|
||||
reshareAuthor : function(){
|
||||
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.interactionsView = new app.views.PostViewerInteractions({ model : this.model });
|
||||
this.navView = new app.views.PostViewerNav({ model : this.model });
|
||||
|
||||
this.postView = new app.views.Post({
|
||||
model : this.model,
|
||||
className : this.options.postTemplateName + " post loaded",
|
||||
templateName : "post-viewer/content/" + this.options.postTemplateName,
|
||||
attributes : {"data-template" : this.options.postTemplateName}
|
||||
className : this.model.get("templateName") + " post loaded",
|
||||
templateName : "post-viewer/content/" + this.model.get("templateName"),
|
||||
attributes : {"data-template" : this.model.get("templateName")}
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -40,11 +40,9 @@ app.Router = Backbone.Router.extend({
|
|||
|
||||
singlePost : function(id) {
|
||||
new app.models.Post({id : id}).fetch({success : function(resp){
|
||||
var postAttrs = resp.get("post");
|
||||
|
||||
var page = new app.pages.PostViewer({
|
||||
model : new app.models.Post(postAttrs),
|
||||
postTemplateName : resp.get("templateName")
|
||||
model : new app.models.Post(resp)
|
||||
}).render();
|
||||
|
||||
$("#container").html(page.el);
|
||||
|
|
|
|||
Loading…
Reference in a new issue