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
|
I18n.locale = request.compatible_language_from AVAILABLE_LANGUAGE_CODES
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ class PeopleController < ApplicationController
|
||||||
|
|
||||||
if @contact
|
if @contact
|
||||||
@aspects_with_person = @contact.aspects
|
@aspects_with_person = @contact.aspects
|
||||||
|
@similar_people = similar_people @contact
|
||||||
end
|
end
|
||||||
|
|
||||||
if (@person != current_user.person) && (!@contact || @contact.pending)
|
if (@person != current_user.person) && (!@contact || @contact.pending)
|
||||||
|
|
@ -152,4 +153,5 @@ class PeopleController < ApplicationController
|
||||||
def webfinger(account, opts = {})
|
def webfinger(account, opts = {})
|
||||||
Resque.enqueue(Jobs::SocketWebfinger, current_user.id, account, opts)
|
Resque.enqueue(Jobs::SocketWebfinger, current_user.id, account, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ class PhotosController < ApplicationController
|
||||||
|
|
||||||
if @contact
|
if @contact
|
||||||
@aspects_with_person = @contact.aspects
|
@aspects_with_person = @contact.aspects
|
||||||
|
@similar_people = similar_people @contact
|
||||||
end
|
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'
|
@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')}
|
%h3 #{t('.bio')}
|
||||||
= markdownify(person.profile.bio, :newlines => true)
|
= markdownify(person.profile.bio, :newlines => true)
|
||||||
|
|
||||||
%li
|
%li.span-8.last
|
||||||
.span-4
|
.span-4
|
||||||
%h3 #{t('.gender')}
|
%h3 #{t('.gender')}
|
||||||
= person.profile.gender
|
= person.profile.gender
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,16 @@
|
||||||
= link_to t('_photos'), person_photos_path(@person)
|
= link_to t('_photos'), person_photos_path(@person)
|
||||||
|
|
||||||
.span-8.append-1.last
|
.span-8.append-1.last
|
||||||
= render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact}
|
= 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
|
.span-15.last
|
||||||
- unless @contact || current_user.person == @person
|
- unless @contact || current_user.person == @person
|
||||||
|
|
|
||||||
|
|
@ -346,6 +346,7 @@ en:
|
||||||
not_connected: "You are not sharing with %{name}"
|
not_connected: "You are not sharing with %{name}"
|
||||||
recent_posts: "Recent Posts"
|
recent_posts: "Recent Posts"
|
||||||
recent_public_posts: "Recent Public Posts"
|
recent_public_posts: "Recent Public Posts"
|
||||||
|
similar_contacts: "similar contacts"
|
||||||
edit:
|
edit:
|
||||||
info_available_to: "This info will be available to whomever you connect with on Diaspora."
|
info_available_to: "This info will be available to whomever you connect with on Diaspora."
|
||||||
your_profile: "Your profile"
|
your_profile: "Your profile"
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ var View = {
|
||||||
|
|
||||||
avatars: {
|
avatars: {
|
||||||
bind: function() {
|
bind: function() {
|
||||||
$("#left_pane img.avatar, #manage_aspect_zones img.avatar").tipsy({
|
$(".contact_pictures img.avatar, #manage_aspect_zones img.avatar").tipsy({
|
||||||
live: true
|
live: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -590,8 +590,7 @@ ul.comments
|
||||||
:padding 0
|
:padding 0
|
||||||
|
|
||||||
ul#profile_information
|
ul#profile_information
|
||||||
:margin
|
:margin 1em 0
|
||||||
:top 1em
|
|
||||||
> li
|
> li
|
||||||
:margin
|
:margin
|
||||||
:bottom 2em
|
:bottom 2em
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,59 @@ describe PeopleController do
|
||||||
sign_in :user, user
|
sign_in :user, user
|
||||||
end
|
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
|
describe '#share_with' do
|
||||||
before do
|
before do
|
||||||
@person = Factory.create(:person)
|
@person = Factory.create(:person)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue