2017-03-06 11:51:34 +01:00
|
|
|
module MailTemplateConcern
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
include Rails.application.routes.url_helpers
|
|
|
|
include ActionView::Helpers::UrlHelper
|
2018-01-04 10:37:40 +01:00
|
|
|
include TagsSubstitutionConcern
|
2017-05-03 11:46:41 +02:00
|
|
|
|
2018-01-08 17:26:13 +01:00
|
|
|
def subject_for_dossier(dossier)
|
|
|
|
replace_tags(subject, dossier)
|
2017-03-06 11:51:34 +01:00
|
|
|
end
|
|
|
|
|
2017-05-03 11:58:34 +02:00
|
|
|
def body_for_dossier(dossier)
|
2017-03-06 11:51:34 +01:00
|
|
|
replace_tags(body, dossier)
|
|
|
|
end
|
|
|
|
|
2018-01-04 16:34:23 +01:00
|
|
|
def tags(is_dossier_termine: self.class.const_get(:IS_DOSSIER_TERMINE))
|
|
|
|
super
|
2017-03-06 11:51:34 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
module ClassMethods
|
2017-12-22 21:37:08 +01:00
|
|
|
def default_for_procedure(procedure)
|
2017-05-27 01:16:38 +02:00
|
|
|
body = ActionController::Base.new.render_to_string(template: self.const_get(:TEMPLATE_NAME))
|
2018-01-08 17:26:13 +01:00
|
|
|
self.new(subject: self.const_get(:DEFAULT_SUBJECT), body: body, procedure: procedure)
|
2017-03-06 11:51:34 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-01-04 10:37:40 +01:00
|
|
|
def dossier_tags
|
2018-01-04 16:34:23 +01:00
|
|
|
super + [{ libelle: 'lien dossier', description: '', lambda: -> (d) { users_dossier_recapitulatif_link(d) } }]
|
2018-01-04 10:37:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def users_dossier_recapitulatif_link(dossier)
|
|
|
|
url = users_dossier_recapitulatif_url(dossier)
|
|
|
|
link_to(url, url, target: '_blank')
|
2017-03-06 11:51:34 +01:00
|
|
|
end
|
|
|
|
end
|