From a3eeb9f3c1ffac55b59935d77d2d71ad99f91235 Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Tue, 4 Oct 2011 17:55:48 -0700 Subject: [PATCH] comment on tagged posts wip --- app/controllers/tag_followings_controller.rb | 1 - app/views/comments/create.js.erb | 2 +- lib/stream/tag_stream.rb | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/tag_followings_controller.rb b/app/controllers/tag_followings_controller.rb index 4992554e0..1ec4d11ed 100644 --- a/app/controllers/tag_followings_controller.rb +++ b/app/controllers/tag_followings_controller.rb @@ -9,7 +9,6 @@ class TagFollowingsController < ApplicationController before_filter :save_sort_order, :only => :index def index - @commenting_disabled = true @stream = TagStream.new(current_user, :max_time => params[:max_time], :order => sort_order) if params[:only_posts] render :partial => 'shared/stream', :locals => {:posts => @stream.posts} diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index 96650cf8b..e9840a2f2 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -1,3 +1,3 @@ ContentUpdater.addCommentToPost("<%= @comment.post.guid %>", "<%= @comment.guid%>", - "<%= escape_javascript(render(:partial => 'comments/comment', :locals => { :comment => @comment, :person => current_user.person}))%>"); \ No newline at end of file + "<%= escape_javascript(render(:partial => 'comments/comment', :locals => { :comment => @comment, :person => current_user.person, :post => @comment.post}))%>"); diff --git a/lib/stream/tag_stream.rb b/lib/stream/tag_stream.rb index 3a96d8287..fcec4e473 100644 --- a/lib/stream/tag_stream.rb +++ b/lib/stream/tag_stream.rb @@ -28,14 +28,15 @@ class TagStream < BaseStream I18n.translate('streams.tags.contacts_title') end - def can_comment_on?(post) + def can_comment?(post) @can_comment_cache ||= {} @can_comment_cache[post.id] ||= contacts_in_stream.find{|contact| contact.person_id == post.author.id}.present? + @can_comment_cache[post.id] ||= user.person.id == post.author.id @can_comment_cache[post.id] end def contacts_in_stream - @contacts_in_stream ||= Contact.where(:user => user, :person => people).all + @contacts_in_stream ||= Contact.where(:user_id => user.id, :person_id => people.map{|x| x.id}).all end private