From 359807b4f7f7f8a8ff337ce328fc633108d34bd3 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 14 Mar 2017 10:45:59 +0100 Subject: [PATCH] Procedure has an auto_archive date --- app/controllers/admin/procedures_controller.rb | 7 +++++-- app/views/admin/procedures/_informations.html.haml | 9 +++++++++ .../20170313140834_add_auto_archive_to_procedure.rb | 5 +++++ db/schema.rb | 3 ++- spec/models/drop_down_list_spec.rb | 8 -------- 5 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 db/migrate/20170313140834_add_auto_archive_to_procedure.rb diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index fa04bb72d..26147a6b4 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -80,6 +80,8 @@ class Admin::ProceduresController < AdminController return render 'edit' end + puts procedure_params + flash.notice = 'Procédure modifiée' redirect_to edit_admin_procedure_path(id: @procedure.id) end @@ -193,10 +195,11 @@ class Admin::ProceduresController < AdminController private def procedure_params + editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :lien_notice, :euro_flag, :logo, :auto_archive_on] if @procedure.try(:locked?) - params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_site_web, :lien_notice, :euro_flag, :logo) + params.require(:procedure).permit(*editable_params) else - params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_site_web, :lien_notice, :euro_flag, :logo, :lien_demarche, :cerfa_flag, :for_individual, :individual_with_siret, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id) + params.require(:procedure).permit(*editable_params, :lien_demarche, :cerfa_flag, :for_individual, :individual_with_siret, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id) end end diff --git a/app/views/admin/procedures/_informations.html.haml b/app/views/admin/procedures/_informations.html.haml index 833f5fee3..aede257cf 100644 --- a/app/views/admin/procedures/_informations.html.haml +++ b/app/views/admin/procedures/_informations.html.haml @@ -80,3 +80,12 @@ %label = f.check_box :individual_with_siret Donner la possibilité de renseigner un SIRET au cours de la construction du dossier. + .col-md-6 + %h4 Options avancées + + %label{ for: :auto_archive_on} Archivage automatique le + = f.text_field :auto_archive_on, id: 'auto_archive_on', value: @procedure.auto_archive_on.try{ |d| d.strftime("%d-%m-%Y") }, data: { provide: 'datepicker', 'date-format' => 'dd/mm/yyyy' } + (à 00h00 ) + + + diff --git a/db/migrate/20170313140834_add_auto_archive_to_procedure.rb b/db/migrate/20170313140834_add_auto_archive_to_procedure.rb new file mode 100644 index 000000000..7d7275651 --- /dev/null +++ b/db/migrate/20170313140834_add_auto_archive_to_procedure.rb @@ -0,0 +1,5 @@ +class AddAutoArchiveToProcedure < ActiveRecord::Migration[5.0] + def change + add_column :procedures, :auto_archive_on, :date + end +end diff --git a/db/schema.rb b/db/schema.rb index db86ebfaf..0ff0aa06a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170307092820) do +ActiveRecord::Schema.define(version: 20170313140834) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -344,6 +344,7 @@ ActiveRecord::Schema.define(version: 20170307092820) do t.string "lien_notice" t.boolean "for_individual", default: false t.boolean "individual_with_siret", default: false + t.date "auto_archive_on" end create_table "quartier_prioritaires", force: :cascade do |t| diff --git a/spec/models/drop_down_list_spec.rb b/spec/models/drop_down_list_spec.rb index 523ab2ae1..9485bc7ee 100644 --- a/spec/models/drop_down_list_spec.rb +++ b/spec/models/drop_down_list_spec.rb @@ -1,14 +1,6 @@ require 'spec_helper' describe DropDownList do - describe 'database columns' do - it { is_expected.to have_db_column(:value) } - end - - describe 'associations' do - it { is_expected.to belong_to(:type_de_champ) } - end - describe '#options' do let(:value) { "Cohésion sociale Dév.Eco / Emploi