Send a notification to administrators on new event
This commit is contained in:
parent
8778f6e045
commit
1321eb67cf
|
@ -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
|
||||
has_one :conference, through: :track
|
||||
belongs_to :user
|
||||
|
||||
after_create :send_new_event_notification
|
||||
|
||||
private
|
||||
|
||||
def send_new_event_notification
|
||||
EventMailer.new_event_notification(self).deliver
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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 %>
|
|
@ -0,0 +1,5 @@
|
|||
class AddAdminFlagToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :admin, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue