demarches-normaliennes/app/controllers/users/recapitulatif_controller.rb

45 lines
1,014 B
Ruby
Raw Normal View History

2015-09-23 19:20:03 +02:00
class Users::RecapitulatifController < UsersController
2016-01-26 15:52:05 +01:00
before_action only: [:show] do
authorized_routes? self.class
end
2015-08-10 11:05:06 +02:00
def show
if Flipflop.new_dossier_details?
redirect_to dossier_url(current_user_dossier)
else
create_dossier_facade
end
2015-08-10 11:05:06 +02:00
end
def initiate
create_dossier_facade
@facade.dossier.en_construction!
flash.notice = 'Dossier soumis avec succès.'
redirect_to users_dossier_recapitulatif_path
end
2016-01-26 15:52:05 +01:00
def self.route_authorization
{
2018-08-28 14:12:48 +02:00
states: [
Dossier.states.fetch(:en_construction),
Dossier.states.fetch(:en_instruction),
Dossier.states.fetch(:sans_suite),
Dossier.states.fetch(:accepte),
Dossier.states.fetch(:refuse)
]
2016-01-26 15:52:05 +01:00
}
end
private
def create_dossier_facade
@facade = DossierFacades.new current_user_dossier.id, current_user.email
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for(root_path)
end
2015-08-10 11:05:06 +02:00
end