2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-04-09 09:55:36 +02:00
|
|
|
class ExpertMailer < ApplicationMailer
|
|
|
|
helper MailerHelper
|
|
|
|
layout 'mailers/layout'
|
|
|
|
|
2022-10-06 15:17:54 +02:00
|
|
|
# TODO: replace with v2 after MEP
|
2021-04-09 09:55:36 +02:00
|
|
|
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
|
2023-10-18 07:10:26 +02:00
|
|
|
|
|
|
|
def self.critical_email?(action_name)
|
|
|
|
false
|
|
|
|
end
|
2021-04-09 09:55:36 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def decision_dossier(dossier)
|
|
|
|
if dossier.accepte?
|
|
|
|
'accepté'
|
|
|
|
elsif dossier.sans_suite?
|
|
|
|
'classé sans suite'
|
|
|
|
elsif dossier.refuse?
|
|
|
|
'refusé'
|
|
|
|
end
|
|
|
|
end
|