Basic proposition creation mailer
This commit is contained in:
parent
6c8b0c304b
commit
4d7b3aea6c
|
@ -0,0 +1,7 @@
|
||||||
|
# coding: utf-8
|
||||||
|
class PropositionMailer < ActionMailer::Base
|
||||||
|
def new_proposition_notification(proposition)
|
||||||
|
@proposition = proposition
|
||||||
|
mail(to: proposition.proposable.conference.email, subject: "Ново предложение за #{@proposition.proposable_type}: #{@proposition.proposable_title}")
|
||||||
|
end
|
||||||
|
end
|
|
@ -4,9 +4,25 @@ module Proposable
|
||||||
included do
|
included do
|
||||||
has_one :proposition, as: :proposable
|
has_one :proposition, as: :proposable
|
||||||
has_one :proposer, through: :proposition
|
has_one :proposer, through: :proposition
|
||||||
|
delegate :email, to: :proposer, prefix: true
|
||||||
|
|
||||||
Proposition.defined_enums["status"].keys.each do |status|
|
Proposition.defined_enums["status"].keys.each do |status|
|
||||||
scope status.to_sym, -> { joins(:proposition).where(propositions: {status: Proposition.defined_enums["status"][status]}) }
|
scope status.to_sym, -> { joins(:proposition).where(propositions: {status: Proposition.defined_enums["status"][status]}) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def proposable_type
|
||||||
|
self.class.model_name.human
|
||||||
|
end
|
||||||
|
|
||||||
|
def notification_email
|
||||||
|
conference.email
|
||||||
|
end
|
||||||
|
|
||||||
|
def proposable_title
|
||||||
|
title
|
||||||
|
end
|
||||||
|
|
||||||
|
def proposable_description
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,6 +33,24 @@ class Event < ActiveRecord::Base
|
||||||
read_attribute(:length) || event_type.try(:minimum_length)
|
read_attribute(:length) || event_type.try(:minimum_length)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def proposable_type
|
||||||
|
event_type.name
|
||||||
|
end
|
||||||
|
|
||||||
|
def proposable_description
|
||||||
|
{
|
||||||
|
proposer_email: proposer_email,
|
||||||
|
title: title,
|
||||||
|
subtitle: subtitle,
|
||||||
|
track: track.name,
|
||||||
|
length: "#{length} m",
|
||||||
|
language: language,
|
||||||
|
abstract: abstract,
|
||||||
|
description: description,
|
||||||
|
notes: notes
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def track_belongs_to_the_selected_conference
|
def track_belongs_to_the_selected_conference
|
||||||
|
|
|
@ -3,4 +3,10 @@ class Proposition < ActiveRecord::Base
|
||||||
belongs_to :proposable, polymorphic: true
|
belongs_to :proposable, polymorphic: true
|
||||||
|
|
||||||
enum status: [:undecided, :approved, :rejected, :backup]
|
enum status: [:undecided, :approved, :rejected, :backup]
|
||||||
|
|
||||||
|
delegate :proposable_title, :proposable_type, :proposable_description, to: :proposable
|
||||||
|
|
||||||
|
def send_creation_notification
|
||||||
|
PropositionMailer.new_proposition_notification(self).deliver_later
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
Здравейте,
|
||||||
|
|
||||||
|
Беше получено следното предложение за <%= @proposition.proposable_type %>:
|
||||||
|
|
||||||
|
<% @proposition.proposable_description.each do |key, value| %>
|
||||||
|
<%= @proposition.proposable.class.human_attribute_name(key) %>: <%= value %>
|
||||||
|
|
||||||
|
<% end %>
|
|
@ -0,0 +1,3 @@
|
||||||
|
PropositionMailer#new_proposition_notification
|
||||||
|
|
||||||
|
= @greeting + ", find me in app/views/proposition_mailer/new_proposition_notification.text.slim"
|
Loading…
Reference in New Issue