add titre_identite champ
This commit is contained in:
parent
fd8880f569
commit
5c68d75107
12 changed files with 92 additions and 3 deletions
|
@ -1291,6 +1291,11 @@ enum TypeDeChamp {
|
||||||
"""
|
"""
|
||||||
textarea
|
textarea
|
||||||
|
|
||||||
|
"""
|
||||||
|
Titre identité
|
||||||
|
"""
|
||||||
|
titre_identite
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Oui/Non
|
Oui/Non
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -26,6 +26,7 @@ const TypeDeChamp = sortableElement(
|
||||||
const isCarte = typeDeChamp.type_champ === 'carte';
|
const isCarte = typeDeChamp.type_champ === 'carte';
|
||||||
const isExplication = typeDeChamp.type_champ === 'explication';
|
const isExplication = typeDeChamp.type_champ === 'explication';
|
||||||
const isHeaderSection = typeDeChamp.type_champ === 'header_section';
|
const isHeaderSection = typeDeChamp.type_champ === 'header_section';
|
||||||
|
const isTitreIdentite = typeDeChamp.type_champ === 'titre_identite';
|
||||||
const isRepetition = typeDeChamp.type_champ === 'repetition';
|
const isRepetition = typeDeChamp.type_champ === 'repetition';
|
||||||
const canBeMandatory =
|
const canBeMandatory =
|
||||||
!isHeaderSection && !isExplication && !state.isAnnotation;
|
!isHeaderSection && !isExplication && !state.isAnnotation;
|
||||||
|
@ -118,7 +119,7 @@ const TypeDeChamp = sortableElement(
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-start">
|
<div className="flex justify-start">
|
||||||
<DescriptionInput
|
<DescriptionInput
|
||||||
isVisible={!isHeaderSection}
|
isVisible={!isHeaderSection && !isTitreIdentite}
|
||||||
handler={updateHandlers.description}
|
handler={updateHandlers.description}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
57
app/models/champs/titre_identite_champ.rb
Normal file
57
app/models/champs/titre_identite_champ.rb
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: champs
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# private :boolean default(FALSE), not null
|
||||||
|
# row :integer
|
||||||
|
# type :string
|
||||||
|
# value :string
|
||||||
|
# created_at :datetime
|
||||||
|
# updated_at :datetime
|
||||||
|
# dossier_id :integer
|
||||||
|
# etablissement_id :integer
|
||||||
|
# parent_id :bigint
|
||||||
|
# type_de_champ_id :integer
|
||||||
|
#
|
||||||
|
class Champs::TitreIdentiteChamp < Champ
|
||||||
|
MAX_SIZE = 20.megabytes
|
||||||
|
|
||||||
|
ACCEPTED_FORMATS = [
|
||||||
|
"image/png",
|
||||||
|
"image/jpeg"
|
||||||
|
]
|
||||||
|
|
||||||
|
# TODO: once we're running on Rails 6, re-enable this validation.
|
||||||
|
# See https://github.com/betagouv/demarches-simplifiees.fr/issues/4926
|
||||||
|
#
|
||||||
|
validates :piece_justificative_file,
|
||||||
|
content_type: ACCEPTED_FORMATS,
|
||||||
|
size: { less_than: MAX_SIZE }
|
||||||
|
|
||||||
|
def main_value_name
|
||||||
|
:piece_justificative_file
|
||||||
|
end
|
||||||
|
|
||||||
|
def search_terms
|
||||||
|
# We don’t know how to search inside documents yet
|
||||||
|
end
|
||||||
|
|
||||||
|
def mandatory_and_blank?
|
||||||
|
mandatory? && !piece_justificative_file.attached?
|
||||||
|
end
|
||||||
|
|
||||||
|
def for_export
|
||||||
|
piece_justificative_file.filename.to_s if piece_justificative_file.attached?
|
||||||
|
end
|
||||||
|
|
||||||
|
def for_api
|
||||||
|
if piece_justificative_file.attached? && (piece_justificative_file.virus_scanner.safe? || piece_justificative_file.virus_scanner.pending?)
|
||||||
|
piece_justificative_file.service_url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_skip_pj_validation
|
||||||
|
type_de_champ.update(skip_pj_validation: true)
|
||||||
|
end
|
||||||
|
end
|
|
@ -47,7 +47,8 @@ class TypeDeChamp < ApplicationRecord
|
||||||
piece_justificative: 'piece_justificative',
|
piece_justificative: 'piece_justificative',
|
||||||
siret: 'siret',
|
siret: 'siret',
|
||||||
carte: 'carte',
|
carte: 'carte',
|
||||||
repetition: 'repetition'
|
repetition: 'repetition',
|
||||||
|
titre_identite: 'titre_identite'
|
||||||
}
|
}
|
||||||
|
|
||||||
belongs_to :revision, class_name: 'ProcedureRevision', optional: true
|
belongs_to :revision, class_name: 'ProcedureRevision', optional: true
|
||||||
|
@ -189,7 +190,7 @@ class TypeDeChamp < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def piece_justificative?
|
def piece_justificative?
|
||||||
type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative)
|
type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) || type_champ == TypeDeChamp.type_champs.fetch(:titre_identite)
|
||||||
end
|
end
|
||||||
|
|
||||||
def legacy_number?
|
def legacy_number?
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
class TypesDeChamp::TitreIdentiteTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
||||||
|
end
|
|
@ -26,6 +26,8 @@
|
||||||
= render partial: "shared/champs/multiple_drop_down_list/show", locals: { champ: c }
|
= render partial: "shared/champs/multiple_drop_down_list/show", locals: { champ: c }
|
||||||
- when TypeDeChamp.type_champs.fetch(:piece_justificative)
|
- when TypeDeChamp.type_champs.fetch(:piece_justificative)
|
||||||
= render partial: "shared/champs/piece_justificative/show", locals: { champ: c }
|
= render partial: "shared/champs/piece_justificative/show", locals: { champ: c }
|
||||||
|
- when TypeDeChamp.type_champs.fetch(:titre_identite)
|
||||||
|
= render partial: "shared/champs/piece_justificative/show", locals: { champ: c }
|
||||||
- when TypeDeChamp.type_champs.fetch(:siret)
|
- when TypeDeChamp.type_champs.fetch(:siret)
|
||||||
= render partial: "shared/champs/siret/show", locals: { champ: c, profile: profile }
|
= render partial: "shared/champs/siret/show", locals: { champ: c, profile: profile }
|
||||||
- when TypeDeChamp.type_champs.fetch(:textarea)
|
- when TypeDeChamp.type_champs.fetch(:textarea)
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
- elsif has_label?(champ)
|
- elsif has_label?(champ)
|
||||||
= render partial: 'shared/dossiers/editable_champs/champ_label', locals: { form: form, champ: champ, seen_at: defined?(seen_at) ? seen_at : nil }
|
= render partial: 'shared/dossiers/editable_champs/champ_label', locals: { form: form, champ: champ, seen_at: defined?(seen_at) ? seen_at : nil }
|
||||||
|
- if champ.type_champ == "titre_identite"
|
||||||
|
%p.notice Carte d'identité (uniquement le recto), passeport ou titre de séjour. Formats acceptés : jpg / png.
|
||||||
|
|
||||||
= render partial: "shared/dossiers/editable_champs/#{champ.type_champ}",
|
= render partial: "shared/dossiers/editable_champs/#{champ.type_champ}",
|
||||||
locals: { champ: champ, form: form }
|
locals: { champ: champ, form: form }
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
= render 'shared/attachment/edit',
|
||||||
|
{ form: form,
|
||||||
|
attached_file: champ.piece_justificative_file,
|
||||||
|
template: champ.type_de_champ.piece_justificative_template, user_can_destroy: true }
|
|
@ -33,3 +33,4 @@ fr:
|
||||||
siret: 'SIRET'
|
siret: 'SIRET'
|
||||||
carte: 'Carte'
|
carte: 'Carte'
|
||||||
repetition: 'Bloc répétable'
|
repetition: 'Bloc répétable'
|
||||||
|
titre_identite: 'Titre identité'
|
||||||
|
|
|
@ -143,6 +143,14 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
factory :champ_titre_identite, class: 'Champs::TitreIdentiteChamp' do
|
||||||
|
type_de_champ { association :type_de_champ_titre_identite, procedure: dossier.procedure }
|
||||||
|
|
||||||
|
after(:build) do |champ, _evaluator|
|
||||||
|
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.png", content_type: "image/png")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
factory :champ_carte, class: 'Champs::CarteChamp' do
|
factory :champ_carte, class: 'Champs::CarteChamp' do
|
||||||
type_de_champ { association :type_de_champ_carte, procedure: dossier.procedure }
|
type_de_champ { association :type_de_champ_carte, procedure: dossier.procedure }
|
||||||
end
|
end
|
||||||
|
|
|
@ -133,6 +133,9 @@ FactoryBot.define do
|
||||||
type_de_champ.piece_justificative_template.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
|
type_de_champ.piece_justificative_template.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
factory :type_de_champ_titre_identite do
|
||||||
|
type_champ { TypeDeChamp.type_champs.fetch(:titre_identite) }
|
||||||
|
end
|
||||||
factory :type_de_champ_siret do
|
factory :type_de_champ_siret do
|
||||||
type_champ { TypeDeChamp.type_champs.fetch(:siret) }
|
type_champ { TypeDeChamp.type_champs.fetch(:siret) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,6 +73,7 @@ describe ProcedureExportService do
|
||||||
"piece_justificative",
|
"piece_justificative",
|
||||||
"siret",
|
"siret",
|
||||||
"carte",
|
"carte",
|
||||||
|
"titre_identite",
|
||||||
"text"
|
"text"
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
@ -156,6 +157,7 @@ describe ProcedureExportService do
|
||||||
"piece_justificative",
|
"piece_justificative",
|
||||||
"siret",
|
"siret",
|
||||||
"carte",
|
"carte",
|
||||||
|
"titre_identite",
|
||||||
"text"
|
"text"
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
@ -235,6 +237,7 @@ describe ProcedureExportService do
|
||||||
"piece_justificative",
|
"piece_justificative",
|
||||||
"siret",
|
"siret",
|
||||||
"carte",
|
"carte",
|
||||||
|
"titre_identite",
|
||||||
"text"
|
"text"
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue