Send a notification to administrators on new event

This commit is contained in:
Petko Bordjukov 2014-09-02 18:11:35 +03:00
parent 8778f6e045
commit 1321eb67cf
4 changed files with 45 additions and 0 deletions

View 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

View File

@ -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

View 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 %>

View File

@ -0,0 +1,5 @@
class AddAdminFlagToUsers < ActiveRecord::Migration
def change
add_column :users, :admin, :boolean, null: false, default: false
end
end