Implement an acceptance mailer with localized views

This commit is contained in:
Petko Bordjukov 2014-10-12 14:54:06 +03:00
parent 27677e2d0a
commit 97fcc32990
7 changed files with 25 additions and 0 deletions

View File

@ -4,4 +4,10 @@ class EventMailer < ActionMailer::Base
@event = event @event = event
mail(to: 'core@openfest.org', subject: "Ново предложение за #{@event.class.model_name.human.mb_chars.downcase.to_s}: #{@event.title}") mail(to: 'core@openfest.org', subject: "Ново предложение за #{@event.class.model_name.human.mb_chars.downcase.to_s}: #{@event.title}")
end end
def acceptance_notification(event)
@event = event
I18n.locale = @event.language
mail to: @event.user.email, from: 'cfp@openfest.org', subject: I18n.t('event_mailer.acceptance_notification.subject', conference: @event.conference.title)
end
end end

View File

@ -19,6 +19,11 @@ class Event < ActiveRecord::Base
STATE_TO_GLYPH = {undecided: 'question-sign', rejected: 'remove', approved: 'ok', backup: 'retweet'} STATE_TO_GLYPH = {undecided: 'question-sign', rejected: 'remove', approved: 'ok', backup: 'retweet'}
STATE_TO_CLASS = {undecided: 'warning', rejected: 'danger', approved: 'success', backup: 'info'} STATE_TO_CLASS = {undecided: 'warning', rejected: 'danger', approved: 'success', backup: 'info'}
def send_acceptance_notification!
EventMailer.acceptance_notification(self).deliver
touch :acceptance_notification_sent_at
end
private private
def send_new_event_notification def send_new_event_notification

View File

@ -0,0 +1 @@
Предложението ви е одобрено

View File

@ -0,0 +1 @@
Your submission was approved

View File

@ -20,6 +20,9 @@
# available at http://guides.rubyonrails.org/i18n.html. # available at http://guides.rubyonrails.org/i18n.html.
bg: bg:
event_mailer:
acceptance_notification:
subject: 'Предложението ви за %{conference} е одобрено'
activerecord: activerecord:
models: models:
user: user:

View File

@ -20,6 +20,9 @@
# available at http://guides.rubyonrails.org/i18n.html. # available at http://guides.rubyonrails.org/i18n.html.
en: en:
event_mailer:
acceptance_notification:
subject: 'Your submission for %{conference} has been approved'
activerecord: activerecord:
models: models:
user: user:

View File

@ -0,0 +1,6 @@
class AddAcceptanceEmailFieldsToEvents < ActiveRecord::Migration
def change
add_column :events, :acceptance_notification_sent_at, :timestamp
add_column :events, :confirmed_at, :timestamp
end
end