demarches-normaliennes/app/controllers/commentaires_controller.rb
Xavier J a24ff681fc - Send email when gestionnaire write a new commentaire
- Change url on mail => redirect on dossier recapitulative page
2015-12-15 15:33:21 +01:00

28 lines
877 B
Ruby

class CommentairesController < ApplicationController
def create
@commentaire = Commentaire.new
@commentaire.dossier = Dossier.find(params['dossier_id'])
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']
@commentaire.save
if is_gestionnaire?
NotificationMailer.new_answer(@commentaire.dossier).deliver_now!
redirect_to url_for(controller: 'backoffice/dossiers', action: :show, id: params['dossier_id'])
else
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: params['dossier_id'])
end
end
def is_gestionnaire?
false
end
end