From a96889310ba82530ea2b14ada1913fc787eed1f7 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 2 May 2018 15:41:43 +0200 Subject: [PATCH] Procedure: add legal reference --- app/controllers/admin/procedures_controller.rb | 2 +- app/models/procedure.rb | 1 + app/views/admin/procedures/_informations.html.haml | 4 ++++ config/locales/models/procedure/fr.yml | 14 ++++++++++++++ ...80502104006_add_cadre_juridique_to_procedure.rb | 5 +++++ db/schema.rb | 1 + .../admin/procedures_controller_spec.rb | 2 ++ spec/factories/procedure.rb | 1 + spec/features/admin/procedure_cloning_spec.rb | 1 + spec/features/admin/procedure_creation_spec.rb | 4 +++- 10 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20180502104006_add_cadre_juridique_to_procedure.rb diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index 9be16c708..10949c077 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -224,7 +224,7 @@ class Admin::ProceduresController < AdminController end def procedure_params - editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :notice, :web_hook_url, :euro_flag, :logo, :auto_archive_on] + editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :cadre_juridique, :notice, :web_hook_url, :euro_flag, :logo, :auto_archive_on] if @procedure&.locked? params.require(:procedure).permit(*editable_params) else diff --git a/app/models/procedure.rb b/app/models/procedure.rb index fb88eed0f..176076bcd 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -45,6 +45,7 @@ class Procedure < ApplicationRecord validates :libelle, presence: true, allow_blank: false, allow_nil: false validates :description, presence: true, allow_blank: false, allow_nil: false + validates :cadre_juridique, presence: true, allow_blank: false, allow_nil: false include AASM diff --git a/app/views/admin/procedures/_informations.html.haml b/app/views/admin/procedures/_informations.html.haml index eeadb6cb3..0b5bdbd2f 100644 --- a/app/views/admin/procedures/_informations.html.haml +++ b/app/views/admin/procedures/_informations.html.haml @@ -21,6 +21,10 @@ Un lien de rappel HTTP (aussi appelé webhook) est utilisé pour notifier un service tiers du changement de l'état d’un dossier sur demarches-simplifiees.fr. À chaque changement d’état d'un dossier, notre site va effectuer une requête sur le lien renseigné avec en paramètres : le nouvel état du dossier, l’identifiant de la procédure, l'identifiant dossier et la date du changement. Vous pourrez alors utiliser notre API pour récupérer les nouvelles informations du dossier concerné. = f.text_field :web_hook_url, class: 'form-control', placeholder: 'https://callback.exemple.fr/' +.form-group + %h4 Cadre juridique : indiquez la référence ou l'URL du texte juridique ou chargez la délibération qui justifie cette procédure * + = f.text_field :cadre_juridique, class: 'form-control', placeholder: 'https://www.legifrance.gouv.fr/' + .form-group %h4 Notice explicative de la procédure - notice = @procedure.notice diff --git a/config/locales/models/procedure/fr.yml b/config/locales/models/procedure/fr.yml index 1066ffc86..ef28b30a9 100644 --- a/config/locales/models/procedure/fr.yml +++ b/config/locales/models/procedure/fr.yml @@ -3,3 +3,17 @@ fr: attributes: procedure: organisation: Organisme + errors: + models: + procedure: + attributes: + libelle: + blank: Attribut manquant + description: + blank: Attribut manquant + lien_demarche: + blank: Attribut manquant + organisation: + blank: Attribut manquant + 'cadre_juridique': + blank: Attribut manquant diff --git a/db/migrate/20180502104006_add_cadre_juridique_to_procedure.rb b/db/migrate/20180502104006_add_cadre_juridique_to_procedure.rb new file mode 100644 index 000000000..91cd50287 --- /dev/null +++ b/db/migrate/20180502104006_add_cadre_juridique_to_procedure.rb @@ -0,0 +1,5 @@ +class AddCadreJuridiqueToProcedure < ActiveRecord::Migration[5.2] + def change + add_column :procedures, :cadre_juridique, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 69ee7bffb..92e8ce361 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -481,6 +481,7 @@ ActiveRecord::Schema.define(version: 2018_05_30_095508) do t.bigint "service_id" t.integer "duree_conservation_dossiers_dans_ds" t.integer "duree_conservation_dossiers_hors_ds" + t.string "cadre_juridique" t.index ["hidden_at"], name: "index_procedures_on_hidden_at" t.index ["parent_procedure_id"], name: "index_procedures_on_parent_procedure_id" t.index ["service_id"], name: "index_procedures_on_service_id" diff --git a/spec/controllers/admin/procedures_controller_spec.rb b/spec/controllers/admin/procedures_controller_spec.rb index cd6947cee..db8026e2d 100644 --- a/spec/controllers/admin/procedures_controller_spec.rb +++ b/spec/controllers/admin/procedures_controller_spec.rb @@ -15,6 +15,7 @@ describe Admin::ProceduresController, type: :controller do let(:quartiers_prioritaires) { '0' } let(:cadastre) { '0' } let(:cerfa_flag) { true } + let(:cadre_juridique) { 'cadre juridique' } let(:procedure_params) { { @@ -24,6 +25,7 @@ describe Admin::ProceduresController, type: :controller do direction: direction, lien_demarche: lien_demarche, cerfa_flag: cerfa_flag, + cadre_juridique: cadre_juridique, module_api_carto_attributes: { use_api_carto: use_api_carto, quartiers_prioritaires: quartiers_prioritaires, diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index 233d655a0..39f77d9d7 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -6,6 +6,7 @@ FactoryBot.define do description "Demande de subvention à l'intention des associations" organisation "Orga DINSIC" direction "direction DINSIC" + cadre_juridique "un cadre juridique important" published_at nil cerfa_flag false administrateur { create(:administrateur) } diff --git a/spec/features/admin/procedure_cloning_spec.rb b/spec/features/admin/procedure_cloning_spec.rb index 6cb94edf7..bfa32d8c1 100644 --- a/spec/features/admin/procedure_cloning_spec.rb +++ b/spec/features/admin/procedure_cloning_spec.rb @@ -14,6 +14,7 @@ feature 'As an administrateur I wanna clone a procedure', js: true do page.find_by_id('from-scratch').click fill_in 'procedure_libelle', with: 'libelle de la procedure' page.execute_script("$('#procedure_description').val('description de la procedure')") + fill_in 'procedure_cadre_juridique', with: 'cadre juridique' page.find_by_id('save-procedure').click end diff --git a/spec/features/admin/procedure_creation_spec.rb b/spec/features/admin/procedure_creation_spec.rb index 9523f3681..9528b1cd0 100644 --- a/spec/features/admin/procedure_creation_spec.rb +++ b/spec/features/admin/procedure_creation_spec.rb @@ -32,13 +32,14 @@ feature 'As an administrateur I wanna create a new procedure', js: true do expect(page).to have_current_path(new_admin_procedure_path) end - scenario 'Finding save button for new procedure, libelle and description required' do + scenario 'Finding save button for new procedure, libelle, description and cadre_juridique required' do page.find_by_id('new-procedure').click page.find_by_id('from-scratch').click page.find_by_id('save-procedure').click page.find_by_id('flash_message').visible? fill_in 'procedure_libelle', with: 'libelle de la procedure' page.execute_script("$('#procedure_description').val('description de la procedure')") + fill_in 'procedure_cadre_juridique', with: 'cadre juridique' page.find_by_id('save-procedure').click expect(page).to have_current_path(admin_procedure_types_de_champ_path(Procedure.first.id.to_s)) end @@ -50,6 +51,7 @@ feature 'As an administrateur I wanna create a new procedure', js: true do page.find_by_id('from-scratch').click fill_in 'procedure_libelle', with: 'libelle de la procedure' page.execute_script("$('#procedure_description').val('description de la procedure')") + fill_in 'procedure_cadre_juridique', with: 'cadre juridique' page.find_by_id('save-procedure').click procedure = Procedure.last