Make people pages publicly accessible

This commit is contained in:
Raphael Sofaer 2011-03-10 12:30:14 -08:00
parent 7b0a354677
commit ddbd5febb3
6 changed files with 50 additions and 24 deletions

View file

@ -86,10 +86,10 @@ class AspectsController < ApplicationController
begin begin
current_user.drop_aspect @aspect current_user.drop_aspect @aspect
flash[:notice] = I18n.t 'aspects.destroy.success',:name => @aspect.name flash[:notice] = I18n.t 'aspects.destroy.success',:name => @aspect.name
redirect_to :back redirect_to aspects_path
rescue ActiveRecord::StatementInvalid => e rescue ActiveRecord::StatementInvalid => e
flash[:error] = I18n.t 'aspects.destroy.failure',:name => @aspect.name flash[:error] = I18n.t 'aspects.destroy.failure',:name => @aspect.name
redirect_to :back redirect_to aspects_path
end end
end end

View file

@ -3,7 +3,7 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class PeopleController < ApplicationController class PeopleController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!, :except => [:show]
respond_to :html respond_to :html
respond_to :json, :only => [:index, :show] respond_to :json, :only => [:index, :show]
@ -48,27 +48,32 @@ class PeopleController < ApplicationController
@share_with = (params[:share_with] == 'true') @share_with = (params[:share_with] == 'true')
if @person if @person
@incoming_request = current_user.request_from(@person)
@profile = @person.profile @profile = @person.profile
@contact = current_user.contact_for(@person)
@aspects_with_person = []
if @contact if current_user
@aspects_with_person = @contact.aspects @incoming_request = current_user.request_from(@person)
@contacts_of_contact = @contact.contacts @contact = current_user.contact_for(@person)
@aspects_with_person = []
if @contact
@aspects_with_person = @contact.aspects
@contacts_of_contact = @contact.contacts
else
@contact ||= Contact.new
@contacts_of_contact = []
end
if (@person != current_user.person) && (!@contact || @contact.pending)
@commenting_disabled = true
else
@commenting_disabled = false
end
@posts = current_user.posts_from(@person).where(:type => "StatusMessage").paginate(:per_page => 15, :page => params[:page])
else else
@contact ||= Contact.new
@contacts_of_contact = []
end
if (@person != current_user.person) && (!@contact || @contact.pending)
@commenting_disabled = true @commenting_disabled = true
else @posts = @person.posts.where(:type => "StatusMessage", :public => true).paginate(:per_page => 15, :page => params[:page])
@commenting_disabled = false
end end
@posts = current_user.posts_from(@person).where(:type => "StatusMessage").paginate :per_page => 15, :page => params[:page]
@fakes = PostsFake.new(@posts) @fakes = PostsFake.new(@posts)
respond_with @person, :locals => {:post_type => :all} respond_with @person, :locals => {:post_type => :all}

View file

@ -18,14 +18,14 @@
.profile_photo .profile_photo
= person_image_link(person, :size => :thumb_large, :to => :photos) = person_image_link(person, :size => :thumb_large, :to => :photos)
- if person == current_user.person - if user_signed_in? && person == current_user.person
%p %p
= link_to t('people.profile_sidebar.edit_my_profile'), edit_profile_path = link_to t('people.profile_sidebar.edit_my_profile'), edit_profile_path
%hr{:style=>"width:300px;"} %hr{:style=>"width:300px;"}
%ul %ul
- unless person == current_user.person - if user_signed_in? && person != current_user.person
%li %li
= render :partial => 'people/aspect_list', = render :partial => 'people/aspect_list',
:locals => {:person => person, :locals => {:person => person,
@ -35,7 +35,7 @@
%br %br
%hr{:style=>"width:300px;"} %hr{:style=>"width:300px;"}
-if (contact.persisted? && !contact.pending?) || person == current_user.person || @incoming_request -if user_signed_in? && ((contact.persisted? && !contact.pending?) || person == current_user.person || @incoming_request)
%ul#profile_information %ul#profile_information
%li %li
- unless person.profile.bio.blank? - unless person.profile.bio.blank?

View file

@ -12,7 +12,7 @@
.span-8.append-1.last .span-8.append-1.last
= render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact } = render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact }
- if @contact.persisted? && @contacts_of_contact.count > 0 - if user_signed_in? && @contact.persisted? && @contacts_of_contact.count > 0
.span-8.last .span-8.last
%hr{:style=>"width:300px;"} %hr{:style=>"width:300px;"}
.section.contact_pictures .section.contact_pictures
@ -24,7 +24,7 @@
.span-15.last .span-15.last
#author_info #author_info
- unless @contact.persisted? || current_user.person == @person - if user_signed_in? && !(@contact.persisted? || current_user.person == @person)
.right .right
- if @incoming_request - if @incoming_request
= link_to t('.incoming_request', :name => truncate(@person.name, :length => 20, :separator => ' ', :omission => '')), = link_to t('.incoming_request', :name => truncate(@person.name, :length => 20, :separator => ' ', :omission => '')),
@ -45,7 +45,7 @@
- else - else
- if @contact.person - if user_signed_in? && @contact.person
.right .right
= link_to t('.message'), new_conversation_path(:contact_id => @contact.id, :name => @contact.person.name, :contact_id => @contact.id), :class => 'button', :rel => 'facebox' = link_to t('.message'), new_conversation_path(:contact_id => @contact.id, :name => @contact.person.name, :contact_id => @contact.id), :class => 'button', :rel => 'facebox'

View file

@ -3,7 +3,7 @@
-# the COPYRIGHT file. -# the COPYRIGHT file.
.stream_element{:data=>{:guid=>post.id}} .stream_element{:data=>{:guid=>post.id}}
- if post.author.owner_id == current_user.id - if current_user && post.author.owner_id == current_user.id
.right.hidden.controls .right.hidden.controls
- reshare_aspects = aspects_without_post(all_aspects, post) - reshare_aspects = aspects_without_post(all_aspects, post)
- unless reshare_aspects.empty? - unless reshare_aspects.empty?

View file

@ -129,6 +129,27 @@ describe PeopleController do
end end
end end
context "with no user signed in" do
before do
sign_out :user
@person = bob.person
end
it "succeeds" do
get :show, :id => @person.id
response.status.should == 200
end
it "assigns only public posts" do
public_posts = []
public_posts << bob.post(:status_message, :message => "first public ", :to => bob.aspects[0].id, :public => true)
bob.post(:status_message, :message => "to an aspect @user is not in", :to => bob.aspects[1].id)
bob.post(:status_message, :message => "to all aspects", :to => 'all')
public_posts << bob.post(:status_message, :message => "public", :to => 'all', :public => true)
get :show, :id => @person.id
assigns[:posts].should == public_posts
end
end
context "when the person is a contact of the current user" do context "when the person is a contact of the current user" do
before do before do
@person = bob.person @person = bob.person