Make people pages publicly accessible
This commit is contained in:
parent
7b0a354677
commit
ddbd5febb3
6 changed files with 50 additions and 24 deletions
|
|
@ -86,10 +86,10 @@ class AspectsController < ApplicationController
|
|||
begin
|
||||
current_user.drop_aspect @aspect
|
||||
flash[:notice] = I18n.t 'aspects.destroy.success',:name => @aspect.name
|
||||
redirect_to :back
|
||||
redirect_to aspects_path
|
||||
rescue ActiveRecord::StatementInvalid => e
|
||||
flash[:error] = I18n.t 'aspects.destroy.failure',:name => @aspect.name
|
||||
redirect_to :back
|
||||
redirect_to aspects_path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class PeopleController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
before_filter :authenticate_user!, :except => [:show]
|
||||
|
||||
respond_to :html
|
||||
respond_to :json, :only => [:index, :show]
|
||||
|
|
@ -48,27 +48,32 @@ class PeopleController < ApplicationController
|
|||
@share_with = (params[:share_with] == 'true')
|
||||
|
||||
if @person
|
||||
@incoming_request = current_user.request_from(@person)
|
||||
|
||||
@profile = @person.profile
|
||||
@contact = current_user.contact_for(@person)
|
||||
@aspects_with_person = []
|
||||
|
||||
if @contact
|
||||
@aspects_with_person = @contact.aspects
|
||||
@contacts_of_contact = @contact.contacts
|
||||
if current_user
|
||||
@incoming_request = current_user.request_from(@person)
|
||||
@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
|
||||
@contact ||= Contact.new
|
||||
@contacts_of_contact = []
|
||||
end
|
||||
|
||||
if (@person != current_user.person) && (!@contact || @contact.pending)
|
||||
@commenting_disabled = true
|
||||
else
|
||||
@commenting_disabled = false
|
||||
@posts = @person.posts.where(:type => "StatusMessage", :public => true).paginate(:per_page => 15, :page => params[:page])
|
||||
end
|
||||
|
||||
@posts = current_user.posts_from(@person).where(:type => "StatusMessage").paginate :per_page => 15, :page => params[:page]
|
||||
@fakes = PostsFake.new(@posts)
|
||||
respond_with @person, :locals => {:post_type => :all}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@
|
|||
.profile_photo
|
||||
= person_image_link(person, :size => :thumb_large, :to => :photos)
|
||||
|
||||
- if person == current_user.person
|
||||
- if user_signed_in? && person == current_user.person
|
||||
%p
|
||||
= link_to t('people.profile_sidebar.edit_my_profile'), edit_profile_path
|
||||
|
||||
%hr{:style=>"width:300px;"}
|
||||
|
||||
%ul
|
||||
- unless person == current_user.person
|
||||
- if user_signed_in? && person != current_user.person
|
||||
%li
|
||||
= render :partial => 'people/aspect_list',
|
||||
:locals => {:person => person,
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
%br
|
||||
%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
|
||||
%li
|
||||
- unless person.profile.bio.blank?
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
.span-8.append-1.last
|
||||
= 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
|
||||
%hr{:style=>"width:300px;"}
|
||||
.section.contact_pictures
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
.span-15.last
|
||||
#author_info
|
||||
- unless @contact.persisted? || current_user.person == @person
|
||||
- if user_signed_in? && !(@contact.persisted? || current_user.person == @person)
|
||||
.right
|
||||
- if @incoming_request
|
||||
= link_to t('.incoming_request', :name => truncate(@person.name, :length => 20, :separator => ' ', :omission => '')),
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
|
||||
- else
|
||||
- if @contact.person
|
||||
- if user_signed_in? && @contact.person
|
||||
.right
|
||||
= link_to t('.message'), new_conversation_path(:contact_id => @contact.id, :name => @contact.person.name, :contact_id => @contact.id), :class => 'button', :rel => 'facebox'
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
-# the COPYRIGHT file.
|
||||
|
||||
.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
|
||||
- reshare_aspects = aspects_without_post(all_aspects, post)
|
||||
- unless reshare_aspects.empty?
|
||||
|
|
|
|||
|
|
@ -129,6 +129,27 @@ describe PeopleController do
|
|||
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
|
||||
before do
|
||||
@person = bob.person
|
||||
|
|
|
|||
Loading…
Reference in a new issue