Move commentaire creation to model
This commit is contained in:
parent
263d85ccee
commit
5eaa2941ad
2 changed files with 8 additions and 2 deletions
|
@ -51,8 +51,6 @@ class CommentairesController < ApplicationController
|
|||
|
||||
redirect_to url_for(controller: 'backoffice/dossiers', action: :show, id: params['dossier_id'])
|
||||
else
|
||||
NotificationService.new('commentaire', @commentaire.dossier.id).notify if saved
|
||||
|
||||
if current_user.email != @commentaire.dossier.user.email
|
||||
invite = Invite.where(dossier: @commentaire.dossier, user: current_user).first
|
||||
redirect_to url_for(controller: 'users/dossiers/invites', action: :show, id: invite.id)
|
||||
|
|
|
@ -4,7 +4,15 @@ class Commentaire < ActiveRecord::Base
|
|||
|
||||
belongs_to :piece_justificative
|
||||
|
||||
after_save :internal_notification
|
||||
|
||||
def header
|
||||
"#{email}, " + created_at.localtime.strftime('%d %b %Y %H:%M')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def internal_notification
|
||||
NotificationService.new('commentaire', self.dossier.id).notify
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue