demarches-normaliennes/app/controllers/root_controller.rb

68 lines
2.3 KiB
Ruby
Raw Normal View History

class RootController < ApplicationController
2017-06-14 14:42:09 +02:00
layout 'new_application'
def index
# TODO delete new_ui when old UI is no longer used
if params[:new_ui].present? && gestionnaire_signed_in?
return redirect_to procedures_path
elsif administrateur_signed_in?
2016-12-19 16:54:41 +01:00
return redirect_to admin_procedures_path
elsif gestionnaire_signed_in?
# to be removed when old ui is deleted
if params[:old_ui].present?
return redirect_to backoffice_path
2016-12-14 18:41:33 +01:00
end
return redirect_to procedures_path
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?
2016-12-14 18:41:33 +01:00
return redirect_to administrations_path
end
2016-12-14 18:41:33 +01:00
2017-06-14 14:42:09 +02:00
render 'landing'
end
def patron
2017-08-02 15:29:12 +02:00
description = 'a not so long description'
2017-08-02 14:56:08 +02:00
all_champs = TypeDeChamp.type_champs
2017-08-02 15:29:12 +02:00
.map { |name, _| TypeDeChamp.new(type_champ: name, libelle: name, description: description, mandatory: true) }
2017-08-02 14:56:08 +02:00
.map { |type_de_champ| ChampPublic.new(type_de_champ: type_de_champ) }
.map.with_index do |champ, i|
champ.id = i
champ
end
2017-08-02 14:56:08 +02:00
all_champs
.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
.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 =
"option A
option B
-- avant l'option C --
option C"
champ.value = '["option B", "option C"]'
end
type_champ_values = {
'date': '2016-07-26',
'datetime': '26/07/2016 07:35',
'textarea': 'Une description de mon projet',
'explication': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In erat mauris, faucibus quis pharetra sit amet, pretium ac libero. Etiam vehicula eleifend bibendum. Morbi gravida metus ut sapien condimentum sodales mollis augue sodales. Vestibulum quis quam at sem placerat aliquet',
}
type_champ_values.each do |(type_champ, value)|
2017-08-02 14:56:08 +02:00
all_champs
.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)
end
end