Refactor:

*people_controller#show
  *photos_controller#index
  *views/people/show both html and mobile
This commit is contained in:
Fabián Rodríguez 2013-02-06 19:14:48 -02:00
parent 19b9b0edb8
commit 7472642bd1
4 changed files with 5 additions and 29 deletions

View file

@ -82,27 +82,18 @@ class PeopleController < ApplicationController
@post_type = :all @post_type = :all
@aspect = :profile @aspect = :profile
@share_with = (params[:share_with] == 'true')
@stream = Stream::Person.new(current_user, @person, :max_time => max_time) @stream = Stream::Person.new(current_user, @person, :max_time => max_time)
@profile = @person.profile @profile = @person.profile
unless params[:format] == "json" # hovercard unless params[:format] == "json" # hovercard
if current_user if current_user
@block = current_user.blocks.where(:person_id => @person.id).first @block = current_user.blocks.where(:person_id => @person.id).first
@contact = current_user.contact_for(@person) @contact = current_user.contact_for(@person)
@aspects_with_person = []
if @contact && !params[:only_posts] if @contact && !params[:only_posts]
@aspects_with_person = @contact.aspects
@aspect_ids = @aspects_with_person.map(&:id)
@contacts_of_contact_count = @contact.contacts.count @contacts_of_contact_count = @contact.contacts.count
@contacts_of_contact = @contact.contacts.limit(8) @contacts_of_contact = @contact.contacts.limit(8)
else else
@contact ||= Contact.new @contact ||= Contact.new
@contacts_of_contact_count = 0
@contacts_of_contact = []
end end
end end
end end

View file

@ -12,19 +12,13 @@ class PhotosController < ApplicationController
@person = Person.find_by_guid(params[:person_id]) @person = Person.find_by_guid(params[:person_id])
if @person if @person
@profile = @person.profile
@contact = current_user.contact_for(@person) @contact = current_user.contact_for(@person)
@is_contact = @person != current_user.person && @contact
@aspects_with_person = []
if @contact if @contact
@aspects_with_person = @contact.aspects
@contacts_of_contact = @contact.contacts @contacts_of_contact = @contact.contacts
@contacts_of_contact_count = @contact.contacts.count @contacts_of_contact_count = @contact.contacts.count
else else
@contact = Contact.new @contact = Contact.new
@contacts_of_contact = []
@contacts_of_contact_count = 0
end end
@posts = current_user.photos_from(@person) @posts = current_user.photos_from(@person)

View file

@ -15,14 +15,14 @@
.span-6 .span-6
= render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact } = render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact }
- if user_signed_in? && @contact.persisted? && @contacts_of_contact.count > 0 - if user_signed_in? && @contact.persisted? && @contacts_of_contact_count > 0
.span-5.last#contacts_of_contact .span-5.last#contacts_of_contact
.section.contact_pictures .section.contact_pictures
%h4 %h4
= t('contacts', :count => @contacts_of_contact_count) = t('contacts', :count => @contacts_of_contact_count)
- for person in @contacts_of_contact - @contacts_of_contact.each do |person|
= person_image_link person = person_image_link person
- if @contacts_of_contact.count > 8 - if @contacts_of_contact_count > 8
%p.see_all= link_to t('.see_all'), person_contacts_path(@person) %p.see_all= link_to t('.see_all'), person_contacts_path(@person)
.span-18.last .span-18.last

View file

@ -15,15 +15,6 @@
%span.description %span.description
= @person.diaspora_handle = @person.diaspora_handle
- if user_signed_in? && !(@contact.persisted? || current_user.person == @person)
- if @incoming_request
.floating
%h3
= t('.incoming_request', :name => @person.name)
%h4
= link_to t('.return_to_aspects'), aspects_manage_path
= t('.to_accept_or_ignore')
.span12 .span12
- if @stream.stream_posts.length > 0 - if @stream.stream_posts.length > 0
- if @post_type == :photos - if @post_type == :photos