demarches-normaliennes/app/controllers/root_controller.rb

90 lines
2.9 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
class RootController < ApplicationController
before_action :authenticate_administrateur!, only: :patron
include ApplicationHelper
def index
if administrateur_signed_in?
2016-12-19 16:54:41 +01:00
return redirect_to admin_procedures_path
elsif instructeur_signed_in?
return redirect_to instructeur_procedures_path
elsif expert_signed_in?
return redirect_to expert_all_avis_path
elsif user_signed_in?
return redirect_to dossiers_path
elsif super_admin_signed_in?
2018-01-16 17:09:25 +01:00
return redirect_to manager_root_path
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
def administration
end
2017-06-14 14:42:09 +02:00
def patron
description = "Allez voir le super site : #{Current.application_base_url}"
2017-08-02 15:29:12 +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')
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
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?
2024-09-20 10:56:12 +02:00
type_de_champ.drop_down_options =
[
"-- section 1 --",
"option A",
"option B",
"-- section 2 --",
"option C"
]
type_de_champ.save
elsif type_de_champ.any_drop_down_list?
2024-09-20 10:56:12 +02:00
type_de_champ.drop_down_options =
[
"option A",
"option B",
"-- avant l'option C --",
"option C"
]
type_de_champ.save
end
2020-07-17 11:07:33 +02:00
end
end
end
2017-08-02 14:56:08 +02:00
@dossier = procedure.draft_revision.dossier_for_preview(current_user)
end
2018-11-07 16:54:18 +01:00
def suivi
end
2021-05-12 16:30:35 +02:00
def save_locale
set_locale(params[:locale])
redirect_back(fallback_location: root_path)
2021-05-12 16:30:35 +02:00
end
end