2015-10-26 16:10:38 +01:00
|
|
|
class RootController < ApplicationController
|
|
|
|
def index
|
2017-01-10 11:03:12 +01:00
|
|
|
|
|
|
|
begin
|
|
|
|
route = Rails.application.routes.recognize_path(request.referrer)
|
|
|
|
rescue ActionController::RoutingError
|
|
|
|
route = Rails.application.routes.recognize_path(new_user_session_path)
|
|
|
|
end
|
2016-12-05 16:17:24 +01:00
|
|
|
|
2016-12-07 14:39:06 +01:00
|
|
|
if user_signed_in? && !route[:controller].match('users').nil?
|
2016-12-05 16:17:24 +01:00
|
|
|
return redirect_to users_dossiers_path
|
2015-12-03 12:00:22 +01:00
|
|
|
|
2016-12-19 16:54:41 +01:00
|
|
|
elsif administrateur_signed_in? && !route[:controller].match('admin').nil?
|
|
|
|
return redirect_to admin_procedures_path
|
|
|
|
|
|
|
|
elsif gestionnaire_signed_in?
|
2017-04-27 16:29:04 +02:00
|
|
|
return redirect_to backoffice_invitations_path if current_gestionnaire.avis.any?
|
|
|
|
|
2016-12-14 18:41:33 +01:00
|
|
|
procedure_id = current_gestionnaire.procedure_filter
|
|
|
|
if procedure_id.nil?
|
|
|
|
procedure_list = current_gestionnaire.procedures
|
2016-12-05 16:17:24 +01:00
|
|
|
|
2016-12-14 18:41:33 +01:00
|
|
|
if procedure_list.count > 0
|
|
|
|
return redirect_to backoffice_dossiers_procedure_path(id: procedure_list.first.id)
|
|
|
|
else
|
|
|
|
flash.alert = "Vous n'avez aucune procédure d'affectée"
|
|
|
|
end
|
2016-12-19 16:54:41 +01:00
|
|
|
else
|
|
|
|
return redirect_to backoffice_dossiers_procedure_path(id: procedure_id)
|
2016-12-14 18:41:33 +01:00
|
|
|
end
|
2016-12-19 16:54:41 +01:00
|
|
|
|
2016-12-05 16:17:24 +01:00
|
|
|
elsif user_signed_in?
|
2016-12-14 18:41:33 +01:00
|
|
|
return redirect_to users_dossiers_path
|
2015-12-03 12:00:22 +01:00
|
|
|
|
2015-10-26 16:10:38 +01:00
|
|
|
elsif administrateur_signed_in?
|
2016-12-14 18:41:33 +01:00
|
|
|
return redirect_to admin_procedures_path
|
2015-12-03 12:00:22 +01:00
|
|
|
|
2016-02-23 16:51:24 +01:00
|
|
|
elsif administration_signed_in?
|
2016-12-14 18:41:33 +01:00
|
|
|
return redirect_to administrations_path
|
2015-10-26 16:10:38 +01:00
|
|
|
end
|
2016-12-14 18:41:33 +01:00
|
|
|
|
2017-01-19 17:25:50 +01:00
|
|
|
@demo_environment_host = "https://tps-dev.apientreprise.fr" unless Rails.env.development?
|
|
|
|
|
2017-04-04 14:41:13 +02:00
|
|
|
render 'landing', :layout => 'new_application'
|
2015-10-26 16:10:38 +01:00
|
|
|
end
|
2016-12-13 16:10:03 +01:00
|
|
|
end
|