2020-08-06 16:35:45 +02:00
# == Schema Information
#
# Table name: initiated_mails
#
# id :integer not null, primary key
# body :text
# subject :string
# created_at :datetime not null
# updated_at :datetime not null
# procedure_id :integer
#
2017-03-06 22:37:37 +01:00
module Mails
2017-05-27 00:44:01 +02:00
class InitiatedMail < ApplicationRecord
2017-03-06 22:37:37 +01:00
include MailTemplateConcern
2020-07-20 17:25:17 +02:00
belongs_to :procedure , optional : false
2017-12-22 21:37:08 +01:00
2017-05-27 00:52:32 +02:00
SLUG = " initiated_mail "
2019-07-18 18:25:11 +02:00
DEFAULT_TEMPLATE_NAME = " notification_mailer/default_templates/initiated_mail "
2022-05-12 16:42:21 +02:00
DISPLAYED_NAME = I18n . t ( 'activerecord.models.mail.initiated_mail.proof_of_receipt' )
DEFAULT_SUBJECT = I18n . t ( 'activerecord.models.mail.initiated_mail.default_subject' , dossier_number : '--numéro du dossier--' , procedure_libelle : '--libellé démarche--' )
2018-08-28 14:10:55 +02:00
DOSSIER_STATE = Dossier . states . fetch ( :en_construction )
2022-05-10 16:23:22 +02:00
def attachment_for_dossier ( dossier )
if procedure . feature_enabled? ( :procedure_dossier_papertrail )
{
filename : I18n . t ( 'users.dossiers.show.papertrail.filename' ) ,
content : deposit_receipt_for_dossier ( dossier )
}
end
end
private
def deposit_receipt_for_dossier ( dossier )
ApplicationController . render (
template : 'users/dossiers/papertrail' ,
formats : [ :pdf ] ,
assigns : { dossier : dossier }
)
end
2017-03-06 22:37:37 +01:00
end
end