2017-03-06 11:51:34 +01:00
|
|
|
module MailTemplateConcern
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
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
|
|
|
|
|
|
|
|
module ClassMethods
|
2017-12-22 21:37:08 +01:00
|
|
|
def default_for_procedure(procedure)
|
2018-03-16 18:32:43 +01:00
|
|
|
template_name = default_template_name_for_procedure(procedure)
|
|
|
|
body = ActionController::Base.new.render_to_string(template: template_name)
|
2018-03-16 18:30:23 +01:00
|
|
|
new(subject: const_get(:DEFAULT_SUBJECT), body: body, procedure: procedure)
|
2017-03-06 11:51:34 +01:00
|
|
|
end
|
2018-03-16 18:32:43 +01:00
|
|
|
|
|
|
|
def default_template_name_for_procedure(procedure)
|
|
|
|
const_get(:DEFAULT_TEMPLATE_NAME)
|
|
|
|
end
|
2017-03-06 11:51:34 +01:00
|
|
|
end
|
|
|
|
|
2018-01-04 10:37:40 +01:00
|
|
|
def dossier_tags
|
2018-01-18 11:52:48 +01:00
|
|
|
TagsSubstitutionConcern::DOSSIER_TAGS + TagsSubstitutionConcern::DOSSIER_TAGS_FOR_MAIL
|
2017-03-06 11:51:34 +01:00
|
|
|
end
|
|
|
|
end
|