feat(procedure.duree_conservation_dossiers_dans_ds): decrease max duree_conservation_dossiers_dans_ds from 36 to 12
This commit is contained in:
parent
df85d51556
commit
24c8dc5829
10 changed files with 69 additions and 18 deletions
|
@ -36,7 +36,9 @@ class ProcedureDashboard < Administrate::BaseDashboard
|
|||
refused_mail_template: MailTemplateField,
|
||||
without_continuation_mail_template: MailTemplateField,
|
||||
attestation_template: AttestationTemplateField,
|
||||
procedure_expires_when_termine_enabled: Field::Boolean
|
||||
procedure_expires_when_termine_enabled: Field::Boolean,
|
||||
duree_conservation_dossiers_dans_ds: Field::Number,
|
||||
duree_conservation_etendue_par_ds: Field::Boolean
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
|
@ -84,14 +86,18 @@ class ProcedureDashboard < Administrate::BaseDashboard
|
|||
:refused_mail_template,
|
||||
:without_continuation_mail_template,
|
||||
:attestation_template,
|
||||
:procedure_expires_when_termine_enabled
|
||||
:procedure_expires_when_termine_enabled,
|
||||
:duree_conservation_dossiers_dans_ds,
|
||||
:duree_conservation_etendue_par_ds
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:procedure_expires_when_termine_enabled
|
||||
:procedure_expires_when_termine_enabled,
|
||||
:duree_conservation_dossiers_dans_ds,
|
||||
:duree_conservation_etendue_par_ds
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how procedures are displayed
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
# description :string
|
||||
# direction :string
|
||||
# duree_conservation_dossiers_dans_ds :integer
|
||||
# duree_conservation_etendue_par_ds :boolean default(FALSE)
|
||||
# durees_conservation_required :boolean default(TRUE)
|
||||
# encrypted_api_particulier_token :string
|
||||
# euro_flag :boolean default(FALSE)
|
||||
|
@ -63,8 +64,8 @@ class Procedure < ApplicationRecord
|
|||
self.discard_column = :hidden_at
|
||||
default_scope -> { kept }
|
||||
|
||||
MAX_DUREE_CONSERVATION = 36
|
||||
MAX_DUREE_CONSERVATION_EXPORT = 3.hours
|
||||
OLD_MAX_DUREE_CONSERVATION = 36
|
||||
NEW_MAX_DUREE_CONSERVATION = 12
|
||||
|
||||
MIN_WEIGHT = 350000
|
||||
|
||||
|
@ -270,7 +271,22 @@ class Procedure < ApplicationRecord
|
|||
if: :validate_for_publication?
|
||||
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_dans_ds, allow_nil: false,
|
||||
numericality: {
|
||||
only_integer: true,
|
||||
greater_than_or_equal_to: 1,
|
||||
less_than_or_equal_to: OLD_MAX_DUREE_CONSERVATION
|
||||
},
|
||||
if: :duree_conservation_etendue_par_ds
|
||||
|
||||
validates :duree_conservation_dossiers_dans_ds, allow_nil: false,
|
||||
numericality: {
|
||||
only_integer: true,
|
||||
greater_than_or_equal_to: 1,
|
||||
less_than_or_equal_to: NEW_MAX_DUREE_CONSERVATION
|
||||
},
|
||||
unless: :duree_conservation_etendue_par_ds
|
||||
|
||||
validates :lien_dpo, email_or_link: true, allow_nil: true
|
||||
validates_with MonAvisEmbedValidator
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
Sur #{APPLICATION_NAME}
|
||||
%span.mandatory *
|
||||
|
||||
%p.notice (durée en mois après le début de l’instruction)
|
||||
= f.number_field :duree_conservation_dossiers_dans_ds, class: 'form-control', placeholder: '6', required: true
|
||||
%p.notice Durée en mois après le début de l’instruction. Pour les démarches classiques, cette durée ne peut exceder 12 mois. Si vous avez besoin d'une durée supérieur à 12 mois, merci d'en faire la demande à notre support
|
||||
= f.number_field :duree_conservation_dossiers_dans_ds, {class: 'form-control', placeholder: '6', required: true}.merge(f.object.duree_conservation_etendue_par_ds ? {} : {max: 12})
|
||||
|
||||
- if @procedure.created_at.present?
|
||||
= f.label :lien_site_web do
|
||||
|
|
|
@ -9,7 +9,6 @@ fr:
|
|||
path: Lien public
|
||||
organisation: Organisme
|
||||
duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers sur demarches-simplifiees.fr
|
||||
duree_conservation_dossiers_hors_ds: Durée de conservation des dossiers hors demarches-simplifiees.fr
|
||||
aasm_state/brouillon: Brouillon
|
||||
aasm_state/publiee: Publiée
|
||||
aasm_state/close: Close
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class DropDureeConservationDossiersHorsDs < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured { remove_column :procedures, :duree_conservation_dossiers_hors_ds }
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddColumnDureeConservationEntendueParDs < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :procedures, :duree_conservation_etendue_par_ds, :boolean
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class BackfillDureeConservationEntendueParDs < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
Procedure.in_batches do |relation|
|
||||
relation.update_all duree_conservation_etendue_par_ds: true
|
||||
sleep(0.01)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class NewDefaultDureeConservationEntendueParDs < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
change_column_default :procedures, :duree_conservation_etendue_par_ds, false
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2022_06_22_183305) do
|
||||
ActiveRecord::Schema.define(version: 2022_07_08_152039) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
|
@ -636,7 +636,7 @@ ActiveRecord::Schema.define(version: 2022_06_22_183305) do
|
|||
t.string "direction"
|
||||
t.bigint "draft_revision_id"
|
||||
t.integer "duree_conservation_dossiers_dans_ds"
|
||||
t.integer "duree_conservation_dossiers_hors_ds"
|
||||
t.boolean "duree_conservation_etendue_par_ds", default: false
|
||||
t.boolean "durees_conservation_required", default: true
|
||||
t.string "encrypted_api_particulier_token"
|
||||
t.boolean "euro_flag", default: false
|
||||
|
|
|
@ -281,19 +281,26 @@ describe Procedure do
|
|||
end
|
||||
end
|
||||
|
||||
shared_examples 'duree de conservation' do
|
||||
context 'duree_conservation_required it true, the field gets validated' do
|
||||
describe 'duree de conservation dans ds' do
|
||||
let(:field_name) { :duree_conservation_dossiers_dans_ds }
|
||||
|
||||
context 'for old procedures, duree_conservation_required it true, the field gets validated' do
|
||||
subject { create(:procedure, duree_conservation_etendue_par_ds: true) }
|
||||
it { is_expected.not_to allow_value(nil).for(field_name) }
|
||||
it { is_expected.not_to allow_value('').for(field_name) }
|
||||
it { is_expected.not_to allow_value('trois').for(field_name) }
|
||||
it { is_expected.to allow_value(3).for(field_name) }
|
||||
it { is_expected.to allow_value(36).for(field_name) }
|
||||
it { is_expected.to validate_numericality_of(field_name).is_less_than_or_equal_to(Procedure::OLD_MAX_DUREE_CONSERVATION) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'duree de conservation dans ds' do
|
||||
let(:field_name) { :duree_conservation_dossiers_dans_ds }
|
||||
|
||||
it_behaves_like 'duree de conservation'
|
||||
context 'for new procedures, duree_conservation_required it true, the field gets validated' do
|
||||
subject { create(:procedure, duree_conservation_etendue_par_ds: false) }
|
||||
it { is_expected.not_to allow_value(nil).for(field_name) }
|
||||
it { is_expected.not_to allow_value('').for(field_name) }
|
||||
it { is_expected.not_to allow_value('trois').for(field_name) }
|
||||
it { is_expected.to validate_numericality_of(field_name).is_less_than_or_equal_to(Procedure::NEW_MAX_DUREE_CONSERVATION) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'draft_types_de_champ validations' do
|
||||
|
|
Loading…
Reference in a new issue