2009-01-06 11:49:19 +01:00
|
|
|
# ActionMailer class that handles all emails for the FoodSoft.
|
|
|
|
class Mailer < ActionMailer::Base
|
2009-02-18 01:06:35 +01:00
|
|
|
|
|
|
|
layout 'email' # Use views/layouts/email.html.erb
|
2009-01-06 11:49:19 +01:00
|
|
|
|
|
|
|
# Sends an email copy of the given internal foodsoft message.
|
|
|
|
def message(message)
|
2009-01-06 15:45:19 +01:00
|
|
|
subject "[#{APP_CONFIG[:name]}] " + message.subject
|
2009-01-06 11:49:19 +01:00
|
|
|
recipients message.recipient.email
|
2009-02-18 01:06:35 +01:00
|
|
|
from "#{message.sender.nick} <#{message.sender.email}>"
|
|
|
|
body :body => message.body,
|
|
|
|
:sender => message.sender.nick,
|
|
|
|
:recipients => message.recipients,
|
|
|
|
:reply => "#{APP_CONFIG[:base_url]}/messages/reply/#{message}",
|
|
|
|
:profile => "#{APP_CONFIG[:base_url]}/home/profile",
|
|
|
|
:link => "#{APP_CONFIG[:base_url]}/messages/show/#{message}"
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|
2009-02-18 01:06:35 +01:00
|
|
|
|
|
|
|
# Sends an email with instructions on how to reset the password.
|
|
|
|
# Assumes user.setResetPasswordToken has been successfully called already.
|
|
|
|
def reset_password(user)
|
|
|
|
prepare_system_message(user)
|
|
|
|
subject "[#{APP_CONFIG[:name]}] Neues Passwort für/ New password for #{user.nick}"
|
|
|
|
body :user => user,
|
|
|
|
:link => "#{APP_CONFIG[:base_url]}/login/password/#{user.id}?token=#{user.reset_password_token}"
|
|
|
|
end
|
|
|
|
|
2009-01-06 11:49:19 +01:00
|
|
|
# Sends an invite email.
|
|
|
|
def invite(invite)
|
2009-02-18 01:06:35 +01:00
|
|
|
prepare_system_message(invite)
|
2009-01-06 15:45:19 +01:00
|
|
|
subject "Einladung in die Foodcoop #{APP_CONFIG[:name]} - Invitation to the Foodcoop"
|
2009-01-06 11:49:19 +01:00
|
|
|
body :invite => invite,
|
2009-02-18 01:06:35 +01:00
|
|
|
:link => "#{APP_CONFIG[:base_url]}/login/invite/#{invite.token}"
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|
2009-02-10 15:07:47 +01:00
|
|
|
|
|
|
|
# Notify user of upcoming task.
|
2009-02-18 01:06:35 +01:00
|
|
|
def upcoming_tasks(user, task)
|
|
|
|
prepare_system_message(user)
|
2009-02-10 15:07:47 +01:00
|
|
|
subject "[#{APP_CONFIG[:name]}] Aufgaben werden fällig!"
|
2009-02-18 01:06:35 +01:00
|
|
|
body :user => user,
|
|
|
|
:task => task
|
|
|
|
end
|
|
|
|
|
|
|
|
# Sends order result for specific Ordergroup
|
|
|
|
def order_result(user, group_order)
|
|
|
|
prepare_system_message(user)
|
|
|
|
subject "[#{APP_CONFIG[:name]}] Bestellung beendet: #{group_order.order.name}"
|
|
|
|
body :order => group_order.order,
|
|
|
|
:group_order => group_order
|
|
|
|
end
|
|
|
|
|
|
|
|
# Notify user if account balance is less than zero
|
|
|
|
def negative_balance(user,transaction)
|
|
|
|
prepare_system_message(user)
|
|
|
|
subject "[#{APP_CONFIG[:name]}] Gruppenkonto im Minus"
|
|
|
|
body :group => user.ordergroup,
|
|
|
|
:transaction => transaction
|
|
|
|
end
|
2009-02-10 15:07:47 +01:00
|
|
|
|
2009-02-18 01:06:35 +01:00
|
|
|
protected
|
|
|
|
|
|
|
|
def prepare_system_message(recipient)
|
|
|
|
recipients recipient.email
|
|
|
|
from "FoodSoft <#{APP_CONFIG[:email_sender]}>"
|
2009-02-10 15:07:47 +01:00
|
|
|
end
|
2009-01-06 11:49:19 +01:00
|
|
|
|
|
|
|
end
|