Send a notification to administrators on new event
This commit is contained in:
parent
8778f6e045
commit
1321eb67cf
8
app/mailers/event_mailer.rb
Normal file
8
app/mailers/event_mailer.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
class EventMailer < ActionMailer::Base
|
||||||
|
def new_event_notification(event)
|
||||||
|
@users = User.where(admin: true)
|
||||||
|
@event = event
|
||||||
|
mail(to: @users.map(&:email), subject: "Ново предложение за #{@event.class.model_name.human.mb_chars.downcase.to_s}: #{@event.title}")
|
||||||
|
end
|
||||||
|
end
|
@ -8,4 +8,12 @@ class Event < ActiveRecord::Base
|
|||||||
belongs_to :track
|
belongs_to :track
|
||||||
has_one :conference, through: :track
|
has_one :conference, through: :track
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
|
after_create :send_new_event_notification
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def send_new_event_notification
|
||||||
|
EventMailer.new_event_notification(self).deliver
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
24
app/views/event_mailer/new_event_notification.text.erb
Normal file
24
app/views/event_mailer/new_event_notification.text.erb
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
Здравейте,
|
||||||
|
|
||||||
|
Беше получено следното предложение за <%= @event.class.model_name.human.mb_chars.downcase.to_s %>:
|
||||||
|
|
||||||
|
Потребител: <%= @event.user.email %>
|
||||||
|
|
||||||
|
Заглавие: <%= @event.title %>
|
||||||
|
|
||||||
|
Подзаглавие: <%= @event.title %>
|
||||||
|
|
||||||
|
Поток: <%= @event.track.name %>
|
||||||
|
|
||||||
|
Продължителност: <%= @event.length %>
|
||||||
|
|
||||||
|
Език: <%= @event.language %>
|
||||||
|
|
||||||
|
Резюме:
|
||||||
|
<%= @event.abstract %>
|
||||||
|
|
||||||
|
Описание:
|
||||||
|
<%= @event.description %>
|
||||||
|
|
||||||
|
Забележки:
|
||||||
|
<%= @event.notes %>
|
5
db/migrate/20140902144335_add_admin_flag_to_users.rb
Normal file
5
db/migrate/20140902144335_add_admin_flag_to_users.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class AddAdminFlagToUsers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :users, :admin, :boolean, null: false, default: false
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user