added a pane for people sharing with you on all aspect page

This commit is contained in:
danielgrippi 2011-05-04 17:57:42 -07:00
parent e854bd0a32
commit 0db8541f6e
8 changed files with 42 additions and 21 deletions

View file

@ -17,6 +17,7 @@ class AspectsController < ApplicationController
@aspects = current_user.aspects.where(:id => params[:a_ids])
else
@aspects = current_user.aspects
@contacts_sharing_with = current_user.contacts.sharing
end
#No aspect_listings on infinite scroll

View file

@ -19,6 +19,10 @@ class Contact < ActiveRecord::Base
validates_uniqueness_of :person_id, :scope => :user_id
scope :sharing, lambda {
where(:sharing => true)
}
def dispatch_request
request = self.generate_request
Postzord::Dispatch.new(self.user, request).post

View file

@ -12,3 +12,16 @@
- for aspect in aspects
= render 'aspects/aspect', :aspect => aspect, :contacts => aspect.contacts
- if @contacts_sharing_with
%li{:class => ("dull" if @contacts_sharing_with.size == 0)}
.right
%b
= link_to t('contacts', :count => @contacts_sharing_with.size), edit_aspect_path(aspect), :rel => 'facebox', :class => 'contact-count'
%b
People sharing with you
%br
- if @contacts_sharing_with.size > 0
.contacts
- for contact in @contacts_sharing_with[0..15]
= person_image_link(contact.person)

View file

@ -35,12 +35,16 @@
%br
%hr{:style=>"width:300px;"}
- if user_signed_in? && contact.sharing?
- if user_signed_in?
%br
%h4
#{person.name} is sharing with you.
- if contact.sharing?
%h4
#{person.name} is sharing with you.
- elsif contact.receiving?
%h4
You are sharing with #{person.name}
-if user_signed_in? && ((contact.persisted? && contact.mutual?) || person == current_user.person || @incoming_request)
-if user_signed_in? && (contact.sharing? || person == current_user.person)
%ul#profile_information
- unless person.profile.bio.blank?
%li

View file

@ -26,7 +26,7 @@
.span-15.last
#author_info
- if user_signed_in?
- if !@contact.receiving? #!(current_user.person == @person) && !(@contact.persisted? && !@contact.sharing?)
- if !@contact.receiving?
.right
= link_to t('.start_sharing'),
{:controller => "contacts",

View file

@ -28,7 +28,7 @@ module Diaspora
if !contact.mutual? || opts[:force]
contact.destroy
else
contact.update_attributes(:sharing => false)
contact.update_attributes(:receiving => false)
end
posts.each do |p|

View file

@ -44,19 +44,18 @@ describe Contact do
contact.person = person
contact.should_not be_valid
end
end
it 'validates that sharing and aspect membership count are consistant' do
pending
person = Factory(:person)
contact2 = alice.contacts.create(:person=>person)
contact2.should be_valid
contact2.aspect_memberships.create(:aspect => alice.aspects.first)
contact2.should_not be_sharing
contact2.should_not be_valid
context 'scope' do
describe 'sharing' do
it 'returns contacts with sharing true' do
lambda {
alice.contacts.create!(:sharing => true, :person => Factory(:person))
alice.contacts.create!(:sharing => false, :person => Factory(:person))
}.should change{
Contact.sharing.count
}.by(1)
end
end
end

View file

@ -27,10 +27,10 @@ describe Diaspora::UserModules::Connecting do
}.by(-1)
end
it 'removes a contacts mutual flag' do
bob.contacts.find_by_person_id(alice.person.id).should be_mutual
it 'removes a contacts receiving flag' do
bob.contacts.find_by_person_id(alice.person.id).should be_receiving
bob.remove_contact(bob.contact_for(alice.person))
bob.contacts(true).find_by_person_id(alice.person.id).should_not be_mutual
bob.contacts(true).find_by_person_id(alice.person.id).should_not be_receiving
end
end