allows unfeasible emails only to be send out once

This commit is contained in:
rgarcia
2016-03-28 18:06:43 +02:00
parent 8a8f062398
commit 467c06c3ca
6 changed files with 45 additions and 14 deletions

View File

@@ -69,15 +69,24 @@ class SpendingProposal < ActiveRecord::Base
end
def marked_as_unfeasible?
previous_changes.has_key?("feasible") && unfeasible?
unfeasible_email_sent_at.blank? && unfeasible? && valuation_finished?
end
def unfeasible?
not feasible?
end
def valuation_finished?
valuation_finished
end
def code
"#{id}" + (administrator.present? ? "-A#{administrator.id}" : "")
end
def send_unfeasible_email
Mailer.unfeasible_spending_proposal(self).deliver_later
update(unfeasible_email_sent_at: Time.now)
end
end