collapse person's photos and status message into their profile; also, made these nested on a person

This commit is contained in:
maxwell 2010-11-08 15:55:58 -08:00
parent 26e1cfe955
commit 2162a2e3f9
11 changed files with 100 additions and 66 deletions

View file

@ -15,9 +15,9 @@ class PeopleController < ApplicationController
end end
def show def show
@aspect = :profile
@person = Person.find(params[:id].to_id) @person = Person.find(params[:id].to_id)
@post_type = :all
if @person if @person
@profile = @person.profile @profile = @person.profile
@ -31,7 +31,9 @@ class PeopleController < ApplicationController
end end
@posts = current_user.visible_posts(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC' @posts = current_user.visible_posts(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC'
respond_with @person respond_with @person, :locals => {:post_type => :all}
else else
flash[:error] = I18n.t 'people.show.does_not_exist' flash[:error] = I18n.t 'people.show.does_not_exist'
redirect_to people_path redirect_to people_path

View file

@ -9,16 +9,28 @@ class PhotosController < ApplicationController
respond_to :json, :only => :show respond_to :json, :only => :show
def index def index
if params[:person_id] @aspect = :profile
@person = current_user.contact_for_person_id(params[:person_id]) @post_type = :photos
@person = @person.person if @person @person = Person.find(params[:person_id].to_id)
if @person
@profile = @person.profile
@contact = current_user.contact_for(@person)
@is_contact = @person != current_user.person && @contact
if @contact
@aspects_with_person = @contact.aspects
else else
@person = current_user.person @pending_request = current_user.pending_requests.find_by_person_id(@person.id)
end end
@photos = current_user.visible_posts(:_type => "Photo", :person_id => @person.id) @posts = current_user.visible_posts(:_type => 'Photo', :person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC'
render 'people/show'
@aspect = :photos else
flash[:error] = I18n.t 'people.show.does_not_exist'
redirect_to people_path
end
end end
def create def create
@ -85,7 +97,7 @@ class PhotosController < ApplicationController
if @photo = current_user.my_posts.where(:_id => params[:id]).first if @photo = current_user.my_posts.where(:_id => params[:id]).first
respond_with @photo respond_with @photo
else else
redirect_to photos_path redirect_to person_photos_path(current_user.person)
end end
end end
@ -100,7 +112,7 @@ class PhotosController < ApplicationController
redirect_to [:edit, photo] redirect_to [:edit, photo]
end end
else else
redirect_to photos_path redirect_to person_photos_path(current_user.person)
end end
end end

View file

@ -21,6 +21,33 @@ class StatusMessagesController < ApplicationController
render :nothing => true render :nothing => true
end end
def index
@aspect = :profile
@post_type = :status_message
@person = Person.find(params[:person_id].to_id)
if @person
@profile = @person.profile
@contact = current_user.contact_for(@person)
@is_contact = @person != current_user.person && @contact
if @contact
@aspects_with_person = @contact.aspects
else
@pending_request = current_user.pending_requests.find_by_person_id(@person.id)
end
@posts = current_user.visible_posts(:_type => 'StatusMessage', :person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC'
render 'people/show'
else
flash[:error] = I18n.t 'people.show.does_not_exist'
redirect_to people_path
end
end
def destroy def destroy
@status_message = current_user.my_posts.where(:_id => params[:id]).first @status_message = current_user.my_posts.where(:_id => params[:id]).first
if @status_message if @status_message

View file

@ -4,13 +4,16 @@
.span-4.append-1.last .span-4.append-1.last
= render 'profile_sidebar', :person => @person, :is_contact => @is_contact = render :partial => 'people/profile_sidebar', :locals => {:person => @person, :is_contact => @is_contact}
.span-15.last .span-15.last
= render 'shared/author_info', :person => @person = render 'shared/author_info', :person => @person
- if @contact || current_user.person == @person - if @contact || current_user.person == @person
- if @posts.count > 0 - if @posts.count > 0
-if @post_type == :photos
= render 'photos/index', :photos => @posts
- else
= render 'shared/stream', :posts => @posts = render 'shared/stream', :posts => @posts
= will_paginate @posts = will_paginate @posts

View file

@ -0,0 +1,23 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
=content_for(:head) do
:javascript
$(document).ready(function(){
$(".image_thumb img").load( function() {
$(this).fadeIn("slow");
});
});
.span-24.last
#thumbnails
- for photo in photos
.image_thumb
= link_to (image_tag photo.url(:thumb_medium)), photo_path(photo)
/.span-24.last
/ #add_photo_pane
/ = render "photos/new_photo", :aspect_id => :all

View file

@ -1,27 +0,0 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
:javascript
$(document).ready(function(){
$(".image_thumb img").load( function() {
$(this).fadeIn("slow");
});
});
.span-24.last{:style=>"position:relative;"}
= render 'shared/author_info', :person => @person
%ul#breadcrumb
%li= link_to "#{@person.profile.first_name}'s Photos", person_photos_path(@person)
.span-24.last
#thumbnails
- for photo in @photos
.image_thumb
= link_to (image_tag photo.url(:thumb_medium)), photo_path(photo)
.span-24.last
#add_photo_pane
= render "photos/new_photo", :aspect_id => :all

View file

@ -15,4 +15,4 @@
#person_nav_links #person_nav_links
= link_to t('.view_profile'), person_path(person) = link_to t('.view_profile'), person_path(person)
= link_to t('_photos'), person_photos_path(person) = link_to t('_photos'), person_photos_path(person)
= link_to 'status messages', person_photos_path(person) = link_to 'status messages', person_status_messages_path(person)

View file

@ -1,13 +0,0 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
%h1.big_text status messages
= render "status_messages/new_status_message", :status_message => @status_message
%ul#stream
- for status_message in @status_messages
= render "status_message", :post => status_message
#pagination
= will_paginate @status_messages

View file

@ -7,9 +7,15 @@ Diaspora::Application.routes.draw do
resources :status_messages, :only => [:create, :destroy, :show] resources :status_messages, :only => [:create, :destroy, :show]
resources :comments, :except => [:index] resources :comments, :except => [:index]
resources :requests, :except => [:edit, :update] resources :requests, :except => [:edit, :update]
resources :photos resources :photos, :except => [:index]
resources :services resources :services
resources :people do
resources :status_messages
resources :photos
end
match '/auth/:provider/callback' => 'services#create' match '/auth/:provider/callback' => 'services#create'
devise_for :users, :controllers => {:registrations => "registrations", devise_for :users, :controllers => {:registrations => "registrations",

View file

@ -36,21 +36,21 @@ describe PhotosController do
describe '#index' do describe '#index' do
it 'defaults to returning all of users pictures' do it 'defaults to returning all of users pictures' do
get :index get :index, :person_id => user.person.id.to_s
assigns[:person].should == user.person assigns[:person].should == user.person
assigns[:photos].should == [photo] assigns[:posts].should == [photo]
end end
it 'sets the person to a friend if person_id is set' do it 'sets the person to a friend if person_id is set' do
get :index, :person_id => user2.person.id.to_s get :index, :person_id => user2.person.id.to_s
assigns[:person].should == user2.person assigns[:person].should == user2.person
assigns[:photos].should == [] assigns[:posts].should == []
end end
it 'sets the aspect to photos?' do it 'sets the aspect to profile' do
get :index get :index, :person_id => user.person.id.to_s
assigns[:aspect].should == :photos assigns[:aspect].should == :profile
end end
end end
@ -73,7 +73,7 @@ describe PhotosController do
it 'should not let you edit a photo that is not yours' do it 'should not let you edit a photo that is not yours' do
get :edit, :id => photo2.id get :edit, :id => photo2.id
response.should redirect_to(:action => :index) response.should redirect_to(:action => :index, :person_id => user.person.id.to_s)
end end
end end
@ -106,7 +106,8 @@ describe PhotosController do
it 'should redirect if you do not have access to the post' do it 'should redirect if you do not have access to the post' do
params = { :caption => "now with lasers!"} params = { :caption => "now with lasers!"}
put :update, :id => photo2.id, :photo => params put :update, :id => photo2.id, :photo => params
response.should redirect_to(:action => :index) response.should redirect_to(:action => :index, :person_id => user.person.id.to_s)
end end
end end
end end