demarches-normaliennes/app/controllers/backoffice/dossiers_controller.rb
2015-11-02 16:36:52 +01:00

44 lines
1.2 KiB
Ruby

class Backoffice::DossiersController < ApplicationController
before_action :authenticate_gestionnaire!
def show
initialize_instance_params params[:id]
end
def valid
initialize_instance_params params[:dossier_id]
@dossier.next_step! 'gestionnaire', 'valid'
flash.notice = 'Dossier confirmé avec succès.'
render 'show'
end
def close
initialize_instance_params params[:dossier_id]
@dossier.next_step! 'gestionnaire', 'close'
flash.notice = 'Dossier traité avec succès.'
render 'show'
end
private
def initialize_instance_params dossier_id
@dossier = Dossier.find(dossier_id)
@entreprise = @dossier.entreprise.decorate
@etablissement = @dossier.etablissement
@pieces_justificatives = @dossier.pieces_justificatives
@commentaires = @dossier.commentaires.order(created_at: :desc)
@commentaires = @commentaires.all.decorate
@commentaire_email = current_gestionnaire.email
@procedure = @dossier.procedure
@dossier = @dossier.decorate
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for(controller: '/backoffice')
end
end