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
mail(to: 'core@openfest.org', subject: "Ново предложение за #{@event.class.model_name.human.mb_chars.downcase.to_s}: #{@event.title}")
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

View File

@ -19,6 +19,11 @@ class Event < ActiveRecord::Base
STATE_TO_GLYPH = {undecided: 'question-sign', rejected: 'remove', approved: 'ok', backup: 'retweet'}
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
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.
bg:
event_mailer:
acceptance_notification:
subject: 'Предложението ви за %{conference} е одобрено'
activerecord:
models:
user:

View File

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