Skip to content
Snippets Groups Projects
Commit cd274cad authored by Maxwell Salzberg's avatar Maxwell Salzberg
Browse files

adding likes, reshares and comments in a naive presenter way

parent 7755c254
No related branches found
No related tags found
No related merge requests found
......@@ -19,12 +19,27 @@ class PostPresenter
:reshares_count => self.post.reshares.count,
:user_reshare => self.user_reshare,
:next_post => self.next_post_path,
:previous_post => self.previous_post_path
:previous_post => self.previous_post_path,
:likes => self.likes,
:reshares => self.reshares,
:comments => self.comments
}),
:templateName => template_name
}
end
def comments
as_api(post.comments)
end
def likes
as_api(post.likes)
end
def reshares
as_api(post.reshares)
end
def user_like
return unless user_signed_in?
if like = post.likes.where(:author_id => person.id).first
......@@ -70,6 +85,12 @@ class PostPresenter
protected
def as_api(collection)
collection.includes(:author => :profile).all.map do |element|
element.as_api_response(:backbone)
end
end
def post_base
if current_user
current_user.posts_from(self.post.author)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment