From db5bf39e32fc82c89dc419f7de045260e57b5f3e Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Thu, 18 Jan 2018 11:39:05 +0100 Subject: [PATCH] [#1203] No implicit available_for_states, make it explicit --- .../concerns/tags_substitution_concern.rb | 44 ++++++++++++------- app/models/dossier.rb | 1 + 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/app/models/concerns/tags_substitution_concern.rb b/app/models/concerns/tags_substitution_concern.rb index 5bd2bdc71..8bfaa4256 100644 --- a/app/models/concerns/tags_substitution_concern.rb +++ b/app/models/concerns/tags_substitution_concern.rb @@ -11,7 +11,7 @@ module TagsSubstitutionConcern identity_tags = entreprise_tags + etablissement_tags end - filter_tags(identity_tags + dossier_tags + procedure_type_de_champ_public_private_tags) + filter_tags(identity_tags + dossier_tags) + procedure_type_de_champ_public_private_tags end private @@ -30,7 +30,7 @@ module TagsSubstitutionConcern raise NameError.new("The class #{self.class.name} includes TagsSubstitutionConcern, it should define the DOSSIER_STATE constant but it does not", :DOSSIER_STATE) end - tags.select { |tag| (tag[:available_for_states] || Dossier::SOUMIS).include?(self.class::DOSSIER_STATE) } + tags.select { |tag| tag[:available_for_states].include?(self.class::DOSSIER_STATE) } end def procedure_type_de_champ_public_private_tags @@ -49,7 +49,8 @@ module TagsSubstitutionConcern { libelle: 'date de dépôt', description: 'Date du passage en construction du dossier par l’usager', - lambda: -> (d) { format_date(d.en_construction_at) } + lambda: -> (d) { format_date(d.en_construction_at) }, + available_for_states: Dossier::SOUMIS }, { libelle: 'date de passage en instruction', @@ -66,12 +67,14 @@ module TagsSubstitutionConcern { libelle: 'libellé procédure', description: '', - lambda: -> (d) { d.procedure.libelle } + lambda: -> (d) { d.procedure.libelle }, + available_for_states: Dossier::SOUMIS }, { libelle: 'numéro du dossier', description: '', - target: :id + target: :id, + available_for_states: Dossier::SOUMIS } ] end @@ -89,7 +92,8 @@ module TagsSubstitutionConcern { libelle: 'lien dossier', description: '', - lambda: -> (d) { users_dossier_recapitulatif_link(d) } + lambda: -> (d) { users_dossier_recapitulatif_link(d) }, + available_for_states: Dossier::SOUMIS } ] end @@ -104,17 +108,20 @@ module TagsSubstitutionConcern { libelle: 'civilité', description: 'M., Mme', - target: :gender + target: :gender, + available_for_states: Dossier::SOUMIS }, { libelle: 'nom', description: "nom de l'usager", - target: :nom + target: :nom, + available_for_states: Dossier::SOUMIS }, { libelle: 'prénom', description: "prénom de l'usager", - target: :prenom + target: :prenom, + available_for_states: Dossier::SOUMIS } ] end @@ -124,22 +131,26 @@ module TagsSubstitutionConcern { libelle: 'SIREN', description: '', - target: :siren + target: :siren, + available_for_states: Dossier::SOUMIS }, { libelle: 'numéro de TVA intracommunautaire', description: '', - target: :numero_tva_intracommunautaire + target: :numero_tva_intracommunautaire, + available_for_states: Dossier::SOUMIS }, { libelle: 'SIRET du siège social', description: '', - target: :siret_siege_social + target: :siret_siege_social, + available_for_states: Dossier::SOUMIS }, { libelle: 'raison sociale', description: '', - target: :raison_sociale + target: :raison_sociale, + available_for_states: Dossier::SOUMIS } ] end @@ -147,9 +158,10 @@ module TagsSubstitutionConcern def etablissement_tags [ { - libelle: 'adresse', - description: '', - target: :inline_adresse + libelle: 'adresse', + description: '', + target: :inline_adresse, + available_for_states: Dossier::SOUMIS } ] end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index a0451e769..5843337d2 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -11,6 +11,7 @@ class Dossier < ActiveRecord::Base EN_CONSTRUCTION_OU_INSTRUCTION = %w(en_construction en_instruction) TERMINE = %w(accepte refuse sans_suite) INSTRUCTION_COMMENCEE = TERMINE + %w(en_instruction) + SOUMIS = EN_CONSTRUCTION_OU_INSTRUCTION + TERMINE has_one :etablissement, dependent: :destroy has_one :entreprise, dependent: :destroy