2015-08-10 11:05:06 +02:00
|
|
|
class CommentairesController < ApplicationController
|
|
|
|
def create
|
2015-08-11 15:22:07 +02:00
|
|
|
@commentaire = Commentaire.new
|
2015-08-10 11:05:06 +02:00
|
|
|
@commentaire.dossier = Dossier.find(params['dossier_id'])
|
|
|
|
|
2015-09-25 10:46:09 +02:00
|
|
|
if is_gestionnaire?
|
|
|
|
@commentaire.email = current_gestionnaire.email
|
|
|
|
@commentaire.dossier.next_step! 'gestionnaire', 'comment'
|
|
|
|
else #is_user
|
|
|
|
@commentaire.email = current_user.email
|
|
|
|
@commentaire.dossier.next_step! 'user', 'comment'
|
|
|
|
end
|
|
|
|
|
|
|
|
@commentaire.body = params['texte_commentaire']
|
2015-08-10 11:05:06 +02:00
|
|
|
@commentaire.save
|
|
|
|
|
2015-09-22 15:00:59 +02:00
|
|
|
if is_gestionnaire?
|
2015-12-15 15:33:21 +01:00
|
|
|
NotificationMailer.new_answer(@commentaire.dossier).deliver_now!
|
2015-09-22 15:00:59 +02:00
|
|
|
redirect_to url_for(controller: 'backoffice/dossiers', action: :show, id: params['dossier_id'])
|
2015-08-10 11:05:06 +02:00
|
|
|
else
|
2015-09-22 15:00:59 +02:00
|
|
|
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: params['dossier_id'])
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
end
|
2015-09-22 15:00:59 +02:00
|
|
|
|
|
|
|
def is_gestionnaire?
|
|
|
|
false
|
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|