added similar contacts to contact pages
This commit is contained in:
parent
72c377fa73
commit
f821f49db1
9 changed files with 80 additions and 5 deletions
|
|
@ -48,4 +48,14 @@ class ApplicationController < ActionController::Base
|
|||
I18n.locale = request.compatible_language_from AVAILABLE_LANGUAGE_CODES
|
||||
end
|
||||
end
|
||||
|
||||
def similar_people contact
|
||||
aspect_ids = contact.aspect_ids
|
||||
contacts = Contact.all(:user_id => current_user.id,
|
||||
:person_id.ne => contact.person.id,
|
||||
:aspect_ids.in => aspect_ids,
|
||||
:limit => 5,
|
||||
:order => 'updated_at desc')
|
||||
contacts.collect!{ |contact| contact.person }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ class PeopleController < ApplicationController
|
|||
|
||||
if @contact
|
||||
@aspects_with_person = @contact.aspects
|
||||
@similar_people = similar_people @contact
|
||||
end
|
||||
|
||||
if (@person != current_user.person) && (!@contact || @contact.pending)
|
||||
|
|
@ -152,4 +153,5 @@ class PeopleController < ApplicationController
|
|||
def webfinger(account, opts = {})
|
||||
Resque.enqueue(Jobs::SocketWebfinger, current_user.id, account, opts)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ class PhotosController < ApplicationController
|
|||
|
||||
if @contact
|
||||
@aspects_with_person = @contact.aspects
|
||||
@similar_people = similar_people @contact
|
||||
end
|
||||
|
||||
@posts = current_user.raw_visible_posts.all(:_type => 'Photo', :person_id => @person.id, :order => 'created_at DESC').paginate :page => params[:page], :order => 'created_at DESC'
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
%h3 #{t('.bio')}
|
||||
= markdownify(person.profile.bio, :newlines => true)
|
||||
|
||||
%li
|
||||
%li.span-8.last
|
||||
.span-4
|
||||
%h3 #{t('.gender')}
|
||||
= person.profile.gender
|
||||
|
|
|
|||
|
|
@ -21,6 +21,15 @@
|
|||
.span-8.append-1.last
|
||||
= render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact }
|
||||
|
||||
- if @contact && @similar_people.count > 0
|
||||
.span-8.last
|
||||
%hr{:style=>"width:300px;"}
|
||||
.section.contact_pictures
|
||||
%h4
|
||||
= t('.similar_contacts')
|
||||
- for person in @similar_people
|
||||
= person_image_link person
|
||||
|
||||
.span-15.last
|
||||
- unless @contact || current_user.person == @person
|
||||
- if @incoming_request
|
||||
|
|
|
|||
|
|
@ -346,6 +346,7 @@ en:
|
|||
not_connected: "You are not sharing with %{name}"
|
||||
recent_posts: "Recent Posts"
|
||||
recent_public_posts: "Recent Public Posts"
|
||||
similar_contacts: "similar contacts"
|
||||
edit:
|
||||
info_available_to: "This info will be available to whomever you connect with on Diaspora."
|
||||
your_profile: "Your profile"
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ var View = {
|
|||
|
||||
avatars: {
|
||||
bind: function() {
|
||||
$("#left_pane img.avatar, #manage_aspect_zones img.avatar").tipsy({
|
||||
$(".contact_pictures img.avatar, #manage_aspect_zones img.avatar").tipsy({
|
||||
live: true
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -590,8 +590,7 @@ ul.comments
|
|||
:padding 0
|
||||
|
||||
ul#profile_information
|
||||
:margin
|
||||
:top 1em
|
||||
:margin 1em 0
|
||||
> li
|
||||
:margin
|
||||
:bottom 2em
|
||||
|
|
|
|||
|
|
@ -14,6 +14,59 @@ describe PeopleController do
|
|||
sign_in :user, user
|
||||
end
|
||||
|
||||
describe '#similar_people' do
|
||||
before do
|
||||
@contacts = []
|
||||
@aspect1 = user.aspects.create(:name => "foos")
|
||||
@aspect2 = user.aspects.create(:name => "bars")
|
||||
|
||||
3.times do
|
||||
@contacts << Contact.create(:user => user, :person => Factory.create(:person))
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns people in mutual aspects' do
|
||||
@contacts[0].aspects << @aspect1
|
||||
@contacts[1].aspects << @aspect1
|
||||
@contacts[0].save
|
||||
@contacts[1].save
|
||||
|
||||
@controller.similar_people(@contacts[0]).should include(@contacts[1].person)
|
||||
end
|
||||
|
||||
it 'does not return people in non-mutual aspects' do
|
||||
@contacts[0].aspects << @aspect1
|
||||
@contacts[1].aspects << @aspect1
|
||||
@contacts[0].save
|
||||
@contacts[1].save
|
||||
|
||||
@controller.similar_people(@contacts[0]).should_not include(@contacts[2].person)
|
||||
end
|
||||
|
||||
it 'does not return the original contacts person' do
|
||||
@contacts[0].aspects << @aspect1
|
||||
@contacts[1].aspects << @aspect1
|
||||
@contacts[0].save
|
||||
@contacts[1].save
|
||||
|
||||
@controller.similar_people(@contacts[0]).should_not include(@contacts[0].person)
|
||||
end
|
||||
|
||||
it 'returns at max 5 similar people' do
|
||||
@contacts[0].aspects << @aspect1
|
||||
@contacts[0].save
|
||||
|
||||
20.times do
|
||||
c = Contact.create(:user => user, :person => Factory.create(:person))
|
||||
c.aspects << @aspect1
|
||||
c.save
|
||||
@contacts << c
|
||||
end
|
||||
|
||||
@controller.similar_people(@contacts[0]).count.should == 5
|
||||
end
|
||||
end
|
||||
|
||||
describe '#share_with' do
|
||||
before do
|
||||
@person = Factory.create(:person)
|
||||
|
|
|
|||
Loading…
Reference in a new issue