2015-10-26 16:10:38 +01:00
|
|
|
class RootController < ApplicationController
|
2019-12-03 16:02:08 +01:00
|
|
|
include ApplicationHelper
|
|
|
|
|
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
|
2019-08-06 11:02:54 +02:00
|
|
|
elsif instructeur_signed_in?
|
|
|
|
return redirect_to instructeur_procedures_path
|
2023-12-14 10:07:34 +01:00
|
|
|
elsif expert_signed_in?
|
|
|
|
return redirect_to expert_all_avis_path
|
2016-12-05 16:17:24 +01:00
|
|
|
elsif user_signed_in?
|
2018-06-27 14:47:02 +02:00
|
|
|
return redirect_to dossiers_path
|
2020-11-05 15:09:11 +01:00
|
|
|
elsif super_admin_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
|
|
|
|
2020-10-06 14:23:15 +02:00
|
|
|
@stat = Stat.first
|
|
|
|
|
2017-06-14 14:42:09 +02:00
|
|
|
render 'landing'
|
|
|
|
end
|
|
|
|
|
2018-08-10 15:18:57 +02:00
|
|
|
def administration
|
|
|
|
end
|
|
|
|
|
2017-06-14 14:42:09 +02:00
|
|
|
def patron
|
2024-03-19 22:31:51 +01:00
|
|
|
description = "Allez voir le super site : #{Current.application_base_url}"
|
2017-08-02 15:29:12 +02:00
|
|
|
|
2017-08-02 14:56:08 +02:00
|
|
|
all_champs = TypeDeChamp.type_champs
|
2023-11-28 17:33:29 +01:00
|
|
|
.map.with_index { |(name, _), i| TypeDeChamp.new(type_champ: name, private: false, libelle: name.humanize, description:, mandatory: true, stable_id: i) }
|
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
|
2019-09-12 11:26:22 +02:00
|
|
|
.filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:header_section) }
|
2019-10-23 12:07:21 +02:00
|
|
|
.each { |champ| champ.type_de_champ.libelle = 'Un super titre de section' }
|
2017-07-25 14:33:03 +02:00
|
|
|
|
2017-08-02 14:56:08 +02:00
|
|
|
all_champs
|
2020-07-17 11:07:33 +02:00
|
|
|
.filter { |champ| champ.type_de_champ.drop_down_list? }
|
2017-07-25 14:33:03 +02:00
|
|
|
.each do |champ|
|
2020-07-17 11:07:33 +02:00
|
|
|
if champ.type_de_champ.linked_drop_down_list?
|
|
|
|
champ.type_de_champ.drop_down_list_value =
|
|
|
|
"-- section 1 --
|
|
|
|
option A
|
|
|
|
option B
|
|
|
|
-- section 2 --
|
|
|
|
option C"
|
|
|
|
else
|
|
|
|
champ.type_de_champ.drop_down_list_value =
|
|
|
|
"option A
|
|
|
|
option B
|
|
|
|
-- avant l'option C --
|
|
|
|
option C"
|
|
|
|
champ.value = '["option B", "option C"]'
|
2022-07-25 13:45:37 +02:00
|
|
|
champ.type_de_champ.drop_down_other = "1"
|
2020-07-17 11:07:33 +02:00
|
|
|
end
|
2017-07-25 14:33:03 +02:00
|
|
|
end
|
|
|
|
|
2019-10-23 12:07:33 +02:00
|
|
|
all_champs
|
|
|
|
.filter { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:repetition) }
|
|
|
|
.each do |champ_repetition|
|
|
|
|
libelles = ['Prénom', 'Nom'];
|
|
|
|
champ_repetition.champs << libelles.map.with_index do |libelle, i|
|
|
|
|
text_tdc = TypeDeChamp.new(type_champ: :text, private: false, libelle: libelle, description: description, mandatory: true)
|
|
|
|
text_tdc.champ.build(id: all_champs.length + i)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-07-25 14:33:03 +02:00
|
|
|
type_champ_values = {
|
2018-08-28 11:52:15 +02:00
|
|
|
TypeDeChamp.type_champs.fetch(:date) => '2016-07-26',
|
|
|
|
TypeDeChamp.type_champs.fetch(:datetime) => '26/07/2016 07:35',
|
|
|
|
TypeDeChamp.type_champs.fetch(: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
|
2019-09-12 11:26:22 +02:00
|
|
|
.filter { |champ| champ.type_champ == type_champ }
|
2017-07-25 14:33:03 +02:00
|
|
|
.each { |champ| champ.value = value }
|
|
|
|
end
|
2017-08-02 14:56:08 +02:00
|
|
|
|
2023-11-28 17:33:29 +01:00
|
|
|
@dossier = Dossier.new(champs: all_champs)
|
2022-11-30 10:53:51 +01:00
|
|
|
@dossier.association(:procedure).target = Procedure.new
|
2022-07-28 11:47:55 +02:00
|
|
|
all_champs.each do |champ|
|
|
|
|
champ.association(:dossier).target = @dossier
|
|
|
|
champ.champs.each do |champ|
|
|
|
|
champ.association(:dossier).target = @dossier
|
|
|
|
end
|
|
|
|
end
|
2022-12-16 12:19:49 +01:00
|
|
|
|
2023-11-28 17:33:29 +01:00
|
|
|
draft_revision = @dossier.procedure.build_draft_revision(types_de_champ: all_champs.map(&:type_de_champ))
|
2023-03-24 11:08:31 +01:00
|
|
|
@dossier.association(:revision).target = draft_revision
|
|
|
|
@dossier.champs_public.map(&:type_de_champ).map do |tdc|
|
|
|
|
tdc.association(:revision_type_de_champ).target = tdc.build_revision_type_de_champ(revision: draft_revision)
|
|
|
|
tdc.association(:revision).target = draft_revision
|
|
|
|
end
|
2015-10-26 16:10:38 +01:00
|
|
|
end
|
2018-11-07 16:54:18 +01:00
|
|
|
|
|
|
|
def suivi
|
|
|
|
end
|
2019-12-03 16:02:08 +01:00
|
|
|
|
2021-05-12 16:30:35 +02:00
|
|
|
def save_locale
|
2021-08-24 11:39:15 +02:00
|
|
|
set_locale(params[:locale])
|
|
|
|
redirect_back(fallback_location: root_path)
|
2021-05-12 16:30:35 +02:00
|
|
|
end
|
2016-12-13 16:10:03 +01:00
|
|
|
end
|