sends unfeasible budget investment
This commit is contained in:
@@ -21,6 +21,11 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
|
||||
def valuate
|
||||
if valid_price_params? && @investment.update(valuation_params)
|
||||
|
||||
if @investment.unfeasible_email_pending?
|
||||
@investment.send_unfeasible_email
|
||||
end
|
||||
|
||||
redirect_to valuation_budget_budget_investment_path(@budget, @investment), notice: t('valuation.budget_investments.notice.valuate')
|
||||
else
|
||||
render action: :edit
|
||||
|
||||
@@ -82,6 +82,15 @@ class Mailer < ApplicationMailer
|
||||
end
|
||||
end
|
||||
|
||||
def budget_investment_unfeasible(investment)
|
||||
@investment = investment
|
||||
@author = investment.author
|
||||
|
||||
with_user(@author) do
|
||||
mail(to: @author.email, subject: t('mailers.budget_investment_unfeasible.subject', code: @investment.code))
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def with_user(user, &block)
|
||||
|
||||
@@ -136,12 +136,21 @@ class Budget
|
||||
unfeasible? && valuation_finished?
|
||||
end
|
||||
|
||||
def unfeasible_email_pending?
|
||||
unfeasible_email_sent_at.blank? && unfeasible? && valuation_finished?
|
||||
end
|
||||
|
||||
def total_votes
|
||||
cached_votes_up + physical_votes
|
||||
end
|
||||
|
||||
def code
|
||||
"B#{budget.id}I#{id}"
|
||||
"#{created_at.strftime('%Y')}-#{id}" + (administrator.present? ? "-A#{administrator.id}" : "")
|
||||
end
|
||||
|
||||
def send_unfeasible_email
|
||||
Mailer.budget_investment_unfeasible(self).deliver_later
|
||||
update(unfeasible_email_sent_at: Time.current)
|
||||
end
|
||||
|
||||
def reason_for_not_being_selectable_by(user)
|
||||
|
||||
35
app/views/mailer/budget_investment_unfeasible.html.erb
Normal file
35
app/views/mailer/budget_investment_unfeasible.html.erb
Normal file
@@ -0,0 +1,35 @@
|
||||
<td style="padding-bottom: 20px; padding-left: 10px;">
|
||||
|
||||
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;">
|
||||
<%= t("mailers.budget_investment_unfeasible.hi") %>
|
||||
</p>
|
||||
|
||||
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;">
|
||||
<%= t("mailers.budget_investment_unfeasible.unfeasible_html",
|
||||
title: @investment.title) %>
|
||||
</p>
|
||||
|
||||
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px; padding-left: 12px; border-left: 2px solid #ccc;">
|
||||
<%= @investment.unfeasibility_explanation %>
|
||||
</p>
|
||||
|
||||
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;">
|
||||
<%= t("mailers.budget_investment_unfeasible.new_html",
|
||||
url: link_to(t("mailers.budget_investment_unfeasible.new_href"),
|
||||
new_budget_investment_url(@investment.budget), style: "color: #2895F1; text-decoration: underline;")) %>
|
||||
</p>
|
||||
|
||||
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;">
|
||||
<%= t("mailers.budget_investment_unfeasible.reconsider_html", code: @investment.code) %>
|
||||
</p>
|
||||
|
||||
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;">
|
||||
<%= t("mailers.budget_investment_unfeasible.sorry") %>
|
||||
</p>
|
||||
|
||||
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;">
|
||||
<%= t("mailers.budget_investment_unfeasible.sincerely") %><br>
|
||||
<span style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 12px;font-weight: normal;line-height: 24px; color: #ccc;">
|
||||
<%= t("mailers.budget_investment_unfeasible.signatory") %></span>
|
||||
</p>
|
||||
</td>
|
||||
Reference in New Issue
Block a user