demarches-normaliennes/app/mailers/expert_mailer.rb

36 lines
969 B
Ruby
Raw Normal View History

class ExpertMailer < ApplicationMailer
helper MailerHelper
layout 'mailers/layout'
2022-10-06 15:17:54 +02:00
# TODO: replace with v2 after MEP
def send_dossier_decision(avis_id)
@avis = Avis.eager_load(:dossier).find(avis_id)
@dossier = @avis.dossier
email = @avis.expert.email
@decision = decision_dossier(@dossier)
subject = "Dossier n° #{@dossier.id} a été #{@decision} - #{@dossier.procedure.libelle}"
mail(to: email, subject: subject)
end
2022-10-06 15:17:54 +02:00
def send_dossier_decision_v2(avis)
@avis = avis
@dossier = @avis.dossier
email = @avis.expert.email
@decision = decision_dossier(@dossier)
subject = "Dossier n° #{@dossier.id} a été #{@decision} - #{@dossier.procedure.libelle}"
mail(template_name: 'send_dossier_decision', to: email, subject: subject)
end
end
def decision_dossier(dossier)
if dossier.accepte?
'accepté'
elsif dossier.sans_suite?
'classé sans suite'
elsif dossier.refuse?
'refusé'
end
end