Skip to content

Commit

Permalink
Added email confirmation and notification after transfer.
Browse files Browse the repository at this point in the history
  • Loading branch information
svenaas committed Dec 8, 2011
1 parent ed94597 commit 29e8ded
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/transfers_controller.rb
Expand Up @@ -51,6 +51,8 @@ def create

respond_to do |format|
if @transfer.save
UserMailer.transfer_confirmation(@transfer).deliver
UserMailer.transfer_notification(@transfer).deliver
format.html { redirect_to([@agreement, @transfer], :notice => 'Transfer was successfully created.') }
format.xml { render :xml => [@agreement, @transfer], :status => :created, :location => [@agreement,@transfer] }
else
Expand Down
15 changes: 15 additions & 0 deletions app/mailers/user_mailer.rb
@@ -0,0 +1,15 @@
class UserMailer < ActionMailer::Base
default :from => Drxfer::Application.config.email_notification_from_address

def transfer_confirmation(transfer)
@transfer = transfer
mail(:to => transfer.user.email,
:subject => "Thank you for transferring your digital records")
end

def transfer_notification(transfer)
@transfer = transfer
mail(:to => Drxfer::Application.config.transfer_notification_recipient_addresses,
:subject => "A digital records transfer has been received")
end
end
8 changes: 8 additions & 0 deletions app/views/user_mailer/transfer_confirmation.text.erb
@@ -0,0 +1,8 @@
Dear <%= @transfer.user.first_name %>,

Thank you for transferring your digital records.

We have received the following file<%= @transfer.attachments.size == 1 ? '' : 's' %>:
<% @transfer.attachments.each do |attachment| %>
<%= File.basename(attachment.asset.current_path) %>
<% end %>
21 changes: 21 additions & 0 deletions app/views/user_mailer/transfer_notification.text.erb
@@ -0,0 +1,21 @@
Dear Transfer Recipient,

<%= @transfer.user.full_name %> has made a digital records transfer.

Transfer agreement:
<%= @transfer.agreement.name %>

Path to destination folder:
<%= @transfer.agreement.folder.full_path %>

Transfer description:
<%= @transfer.description %>

Transferred file<%= @transfer.attachments.size == 1 ? '' : 's' %>:
<% @transfer.attachments.each do |attachment| %>
<%= File.basename(attachment.asset.current_path) %>
Content-type: <%= attachment.content_type %>
Size: <%= number_to_human_size(attachment.file_size) %>
MD5: <%= attachment.md5 %>
<% end %>
3 changes: 3 additions & 0 deletions config/environments/development.rb
Expand Up @@ -32,5 +32,8 @@

# Override base path for transfered files here. Default is Rails.root
config.transfer_destination_base_path = Rails.root.to_s + '/' + 'transfers'

config.email_notification_from_address = 'drxfer@example.com'
config.transfer_notification_recipient_addresses = ['drxfer.admin@example.com']
end

3 changes: 3 additions & 0 deletions config/environments/production.rb.sample
Expand Up @@ -52,4 +52,7 @@ Drxfer::Application.configure do

# Override base path for transfered files here. Default is Rails.root
config.transfer_destination_base_path = Rails.root.to_s + '/'+ 'transfers'

config.email_notification_from_address = 'drxfer@example.com'
config.transfer_notification_recipient_addresses = ['drxfer@example.com']
end
3 changes: 3 additions & 0 deletions config/environments/test.rb
Expand Up @@ -44,4 +44,7 @@

# Override base path for transfered files here. Default is Rails.root
# config.transfer_destination_base_path = '/'

config.email_notification_from_address = 'drxfer@example.com'
config.transfer_notification_recipient_addresses = ['drxfer.admin@example.com']
end
5 changes: 5 additions & 0 deletions spec/mailers/user_mailer_spec.rb
@@ -0,0 +1,5 @@
require "spec_helper"

describe UserMailer do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit 29e8ded

Please sign in to comment.