invitation text

setting the invites

added requests to the fb hash

finder has options

remove the requester from the list

typo

making a block

another typo

remove the if statement for the notifications

checking on the right field

translations and correct indenting

fixed stuff added

added a temp puts

added a temp puts

now actually referencing the service

not double nesting

remove stream element

updated remote friends to old style

removed it from the h1 block

putting the stream element back
This commit is contained in:
zhitomirskiyi 2011-02-04 16:45:56 -08:00
parent df4ebb286d
commit d147da1b4a
9 changed files with 79 additions and 30 deletions

View file

@ -25,7 +25,7 @@ class ServicesController < ApplicationController
flash[:notice] = I18n.t 'services.create.success'
if current_user.getting_started
redirect_to getting_started_path(:step => 3)
redirect_to getting_started_path(:step => 1)
else
redirect_to services_url
end

View file

@ -78,15 +78,18 @@ class UsersController < ApplicationController
@person = @user.person
@profile = @user.profile
@services = @user.services
@requests = Request.where(:recipient_id => @person.id).all
service = current_user.services.where(:type => "Services::Facebook").first
@step = ((params[:step].to_i>0)&&(params[:step].to_i<5)) ? params[:step].to_i : 1
@step ||= 1
if @step == 3
service = current_user.services.where(:type => "Services::Facebook").first
@friends = service ? service.finder : {}
@requests = Request.where(:recipient_id => @person.id).includes(:sender).all
@friends = service ? service.finder(:local => true) : {}
@friends.delete_if{|key, value| @requests.any?{ |r| r.sender_id == value[:person].id} }
elsif @step == 4
@invites = @user.invites
@friends = service ? service.finder(:remote => true) : {}
@user.getting_started = false
@user.save
end

View file

@ -19,7 +19,7 @@ class Services::Facebook < Service
super(post, MAX_CHARACTERS, url)
end
def finder
def finder(opts = {})
Rails.logger.debug("event=friend_finder type=facebook sender_id=#{self.user_id}")
response = RestClient.get("https://graph.facebook.com/me/friends", {:params => {:access_token => self.access_token}})
data = JSON.parse(response.body)['data']
@ -45,9 +45,21 @@ class Services::Facebook < Service
person_ids_and_uids[s.user.person.id] = s.uid
end
requests = Request.where(:recipient_id => self.user.person.id, :sender_id => person_ids_and_uids.keys).all
requests.each{|r| data_h[person_ids_and_uids[r.sender_id]][:request] = r}
contact_objects = self.user.contacts.where(:person_id => person_ids_and_uids.keys)
contact_objects.each{|c| data_h[person_ids_and_uids[c.person_id]][:contact] = c}
if opts[:local]
data_h.delete_if {|key, value| value[:person].nil? }
end
if opts[:remote]
data_h.delete_if {|key, value| !value[:person].nil? }
end
data_h
end
end

View file

@ -2,7 +2,7 @@
-if friend[:person]
= render :partial => 'people/person', :locals => {:person => friend[:person], :contact => friend[:contact], :request => friend[:request]}
-else
.stream_element
.steam_element
.right
-if friend[:invitation_id]
= t('invitations.new.already_invited')

View file

@ -38,10 +38,10 @@
= t('.edit_profile')
%br
- if @step != 3
= link_to t('.define_aspects'), getting_started_path(:step => 3)
= link_to t('.connect_on_diaspora'), getting_started_path(:step => 3)
- else
%span.current_gs_step
= t('.define_aspects')
= t('.connect_on_diaspora')
%br
- if @step != 4
= link_to t('.finished'), getting_started_path(:step => 4)

View file

@ -8,20 +8,19 @@
= t('.your_aspects')
.description
= t('.description')
-if @requests.length > 0
%br
= t('.your_inviter')
%br
%br
= t('.your_inviter')
%br
#people_stream.stream
- for pending_req in @requests
- person = pending_req.sender
= render :partial => 'people/person', :locals => {:request => pending_req, :person => person, :contact => nil}
- for fb_id in @friends.keys
- friend = @friends[fb_id]
= render :partial => 'people/person', :locals => {:request => friend[:request], :person => friend[:person], :contact => friend[:contact]}
#people_stream.stream
- for pending_req in @requests
- person = pending_req.sender
= render :partial => 'people/person', :locals => {:request => pending_req, :person => person, :contact => nil}
-unless @friends.blank?
%br
.contact_list
= render :partial => 'services/finder', :locals => {:friends => @friends, :getting_started => true}
.submit_block

View file

@ -10,7 +10,13 @@
%ul.inline_aspect_listing
- for aspect in @all_aspects
%li= aspect
-unless @friends.blank?
%br
= t('services.finder.invite_your_friends_from', :service => "facebook".titleize)
= t('shared.invitations.invitations_left', :count => @invites)
%br
.contact_list
= render :partial => 'services/finder', :locals => {:friends => @friends, :getting_started => true}
%br
%br

View file

@ -230,7 +230,7 @@ en:
welcome: "Welcome to Diaspora!"
signup_steps: "Finish your sign up by completing these three steps:"
edit_profile: "Edit your profile"
define_aspects: "Define your aspects"
connect_on_diaspora: "Connect on Diaspora"
connect_services: "Connect your other services"
finished: "Finished!"
skip: "skip getting started"

View file

@ -40,6 +40,10 @@ describe Services::Facebook do
{
"name": "#{@user2_fb_name}",
"id": "#{@user2_fb_id}"
},
{
"name": "Person to Invite",
"id": "abc123"
}
]
}
@ -54,12 +58,14 @@ JSON
@service.finder
end
context 'returns a hash' do
it 'returns a hash' do
@service.finder.class.should == Hash
end
it 'contains a name' do
@service.finder.values.first[:name].should == @user2_fb_name
@service.finder["#{@user2_fb_id}"][:name].should == @user2_fb_name
end
it 'contains a photo url' do
pending
@ -68,21 +74,44 @@ JSON
@service.finder.include?(@user2_fb_id).should be_true
end
it 'contains a diaspora person object' do
@service.finder.values.first[:person].should == @user2.person
@service.finder["#{@user2_fb_id}"][:person].should == @user2.person
end
it 'caches the profile' do
@service.finder.values.first[:person].profile.loaded?.should be_true
@service.finder["#{@user2_fb_id}"][:person].profile.loaded?.should be_true
end
it 'does not include the person if the search is disabled' do
p = @user2.person.profile
p.searchable = false
p.save
@service.finder.values.first[:person].should be_nil
@service.finder["#{@user2_fb_id}"][:person].should be_nil
end
it 'contains a request object if one has been sent' do
request = Request.diaspora_initialize(:from => @user2.person, :to => @user.person, :into => @user2.aspects.first)
Postzord::Receiver.new(@user, :object => request, :person => @user2.person).receive_object
Request.count.should == 1
@service.finder["#{@user2_fb_id}"][:request].should == request
end
it 'contains a contact object if connected' do
connect_users(@user, @user.aspects.first, @user2, @user2.aspects.first)
@service.finder.values.first[:contact].should == @user.reload.contact_for(@user2.person)
@service.finder["#{@user2_fb_id}"][:contact].should == @user.reload.contact_for(@user2.person)
end
context 'only local' do
it 'does not return people who are remote' do
@service.finder(:local => true)['abc123'].should be nil
@service.finder(:local => true)["#{@user2_fb_id}"].should_not be_nil
end
end
context 'only remote' do
it 'does not return people who are remote' do
@service.finder(:remote => true)['abc123'].should_not be nil
@service.finder(:remote => true)["#{@user2_fb_id}"].should be_nil
end
end
context 'already invited' do
before do
@user2.invitation_service = 'facebook'
@ -91,14 +120,14 @@ JSON
end
it 'contains an invitation if invited' do
@inv = Invitation.create(:sender => @user, :recipient => @user2, :aspect => @user.aspects.first)
@service.finder.values.first[:invitation_id].should == @inv.id
@service.finder["#{@user2_fb_id}"][:invitation_id].should == @inv.id
end
it 'does not find the user with a wrong identifier' do
@user2.invitation_identifier = 'dsaofhnadsoifnsdanf'
@user2.save
@inv = Invitation.create(:sender => @user, :recipient => @user2, :aspect => @user.aspects.first)
@service.finder.values.first[:invitation_id].should be_nil
@service.finder["#{@user2_fb_id}"][:invitation_id].should be_nil
end
end
end