2018-11-20 11:57:51 +01:00
|
|
|
# Preview all emails at http://localhost:3000/rails/mailers/avis_mailer
|
2017-05-02 15:37:06 +02:00
|
|
|
class AvisMailer < ApplicationMailer
|
2020-04-07 12:05:36 +02:00
|
|
|
helper MailerHelper
|
|
|
|
|
2018-11-23 11:04:28 +01:00
|
|
|
layout 'mailers/layout'
|
|
|
|
|
2022-06-13 13:44:06 +02:00
|
|
|
def avis_invitation(avis, targeted_user_link = nil) # ensure re-entrance if existing AvisMailer.avis_invitation in queue
|
2022-03-09 10:27:43 +01:00
|
|
|
if avis.dossier.visible_by_administration?
|
2022-06-13 13:44:06 +02:00
|
|
|
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)
|
2021-04-12 10:35:52 +02:00
|
|
|
@avis = avis
|
|
|
|
email = @avis.expert&.email
|
2022-05-23 15:09:22 +02:00
|
|
|
@url = targeted_user_link_url(targeted_user_link)
|
2021-04-12 10:35:52 +02:00
|
|
|
subject = "Donnez votre avis sur le dossier nº #{@avis.dossier.id} (#{@avis.dossier.procedure.libelle})"
|
2018-05-31 23:58:10 +02:00
|
|
|
|
2021-04-12 10:35:52 +02:00
|
|
|
mail(to: email, subject: subject)
|
|
|
|
end
|
2017-05-02 15:37:06 +02:00
|
|
|
end
|
|
|
|
end
|