Set ActionMailer configuration in FoodsoftConfig
This commit is contained in:
parent
e6e8c845cd
commit
43c1833cd7
3 changed files with 8 additions and 18 deletions
|
@ -16,7 +16,6 @@ class Mailer < ActionMailer::Base
|
||||||
# Sends an email with instructions on how to reset the password.
|
# Sends an email with instructions on how to reset the password.
|
||||||
# Assumes user.setResetPasswordToken has been successfully called already.
|
# Assumes user.setResetPasswordToken has been successfully called already.
|
||||||
def reset_password(user)
|
def reset_password(user)
|
||||||
set_foodcoop_scope
|
|
||||||
@user = user
|
@user = user
|
||||||
@link = new_password_url(id: @user.id, token: @user.reset_password_token)
|
@link = new_password_url(id: @user.id, token: @user.reset_password_token)
|
||||||
|
|
||||||
|
@ -26,7 +25,6 @@ class Mailer < ActionMailer::Base
|
||||||
|
|
||||||
# Sends an invite email.
|
# Sends an invite email.
|
||||||
def invite(invite)
|
def invite(invite)
|
||||||
set_foodcoop_scope
|
|
||||||
@invite = invite
|
@invite = invite
|
||||||
@link = accept_invitation_url(token: @invite.token)
|
@link = accept_invitation_url(token: @invite.token)
|
||||||
|
|
||||||
|
@ -36,7 +34,6 @@ class Mailer < ActionMailer::Base
|
||||||
|
|
||||||
# Notify user of upcoming task.
|
# Notify user of upcoming task.
|
||||||
def upcoming_tasks(user, task)
|
def upcoming_tasks(user, task)
|
||||||
set_foodcoop_scope
|
|
||||||
@user = user
|
@user = user
|
||||||
@task = task
|
@task = task
|
||||||
|
|
||||||
|
@ -46,7 +43,6 @@ class Mailer < ActionMailer::Base
|
||||||
|
|
||||||
# Sends order result for specific Ordergroup
|
# Sends order result for specific Ordergroup
|
||||||
def order_result(user, group_order)
|
def order_result(user, group_order)
|
||||||
set_foodcoop_scope
|
|
||||||
@order = group_order.order
|
@order = group_order.order
|
||||||
@group_order = group_order
|
@group_order = group_order
|
||||||
|
|
||||||
|
@ -56,7 +52,6 @@ class Mailer < ActionMailer::Base
|
||||||
|
|
||||||
# Notify user if account balance is less than zero
|
# Notify user if account balance is less than zero
|
||||||
def negative_balance(user,transaction)
|
def negative_balance(user,transaction)
|
||||||
set_foodcoop_scope
|
|
||||||
@group = user.ordergroup
|
@group = user.ordergroup
|
||||||
@transaction = transaction
|
@transaction = transaction
|
||||||
|
|
||||||
|
@ -65,7 +60,6 @@ class Mailer < ActionMailer::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def feedback(user, feedback)
|
def feedback(user, feedback)
|
||||||
set_foodcoop_scope
|
|
||||||
@user = user
|
@user = user
|
||||||
@feedback = feedback
|
@feedback = feedback
|
||||||
|
|
||||||
|
@ -77,7 +71,6 @@ class Mailer < ActionMailer::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def not_enough_users_assigned(task, user)
|
def not_enough_users_assigned(task, user)
|
||||||
set_foodcoop_scope
|
|
||||||
@task = task
|
@task = task
|
||||||
@user = user
|
@user = user
|
||||||
|
|
||||||
|
@ -85,14 +78,4 @@ class Mailer < ActionMailer::Base
|
||||||
:subject => "[#{FoodsoftConfig[:name]}] " + I18n.t('mailer.not_enough_users_assigned.subject', :task => task.name)
|
:subject => "[#{FoodsoftConfig[:name]}] " + I18n.t('mailer.not_enough_users_assigned.subject', :task => task.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
# @todo this global stuff gives threading problems when foodcoops have different values! - pass args to `url_for` instead
|
|
||||||
def set_foodcoop_scope(foodcoop = FoodsoftConfig.scope)
|
|
||||||
[:protocol, :host, :port, :script_name].each do |k|
|
|
||||||
ActionMailer::Base.default_url_options[k] = FoodsoftConfig[k] if FoodsoftConfig[k]
|
|
||||||
end
|
|
||||||
ActionMailer::Base.default_url_options[:foodcoop] = foodcoop
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -78,6 +78,7 @@ class FoodsoftConfig
|
||||||
def select_foodcoop(foodcoop)
|
def select_foodcoop(foodcoop)
|
||||||
set_config foodcoop
|
set_config foodcoop
|
||||||
setup_database
|
setup_database
|
||||||
|
setup_mailing
|
||||||
end
|
end
|
||||||
|
|
||||||
def select_default_foodcoop
|
def select_default_foodcoop
|
||||||
|
@ -220,6 +221,13 @@ class FoodsoftConfig
|
||||||
ActiveRecord::Base.establish_connection(database_config)
|
ActiveRecord::Base.establish_connection(database_config)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def setup_mailing
|
||||||
|
[:protocol, :host, :port, :script_name].each do |k|
|
||||||
|
ActionMailer::Base.default_url_options[k] = self[k] if self[k]
|
||||||
|
end
|
||||||
|
ActionMailer::Base.default_url_options[:foodcoop] = scope
|
||||||
|
end
|
||||||
|
|
||||||
# Completes foodcoop configuration with program defaults.
|
# Completes foodcoop configuration with program defaults.
|
||||||
# @see #foodsoft_config
|
# @see #foodsoft_config
|
||||||
def set_missing
|
def set_missing
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
class MessagesMailer < Mailer
|
class MessagesMailer < Mailer
|
||||||
# Sends an email copy of the given internal foodsoft message.
|
# Sends an email copy of the given internal foodsoft message.
|
||||||
def foodsoft_message(message, recipient)
|
def foodsoft_message(message, recipient)
|
||||||
set_foodcoop_scope
|
|
||||||
@message = message
|
@message = message
|
||||||
|
|
||||||
reply_email_domain = FoodsoftConfig[:reply_email_domain]
|
reply_email_domain = FoodsoftConfig[:reply_email_domain]
|
||||||
|
|
Loading…
Reference in a new issue