don't show new comment form on a non-contact's post

This commit is contained in:
danielvincent 2010-12-08 18:23:30 -08:00
parent faf27fe05a
commit cdd225c076
5 changed files with 15 additions and 9 deletions

View file

@ -43,7 +43,7 @@ class PeopleController < ApplicationController
def show def show
@person = Person.find(params[:id].to_id) @person = Person.find(params[:id].to_id)
@post_type = :all @post_type = :all
@aspect = :none
if @person if @person
@profile = @person.profile @profile = @person.profile
@contact = current_user.contact_for(@person) @contact = current_user.contact_for(@person)
@ -53,6 +53,8 @@ class PeopleController < ApplicationController
@aspects_with_person = @contact.aspects @aspects_with_person = @contact.aspects
end end
@commenting_disabled = !@contact
@posts = current_user.posts_from(@person).paginate :page => params[:page] @posts = current_user.posts_from(@person).paginate :page => params[:page]
@post_hashes = hashes_for_posts @posts @post_hashes = hashes_for_posts @posts

View file

@ -4,9 +4,11 @@
module StreamHelper module StreamHelper
GSUB_THIS = "FIUSDHVIUSHDVIUBAIUHAPOIUXJM" GSUB_THIS = "FIUSDHVIUSHDVIUBAIUHAPOIUXJM"
def comment_toggle(count) def comment_toggle(count, commenting_disabled=false)
if count == 0 if count == 0
link_to "#{t('comments.new_comment.comment').downcase}", '#', :class => "show_post_comments" unless commenting_disabled
link_to "#{t('comments.new_comment.comment').downcase}", '#', :class => "show_post_comments"
end
elsif count <= 3 elsif count <= 3
link_to "#{t('stream_helper.hide_comments')} (#{count})", '#', :class => "show_post_comments" link_to "#{t('stream_helper.hide_comments')} (#{count})", '#', :class => "show_post_comments"
else else

View file

@ -9,6 +9,8 @@
= render :partial => 'comments/comment', :collection => comment_hashes[-3, 3], :as => :hash = render :partial => 'comments/comment', :collection => comment_hashes[-3, 3], :as => :hash
-else -else
= render :partial => 'comments/comment', :collection => comment_hashes, :as => :hash = render :partial => 'comments/comment', :collection => comment_hashes, :as => :hash
%li.comment.show
= new_comment_form(post_id) - unless @commenting_disabled
%li.comment.show
= new_comment_form(post_id)

View file

@ -3,5 +3,5 @@
-# the COPYRIGHT file. -# the COPYRIGHT file.
%ul{:class => 'stream', :id => 'main_stream'} %ul{:class => 'stream', :id => 'main_stream'}
- for post_hash in @post_hashes - for post_hash in posts
= render 'shared/stream_element', post_hash.merge(:aspects => @aspects) = render 'shared/stream_element', post_hash.merge(:aspects => @aspects, :commenting_disabled => defined?(@commenting_disabled))

View file

@ -28,7 +28,7 @@
.info .info
%span.time= link_to(how_long_ago(post), status_message_path(post)) %span.time= link_to(how_long_ago(post), status_message_path(post))
= comment_toggle(comments.length) = comment_toggle(comments.length, defined?(@commenting_disabled))
= render "comments/comments", :post_id => post.id, :comment_hashes => comments, :condensed => true = render "comments/comments", :post_id => post.id, :comment_hashes => comments, :condensed => true, :commenting_disabled => defined?(@commenting_disabled)