2015-10-26 16:10:38 +01:00
class RootController < ApplicationController
2017-06-14 14:42:09 +02:00
layout 'new_application'
2015-10-26 16:10:38 +01:00
def index
2018-01-15 10:02:10 +01:00
if administrateur_signed_in?
2016-12-19 16:54:41 +01:00
return redirect_to admin_procedures_path
elsif gestionnaire_signed_in?
2018-02-21 15:06:21 +01:00
return redirect_to gestionnaire_procedures_path
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
2016-02-23 16:51:24 +01:00
elsif administration_signed_in?
2018-01-16 17:09:25 +01:00
return redirect_to manager_root_path
2015-10-26 16:10:38 +01:00
end
2016-12-14 18:41:33 +01:00
2018-02-28 16:34:00 +01:00
if Date . today < Date . new ( 2018 , 03 , 31 )
2018-03-13 11:24:12 +01:00
flash . now . notice = [ " Téléprocédures Simplifiées change de nom et devient demarches-simplifiees.fr, <a href='https://demarches-simplifiees.gitbooks.io/demarches-simplifiees/content/changement-de-nom.html' target='_blank' rel='noopener noreferrer'>en savoir plus</a>. " ]
2018-02-28 16:34:00 +01:00
end
2017-06-14 14:42:09 +02:00
render 'landing'
end
def patron
2018-02-28 17:14:00 +01:00
description = 'aller voir le super site : https://demarches-simplifiees.fr'
2017-08-02 15:29:12 +02:00
2017-08-02 14:56:08 +02:00
all_champs = TypeDeChamp . type_champs
2018-02-13 15:38:26 +01:00
. map { | name , _ | TypeDeChamp . new ( type_champ : name , private : false , libelle : name , description : description , mandatory : true ) }
2018-02-09 17:38:30 +01:00
. map . with_index { | type_de_champ , i | type_de_champ . champ . build ( id : i ) }
2017-07-25 14:33:03 +02:00
2017-08-02 14:56:08 +02:00
all_champs
2017-07-25 14:33:03 +02:00
. select { | champ | champ . type_champ == 'header_section' }
. each { | champ | champ . type_de_champ . libelle = 'un super titre de section' }
2017-08-02 14:56:08 +02:00
all_champs
2017-07-25 14:33:03 +02:00
. select { | champ | %w( drop_down_list multiple_drop_down_list ) . include? ( champ . type_champ ) }
. each do | champ |
champ . type_de_champ . drop_down_list = DropDownList . new ( type_de_champ : champ . type_de_champ )
champ . drop_down_list . value =
2018-01-15 18:48:14 +01:00
" option A
option B
- - avant l ' option C - -
option C "
2017-07-25 14:33:03 +02:00
champ . value = '["option B", "option C"]'
end
type_champ_values = {
'date' : '2016-07-26' ,
'datetime' : '26/07/2016 07:35' ,
2018-02-28 17:14:00 +01:00
'textarea' : 'Une description de mon projet'
2017-07-25 14:33:03 +02:00
}
type_champ_values . each do | ( type_champ , value ) |
2017-08-02 14:56:08 +02:00
all_champs
2017-07-25 14:33:03 +02:00
. select { | champ | champ . type_champ == type_champ . to_s }
. each { | champ | champ . value = value }
end
2017-08-02 14:56:08 +02:00
@dossier = Dossier . new ( champs : all_champs )
2015-10-26 16:10:38 +01:00
end
2016-12-13 16:10:03 +01:00
end