Merge pull request #6630 from tchak/feat-allow-admin-to-change-duree_conservation_dossiers_dans_ds
fix(procedure): allow to modify duree_conservation_dossiers_dans_ds after publication
This commit is contained in:
commit
ea15c94e2d
5 changed files with 6 additions and 31 deletions
|
@ -251,11 +251,11 @@ module NewAdministrateur
|
|||
end
|
||||
|
||||
def procedure_params
|
||||
editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :cadre_juridique, :deliberation, :notice, :web_hook_url, :declarative_with_state, :euro_flag, :logo, :auto_archive_on, :monavis_embed, :api_entreprise_token]
|
||||
editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :cadre_juridique, :deliberation, :notice, :web_hook_url, :declarative_with_state, :logo, :auto_archive_on, :monavis_embed, :api_entreprise_token, :duree_conservation_dossiers_dans_ds]
|
||||
permited_params = if @procedure&.locked?
|
||||
params.require(:procedure).permit(*editable_params)
|
||||
else
|
||||
params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :for_individual, :path)
|
||||
params.require(:procedure).permit(*editable_params, :for_individual, :path)
|
||||
end
|
||||
if permited_params[:auto_archive_on].present?
|
||||
permited_params[:auto_archive_on] = Date.parse(permited_params[:auto_archive_on]) + 1.day
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module ConservationDeDonneesHelper
|
||||
def politiques_conservation_de_donnees(procedure)
|
||||
[conservation_dans_ds(procedure), conservation_hors_ds(procedure)].compact
|
||||
[conservation_dans_ds(procedure)].compact
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -10,10 +10,4 @@ module ConservationDeDonneesHelper
|
|||
"Dans #{APPLICATION_NAME} : #{procedure.duree_conservation_dossiers_dans_ds} mois"
|
||||
end
|
||||
end
|
||||
|
||||
def conservation_hors_ds(procedure)
|
||||
if procedure.duree_conservation_dossiers_hors_ds.present?
|
||||
"Par l’administration : #{procedure.duree_conservation_dossiers_hors_ds} mois"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#
|
||||
|
||||
class Procedure < ApplicationRecord
|
||||
self.ignored_columns = [:duree_conservation_dossiers_hors_ds]
|
||||
include ProcedureStatsConcern
|
||||
include EncryptableConcern
|
||||
include FileValidationConcern
|
||||
|
@ -238,7 +239,6 @@ class Procedure < ApplicationRecord
|
|||
validate :check_juridique
|
||||
validates :path, presence: true, format: { with: /\A[a-z0-9_\-]{3,200}\z/ }, uniqueness: { scope: [:path, :closed_at, :hidden_at, :unpublished_at], case_sensitive: false }
|
||||
validates :duree_conservation_dossiers_dans_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION }
|
||||
validates :duree_conservation_dossiers_hors_ds, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
||||
validates_with MonAvisEmbedValidator
|
||||
|
||||
FILE_MAX_SIZE = 20.megabytes
|
||||
|
|
|
@ -9,7 +9,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
|
|||
let(:direction) { 'Direction de test' }
|
||||
let(:cadre_juridique) { 'cadre juridique' }
|
||||
let(:duree_conservation_dossiers_dans_ds) { 3 }
|
||||
let(:duree_conservation_dossiers_hors_ds) { 6 }
|
||||
let(:monavis_embed) { nil }
|
||||
let(:lien_site_web) { 'http://mon-site.gouv.fr' }
|
||||
|
||||
|
@ -33,7 +32,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
|
|||
direction: direction,
|
||||
cadre_juridique: cadre_juridique,
|
||||
duree_conservation_dossiers_dans_ds: duree_conservation_dossiers_dans_ds,
|
||||
duree_conservation_dossiers_hors_ds: duree_conservation_dossiers_hors_ds,
|
||||
monavis_embed: monavis_embed,
|
||||
lien_site_web: lien_site_web
|
||||
}
|
||||
|
@ -164,7 +162,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
|
|||
it { expect(subject.direction).to eq(direction) }
|
||||
it { expect(subject.administrateurs).to eq([admin]) }
|
||||
it { expect(subject.duree_conservation_dossiers_dans_ds).to eq(duree_conservation_dossiers_dans_ds) }
|
||||
it { expect(subject.duree_conservation_dossiers_hors_ds).to eq(duree_conservation_dossiers_hors_ds) }
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to(champs_admin_procedure_path(Procedure.last)) }
|
||||
|
@ -234,7 +231,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
|
|||
let(:organisation) { 'plop' }
|
||||
let(:direction) { 'plap' }
|
||||
let(:duree_conservation_dossiers_dans_ds) { 7 }
|
||||
let(:duree_conservation_dossiers_hors_ds) { 5 }
|
||||
|
||||
before { update_procedure }
|
||||
|
||||
|
@ -246,7 +242,6 @@ describe NewAdministrateur::ProceduresController, type: :controller do
|
|||
it { expect(subject.organisation).to eq(organisation) }
|
||||
it { expect(subject.direction).to eq(direction) }
|
||||
it { expect(subject.duree_conservation_dossiers_dans_ds).to eq(duree_conservation_dossiers_dans_ds) }
|
||||
it { expect(subject.duree_conservation_dossiers_hors_ds).to eq(duree_conservation_dossiers_hors_ds) }
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to(edit_admin_procedure_path id: procedure.id) }
|
||||
|
|
|
@ -1,30 +1,16 @@
|
|||
RSpec.describe ConservationDeDonneesHelper, type: :helper do
|
||||
let(:procedure) { build(:procedure, duree_conservation_dossiers_dans_ds: dans_ds, duree_conservation_dossiers_hors_ds: hors_ds) }
|
||||
let(:procedure) { build(:procedure, duree_conservation_dossiers_dans_ds: dans_ds) }
|
||||
|
||||
describe "politiques_conservation_de_donnees" do
|
||||
subject { politiques_conservation_de_donnees(procedure) }
|
||||
|
||||
context "when both retention times are set" do
|
||||
context "when retention time is set" do
|
||||
let(:dans_ds) { 3 }
|
||||
let(:hors_ds) { 6 }
|
||||
|
||||
it { is_expected.to eq(["Dans #{APPLICATION_NAME} : 3 mois", "Par l’administration : 6 mois"]) }
|
||||
end
|
||||
|
||||
context "when only in-app retention time is set" do
|
||||
let(:dans_ds) { 3 }
|
||||
let(:hors_ds) { nil }
|
||||
|
||||
it { is_expected.to eq(["Dans #{APPLICATION_NAME} : 3 mois"]) }
|
||||
end
|
||||
|
||||
context "when only out of app retention time is set" do
|
||||
let(:dans_ds) { nil }
|
||||
let(:hors_ds) { 6 }
|
||||
|
||||
it { is_expected.to eq(["Par l’administration : 6 mois"]) }
|
||||
end
|
||||
|
||||
context "when the retention time is not set" do
|
||||
let(:dans_ds) { nil }
|
||||
let(:hors_ds) { nil }
|
||||
|
|
Loading…
Reference in a new issue