Procedure has an auto_archive date

This commit is contained in:
Mathieu Magnin 2017-03-14 10:45:59 +01:00
parent 18b3368a29
commit 359807b4f7
5 changed files with 21 additions and 11 deletions

View file

@ -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

View file

@ -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 )

View file

@ -0,0 +1,5 @@
class AddAutoArchiveToProcedure < ActiveRecord::Migration[5.0]
def change
add_column :procedures, :auto_archive_on, :date
end
end

View file

@ -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|

View file

@ -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