2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-10-26 16:10:38 +01:00
|
|
|
class RootController < ApplicationController
|
2024-04-23 17:30:13 +02:00
|
|
|
before_action :authenticate_administrateur!, only: :patron
|
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
|
|
|
|
2024-04-23 17:30:13 +02:00
|
|
|
procedure = Procedure.create_with(for_individual: true,
|
|
|
|
administrateurs: [current_administrateur],
|
|
|
|
duree_conservation_dossiers_dans_ds: 1,
|
|
|
|
max_duree_conservation_dossiers_dans_ds: Expired::DEFAULT_DOSSIER_RENTENTION_IN_MONTH,
|
|
|
|
cadre_juridique: 'http://www.legifrance.gouv.fr',
|
|
|
|
description:).find_or_initialize_by(libelle: 'Démarche de demo pour la page patron')
|
2017-07-25 14:33:03 +02:00
|
|
|
|
2024-04-23 17:30:13 +02:00
|
|
|
if procedure.new_record?
|
|
|
|
Procedure.transaction do
|
|
|
|
procedure.draft_revision = procedure.revisions.build
|
|
|
|
procedure.save!
|
|
|
|
after_stable_id = nil
|
|
|
|
TypeDeChamp.type_champs.values.sort.each do |type_champ|
|
|
|
|
type_de_champ = procedure.draft_revision
|
|
|
|
.add_type_de_champ(type_champ:, libelle: type_champ.humanize, description:, mandatory: true, private: false, after_stable_id:)
|
|
|
|
after_stable_id = type_de_champ.stable_id
|
2017-07-25 14:33:03 +02:00
|
|
|
|
2024-04-23 17:30:13 +02:00
|
|
|
if type_de_champ.repetition?
|
|
|
|
repetition_after_stable_id = nil
|
|
|
|
['text', 'integer_number', 'checkbox'].each do |type_champ|
|
|
|
|
repetition_type_de_champ = procedure.draft_revision
|
|
|
|
.add_type_de_champ(type_champ:, libelle: type_champ.humanize, description:, mandatory: true, private: false, parent_stable_id: type_de_champ.stable_id, after_stable_id: repetition_after_stable_id)
|
|
|
|
repetition_after_stable_id = repetition_type_de_champ.stable_id
|
|
|
|
end
|
|
|
|
elsif type_de_champ.linked_drop_down_list?
|
|
|
|
type_de_champ.drop_down_list_value =
|
|
|
|
"-- section 1 --
|
|
|
|
option A
|
|
|
|
option B
|
|
|
|
-- section 2 --
|
|
|
|
option C"
|
|
|
|
type_de_champ.save
|
|
|
|
elsif type_de_champ.drop_down_list?
|
|
|
|
type_de_champ.drop_down_list_value =
|
|
|
|
"option A
|
|
|
|
option B
|
|
|
|
-- avant l'option C --
|
|
|
|
option C"
|
|
|
|
type_de_champ.save
|
|
|
|
end
|
2020-07-17 11:07:33 +02:00
|
|
|
end
|
2017-07-25 14:33:03 +02:00
|
|
|
end
|
|
|
|
end
|
2017-08-02 14:56:08 +02:00
|
|
|
|
2024-04-23 17:30:13 +02:00
|
|
|
@dossier = procedure.draft_revision.dossier_for_preview(current_user)
|
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
|