Skip to content
Extraits de code Groupes Projets
Valider 2162a2e3 rédigé par maxwell's avatar maxwell
Parcourir les fichiers

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

parent 26e1cfe9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -15,10 +15,10 @@ class PeopleController < ApplicationController
end
def show
@aspect = :profile
@person = Person.find(params[:id].to_id)
@post_type = :all
if @person
@profile = @person.profile
@contact = current_user.contact_for(@person)
......@@ -31,7 +31,9 @@ class PeopleController < ApplicationController
end
@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
flash[:error] = I18n.t 'people.show.does_not_exist'
redirect_to people_path
......
......@@ -9,16 +9,28 @@ class PhotosController < ApplicationController
respond_to :json, :only => :show
def index
if params[:person_id]
@person = current_user.contact_for_person_id(params[:person_id])
@person = @person.person if @person
@aspect = :profile
@post_type = :photos
@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 => 'Photo', :person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC'
render 'people/show'
else
@person = current_user.person
flash[:error] = I18n.t 'people.show.does_not_exist'
redirect_to people_path
end
@photos = current_user.visible_posts(:_type => "Photo", :person_id => @person.id)
@aspect = :photos
end
def create
......@@ -85,7 +97,7 @@ class PhotosController < ApplicationController
if @photo = current_user.my_posts.where(:_id => params[:id]).first
respond_with @photo
else
redirect_to photos_path
redirect_to person_photos_path(current_user.person)
end
end
......@@ -100,7 +112,7 @@ class PhotosController < ApplicationController
redirect_to [:edit, photo]
end
else
redirect_to photos_path
redirect_to person_photos_path(current_user.person)
end
end
......
......@@ -21,6 +21,33 @@ class StatusMessagesController < ApplicationController
render :nothing => true
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
@status_message = current_user.my_posts.where(:_id => params[:id]).first
if @status_message
......
......@@ -4,14 +4,17 @@
.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
= render 'shared/author_info', :person => @person
- if @contact || current_user.person == @person
- if @posts.count > 0
= render 'shared/stream', :posts => @posts
-if @post_type == :photos
= render 'photos/index', :photos => @posts
- else
= render 'shared/stream', :posts => @posts
= will_paginate @posts
- else
......
......@@ -2,26 +2,22 @@
-# 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)
=content_for(:head) do
:javascript
$(document).ready(function(){
$(".image_thumb img").load( function() {
$(this).fadeIn("slow");
});
});
.span-24.last
#thumbnails
- for photo in @photos
- 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
/.span-24.last
/ #add_photo_pane
/ = render "photos/new_photo", :aspect_id => :all
......@@ -15,4 +15,4 @@
#person_nav_links
= link_to t('.view_profile'), person_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)
-# 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
......@@ -7,9 +7,15 @@ Diaspora::Application.routes.draw do
resources :status_messages, :only => [:create, :destroy, :show]
resources :comments, :except => [:index]
resources :requests, :except => [:edit, :update]
resources :photos
resources :photos, :except => [:index]
resources :services
resources :people do
resources :status_messages
resources :photos
end
match '/auth/:provider/callback' => 'services#create'
devise_for :users, :controllers => {:registrations => "registrations",
......
......@@ -36,21 +36,21 @@ describe PhotosController do
describe '#index' 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[:photos].should == [photo]
assigns[:posts].should == [photo]
end
it 'sets the person to a friend if person_id is set' do
get :index, :person_id => user2.person.id.to_s
assigns[:person].should == user2.person
assigns[:photos].should == []
assigns[:posts].should == []
end
it 'sets the aspect to photos?' do
get :index
assigns[:aspect].should == :photos
it 'sets the aspect to profile' do
get :index, :person_id => user.person.id.to_s
assigns[:aspect].should == :profile
end
end
......@@ -73,7 +73,7 @@ describe PhotosController do
it 'should not let you edit a photo that is not yours' do
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
......@@ -106,7 +106,8 @@ describe PhotosController do
it 'should redirect if you do not have access to the post' do
params = { :caption => "now with lasers!"}
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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter