resending of invitation in resque and works

This commit is contained in:
zhitomirskiyi 2011-01-23 20:13:10 -08:00
parent da6e16b3a4
commit 83a9e916e4
5 changed files with 23 additions and 9 deletions

View file

@ -7,8 +7,8 @@ class InvitationsController < Devise::InvitationsController
before_filter :check_token, :only => [:edit]
def new
sent_invitations = current_user.invitations_from_me.includes(:recipient)
@emails_delivered = sent_invitations.map!{ |i| i.recipient.email }
@sent_invitations = current_user.invitations_from_me.includes(:recipient)
#emails_delivered = sent_invitations.map!{ |i| i.recipient.email }
end
def create
@ -59,7 +59,10 @@ class InvitationsController < Devise::InvitationsController
def resend
invitation = current_user.invitations_from_me.where(:id => params[:id]).first
Resque.enqueue(Job::ResendInvitation, invitation.id) if invitation
if invitation
Resque.enqueue(Job::ResendInvitation, invitation.id)
flash[:notice] = I18n.t('invitations.create.sent') + invitation.recipient.email
end
redirect_to :back
end

View file

@ -79,6 +79,10 @@ class Invitation < ActiveRecord::Base
invitee
end
def resend
recipient.invite!
end
def to_request!
request = sender.send_contact_request_to(recipient.person, aspect)
destroy if request

View file

@ -36,10 +36,11 @@
%p
= invite.submit t('.send_an_invitation')
- if !@emails_delivered.empty?
- if !@sent_invitations.empty?
.span-4.last
#already_invited_pane
%h4
= t('.already_invited')
- for email in @emails_delivered
= email
- for invitation in @sent_invitations
= invitation.recipient.email
= link_to "Resend", invitation_resend_path(invitation), :confirm => t('are_you_sure')

View file

@ -31,10 +31,15 @@ Diaspora::Application.routes.draw do
match 'photos/make_profile_photo' => 'photos#make_profile_photo'
resources :photos, :except => [:index]
match 'invitations/resend/:id' => 'invitations#resend'
devise_for :users, :controllers => {:registrations => "registrations",
:password => "devise/passwords",
:invitations => "invitations"}
:invitations => "invitations"} do
get 'invitations/resend/:id' => 'invitations#resend', :as => 'invitation_resend'
end
# added public route to user
match 'public/:username', :to => 'users#public'
match 'getting_started', :to => 'users#getting_started', :as => 'getting_started'

View file

@ -301,7 +301,8 @@ describe Invitation do
describe '.resend' do
before do
aspect
@invitation = Invitation.new(:sender => user, :recipient => user2, :aspect => aspect)
user.invite_user("a@a.com", aspect.id)
@invitation = user.reload.invitations_from_me.first
end
it 'sends another email' do