2015-08-10 11:05:06 +02:00
|
|
|
class Commentaire < ActiveRecord::Base
|
|
|
|
belongs_to :dossier
|
2016-11-14 18:00:26 +01:00
|
|
|
belongs_to :champ
|
2016-04-20 16:51:57 +02:00
|
|
|
|
|
|
|
belongs_to :piece_justificative
|
2016-11-25 11:08:58 +01:00
|
|
|
|
2017-05-12 10:03:21 +02:00
|
|
|
after_save :notify_gestionnaires
|
2016-12-26 11:08:53 +01:00
|
|
|
|
2016-11-25 11:08:58 +01:00
|
|
|
def header
|
2017-04-18 17:33:24 +02:00
|
|
|
"#{email}, " + I18n.l(created_at.localtime, format: '%d %b %Y %H:%M')
|
2016-11-25 11:08:58 +01:00
|
|
|
end
|
2016-12-26 11:08:53 +01:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-05-12 10:03:21 +02:00
|
|
|
def notify_gestionnaires
|
2016-12-26 14:45:42 +01:00
|
|
|
if email == dossier.user.email || dossier.invites_user.pluck(:email).to_a.include?(email)
|
2016-12-26 14:38:00 +01:00
|
|
|
NotificationService.new('commentaire', self.dossier.id).notify
|
|
|
|
end
|
2016-12-26 11:08:53 +01:00
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|