37 lines
1.3 KiB
Ruby
37 lines
1.3 KiB
Ruby
# Preview all emails at http://localhost:3000/rails/mailers/avis_mailer
|
|
class AvisMailer < ApplicationMailer
|
|
helper MailerHelper
|
|
|
|
layout 'mailers/layout'
|
|
|
|
def avis_invitation(avis, targeted_user_link = nil) # ensure re-entrance if existing AvisMailer.avis_invitation in queue
|
|
if avis.dossier.visible_by_administration?
|
|
targeted_user_link = avis.targeted_user_links
|
|
.find_or_create_by(target_context: 'avis',
|
|
target_model_type: Avis.name,
|
|
target_model_id: avis.id,
|
|
user: avis.expert.user)
|
|
@avis = avis
|
|
email = @avis.expert&.email
|
|
@url = targeted_user_link_url(targeted_user_link)
|
|
subject = "Donnez votre avis sur le dossier nº #{@avis.dossier.id} (#{@avis.dossier.procedure.libelle})"
|
|
|
|
mail(to: email, subject: subject)
|
|
end
|
|
end
|
|
|
|
# i18n-tasks-use t("avis_mailer.#{action}.subject")
|
|
def notify_new_commentaire_to_expert(dossier, avis, expert)
|
|
I18n.with_locale(dossier.user_locale) do
|
|
@dossier = dossier
|
|
@avis = avis
|
|
@subject = default_i18n_subject(dossier_id: dossier.id, libelle_demarche: dossier.procedure.libelle)
|
|
|
|
mail(to: expert.email, subject: @subject)
|
|
end
|
|
end
|
|
|
|
def self.critical_email?(action_name)
|
|
false
|
|
end
|
|
end
|