Refactor NotificationMailer

This commit is contained in:
Paul Chavard 2021-04-29 19:10:22 +02:00
parent a4fd629f4a
commit f6508899de
9 changed files with 128 additions and 70 deletions

View file

@ -500,6 +500,23 @@ class Procedure < ApplicationRecord
without_continuation_mail || Mails::WithoutContinuationMail.default_for_procedure(self)
end
def mail_template_for(state)
case state
when Dossier.states.fetch(:en_construction)
initiated_mail_template
when Dossier.states.fetch(:en_instruction)
received_mail_template
when Dossier.states.fetch(:accepte)
closed_mail_template
when Dossier.states.fetch(:refuse)
refused_mail_template
when Dossier.states.fetch(:sans_suite)
without_continuation_mail_template
else
raise "Unknown dossier state: #{state}"
end
end
def self.default_sort
{
'table' => 'self',