Merge branch 'master' of github.com:diaspora/diaspora

This commit is contained in:
maxwell 2010-12-15 18:05:54 -08:00
commit d5ba34f245
15 changed files with 195 additions and 78 deletions

View file

@ -11,7 +11,7 @@ class AspectsController < ApplicationController
def index def index
@posts = current_user.visible_posts(:_type => "StatusMessage").paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' @posts = current_user.visible_posts(:_type => "StatusMessage").paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC'
@post_hashes = hashes_for_posts @posts @post_hashes = hashes_for_posts @posts
@contacts = current_user.contacts(:pending => false) @contacts = Contact.all(:user_id => current_user.id, :pending => false)
@aspect_hashes = hashes_for_aspects @aspects.all, @contacts, :limit => 8 @aspect_hashes = hashes_for_aspects @aspects.all, @contacts, :limit => 8
@aspect = :all @aspect = :all
@ -62,7 +62,7 @@ class AspectsController < ApplicationController
unless @aspect unless @aspect
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404 render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
else else
@aspect_contacts = hashes_for_contacts @aspect.contacts(:pending => false) @aspect_contacts = hashes_for_contacts Contact.all(:user_id => current_user.id, :aspect_ids.in => [@aspect.id], :pending => false)
@aspect_contacts_count = @aspect_contacts.count @aspect_contacts_count = @aspect_contacts.count
@posts = @aspect.posts.find_all_by__type("StatusMessage", :order => 'created_at desc').paginate :page => params[:page], :per_page => 15 @posts = @aspect.posts.find_all_by__type("StatusMessage", :order => 'created_at desc').paginate :page => params[:page], :per_page => 15
@ -116,6 +116,12 @@ class AspectsController < ApplicationController
current_user.add_contact_to_aspect(@contact, @aspect) current_user.add_contact_to_aspect(@contact, @aspect)
else else
current_user.send_contact_request_to(@person, @aspect) current_user.send_contact_request_to(@person, @aspect)
contact = current_user.contact_for(@person)
if request = Request.from(@person).to(current_user).first
request.destroy
contact.update_attributes(:pending => false)
end
end end
flash.now[:notice] = I18n.t 'aspects.add_to_aspect.success' flash.now[:notice] = I18n.t 'aspects.add_to_aspect.success'

View file

@ -113,6 +113,22 @@ class PeopleController < ApplicationController
end end
end end
def share_with
@person = Person.find(params[:id].to_id)
@contact = current_user.contact_for(@person)
@aspects_with_person = []
if @contact
@aspects_with_person = @contact.aspects
end
@aspects_without_person = @aspects.reject do |aspect|
@aspects_with_person.include?(aspect)
end
render :layout => nil
end
private private
def hashes_for_posts posts def hashes_for_posts posts
post_ids = posts.map{|p| p.id} post_ids = posts.map{|p| p.id}

View file

@ -34,12 +34,12 @@ class Profile
validates_length_of :first_name, :maximum => 32 validates_length_of :first_name, :maximum => 32
validates_length_of :last_name, :maximum => 32 validates_length_of :last_name, :maximum => 32
before_save :strip_names before_save :strip_names
attr_accessible :first_name, :last_name, :image_url, :image_url_medium, attr_accessible :first_name, :last_name, :image_url, :image_url_medium,
:image_url_small, :birthday, :gender, :bio, :searchable, :date :image_url_small, :birthday, :gender, :bio, :searchable, :date
def person def person
self._parent_document self._parent_document
end end

View file

@ -37,23 +37,14 @@
= link_to "edit aspect membership", "#", :id=> "edit_contact_aspects" = link_to "edit aspect membership", "#", :id=> "edit_contact_aspects"
.edit{:class => ("hidden" if contact)} .edit{:class => ("hidden" if contact)}
.contact_list#aspects_list
%ul
- for aspect in aspects_with_person
%li{:data=>{:guid=>aspect.id}}
%span.name
= link_to aspect.name, aspect
.right
= aspect_membership_button(aspect.id, contact, person)
- for aspect in aspects_without_person = render :partial => 'people/share_with_pane',
%li{:data=>{:guid=>aspect.id}} :locals => {:person => person,
%span.name :contact => contact,
= link_to aspect.name, aspect :aspects_with_person => aspects_with_person,
.right :aspects_without_person => aspects_without_person}
= aspect_membership_button(aspect.id, contact, person)
- if contact
.right .right
= link_to "done editing", "#", :id => "done_contact_aspects" = link_to "done editing", "#", :id => "done_contact_aspects"
- if contact
= link_to t('people.profile_sidebar.remove_contact'), person, :confirm => t('are_you_sure'), :method => :delete = link_to t('people.profile_sidebar.remove_contact'), person, :confirm => t('are_you_sure'), :method => :delete

View file

@ -4,22 +4,27 @@
%li.message{:id => person.id} %li.message{:id => person.id}
= person_image_link(person)
.content
%span.from
=person_link(person)
.right{:style=>"display:inline;"} .right{:style=>"display:inline;"}
- if person.owner_id == current_user.id - if person.owner_id == current_user.id
= t('.thats_you') = t('.thats_you')
- elsif contact && !contact.pending - elsif contact && !contact.pending
= t('.already_connected') = t('.already_connected')
- elsif (contact && contact.pending) || request - elsif (contact && contact.pending) || request
= link_to t('.pending_request'), aspects_manage_path = t('.pending_request')
- else - else
- single_aspect_form ||= nil - single_aspect_form ||= nil
= render(:partial => request_partial(single_aspect_form), :locals => {:aspects => aspects, :destination_handle => person.diaspora_handle}) = link_to "start sharing",
{:controller => "people",
:action => "share_with",
:id => person.id},
:class => 'button share_with_button'
= person_image_link(person)
.content
%span.from
=person_link(person)
.info .info
= person.diaspora_handle = person.diaspora_handle

View file

@ -0,0 +1,20 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
.contact_list#aspects_list
%ul
- for aspect in aspects_with_person
%li{:data=>{:guid=>aspect.id}}
%span.name
= link_to aspect.name, aspect
.right
= aspect_membership_button(aspect.id, contact, person)
- for aspect in aspects_without_person
%li{:data=>{:guid=>aspect.id}}
%span.name
= link_to aspect.name, aspect
.right
= aspect_membership_button(aspect.id, contact, person)

View file

@ -5,6 +5,9 @@
- content_for :page_title do - content_for :page_title do
= t('search') = t('search')
- content_for :head do
= include_javascripts :people
.span-24.last .span-24.last
- if params[:q].blank? - if params[:q].blank?
%h2 %h2

View file

@ -0,0 +1,18 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
#share_with
.share_with_header
= person_image_link(@person, :size => :thumb_medium)
%h3
= "Start sharing with #{@person.name}"
%p
= "Once #{@person.first_name} accepts, you'll start seeing each other's posts on Diaspora"
= render :partial => 'share_with_pane',
:locals => {:person => @person,
:contact => @contact,
:aspects_with_person => @aspects_with_person,
:aspects_without_person => @aspects_without_person}

View file

@ -3,17 +3,17 @@
-# the COPYRIGHT file. -# the COPYRIGHT file.
%li.message{:data=>{:guid=>post.id}} %li.message{:data=>{:guid=>post.id}}
= person_image_link(person, :size => :thumb_small)
.content
.from
- if person.owner_id == current_user.id - if person.owner_id == current_user.id
.right .right.controls
- reshare_aspects = aspects_without_post(aspects, post) - reshare_aspects = aspects_without_post(aspects, post)
- unless reshare_aspects.empty? - unless reshare_aspects.empty?
= render 'shared/reshare', :aspects => reshare_aspects, :post => post = render 'shared/reshare', :aspects => reshare_aspects, :post => post
= link_to t('delete'), status_message_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete" = link_to t('delete'), status_message_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete"
= person_image_link(person, :size => :thumb_small)
.content
.from
%h4 %h4
=person_link(person) =person_link(person)

View file

@ -28,6 +28,8 @@ javascripts:
- public/javascripts/vendor/jquery-ui-1.8.6.custom.min.js - public/javascripts/vendor/jquery-ui-1.8.6.custom.min.js
- public/javascripts/aspect-edit.js - public/javascripts/aspect-edit.js
- public/javascripts/contact-list.js - public/javascripts/contact-list.js
people:
- public/javascripts/contact-list.js
photos: photos:
- public/javascripts/photo-show.js - public/javascripts/photo-show.js

View file

@ -10,6 +10,10 @@ Diaspora::Application.routes.draw do
resources :notifications, :only => [:destroy, :index] resources :notifications, :only => [:destroy, :index]
resources :posts, :only => [:show], :path => '/p/' resources :posts, :only => [:show], :path => '/p/'
match '/people/share_with' => 'people#share_with', :as => 'share_with'
resources :people do resources :people do
resources :status_messages resources :status_messages
resources :photos resources :photos

View file

@ -82,7 +82,8 @@ var View = {
".invite_user_button", ".invite_user_button",
".add_photo_button", ".add_photo_button",
".remove_person_button", ".remove_person_button",
".question_mark" ".question_mark",
".share_with_button"
] ]
}, },

View file

@ -617,10 +617,12 @@ ul.comments
a a
:padding 3px :padding 3px
li.message .from .right li.message .right
:display none :display none
:position absolute :position absolute
:right 12px :right 12px
&.controls
:font :font
:size 12px :size 12px
:color #999 :color #999
@ -2041,3 +2043,22 @@ h3,h4
.aspect_badge .aspect_badge
:top -0.2em :top -0.2em
#share_with
:min-width 400px
:max-width 400px
.share_with_header
:min-height 100px
.avatar
:width 100px
:height 100px
:float left
h3,p
:padding
:left 120px
h3
:margin 0
#aspects_list
:height auto

View file

@ -227,6 +227,27 @@ describe AspectsController do
end end
describe "#add_to_aspect" do describe "#add_to_aspect" do
context 'with an incoming request' do
before do
@user3 = make_user
@user3.send_contact_request_to(@user.person, @user3.aspects.create(:name => "Walruses"))
end
it 'deletes the request' do
post 'add_to_aspect',
:format => 'js',
:person_id => @user3.person.id,
:aspect_id => @aspect1.id
Request.from(@user3).to(@user).first.should be_nil
end
it 'does not leave the contact pending' do
post 'add_to_aspect',
:format => 'js',
:person_id => @user3.person.id,
:aspect_id => @aspect1.id
@user.contact_for(@user3.person).should_not be_pending
end
end
context 'with a non-contact' do context 'with a non-contact' do
before do before do
@person = Factory(:person) @person = Factory(:person)

View file

@ -14,6 +14,15 @@ describe PeopleController do
sign_in :user, user sign_in :user, user
end end
describe '#share_with' do
before do
@person = Factory.create(:person)
end
it 'succeeds' do
get :share_with, :id => @person.id
response.should be_success
end
end
describe '#hashes_from_people' do describe '#hashes_from_people' do
before do before do
@everyone = [] @everyone = []