feat(api particulier): add MESRI field
This commit is contained in:
parent
f08081abfe
commit
14e0c68266
29 changed files with 380 additions and 10 deletions
|
@ -359,7 +359,8 @@
|
|||
|
||||
.cnaf-inputs,
|
||||
.dgfip-inputs,
|
||||
.pole-emploi-inputs {
|
||||
.pole-emploi-inputs,
|
||||
.mesri-inputs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
|
|
30
app/assets/stylesheets/mesri.scss
Normal file
30
app/assets/stylesheets/mesri.scss
Normal file
|
@ -0,0 +1,30 @@
|
|||
@import "constants";
|
||||
@import "colors";
|
||||
|
||||
table.mesri {
|
||||
margin: 2 * $default-padding 0 $default-padding $default-padding;
|
||||
width: 100%;
|
||||
|
||||
caption {
|
||||
font-weight: bold;
|
||||
margin-left: - $default-padding;
|
||||
margin-bottom: $default-spacer;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
font-weight: normal;
|
||||
padding: $default-spacer;
|
||||
}
|
||||
|
||||
th.text-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
&.horizontal {
|
||||
th {
|
||||
border-bottom: 1px solid $grey;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -348,8 +348,8 @@ module Users
|
|||
def champs_params
|
||||
params.permit(dossier: {
|
||||
champs_attributes: [
|
||||
:id, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :piece_justificative_file, :departement, :code_departement, value: [],
|
||||
champs_attributes: [:id, :_destroy, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :piece_justificative_file, :departement, :code_departement, value: []]
|
||||
:id, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :departement, :code_departement, value: [],
|
||||
champs_attributes: [:id, :_destroy, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :departement, :code_departement, value: []]
|
||||
]
|
||||
})
|
||||
end
|
||||
|
|
|
@ -1983,6 +1983,11 @@ enum TypeDeChamp {
|
|||
"""
|
||||
linked_drop_down_list
|
||||
|
||||
"""
|
||||
Données du Ministère de l'Enseignement Supérieur, de la Recherche et de l'Innovation
|
||||
"""
|
||||
mesri
|
||||
|
||||
"""
|
||||
Choix multiples
|
||||
"""
|
||||
|
|
|
@ -8,6 +8,7 @@ module APIParticulier
|
|||
def available_sources
|
||||
@procedure.api_particulier_scopes
|
||||
.filter_map { |provider_and_scope| raw_scopes[provider_and_scope] }
|
||||
.uniq # remove provider/scope tuples duplicates (e.g. mesri inscriptions)
|
||||
.map { |provider, scope| extract_sources(provider, scope) }
|
||||
.reduce({}) { |acc, el| acc.deep_merge(el) { |_, this_val, other_val| this_val + other_val } }
|
||||
end
|
||||
|
|
47
app/models/champs/mesri_champ.rb
Normal file
47
app/models/champs/mesri_champ.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: champs
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# data :jsonb
|
||||
# fetch_external_data_exceptions :string is an Array
|
||||
# private :boolean default(FALSE), not null
|
||||
# rebased_at :datetime
|
||||
# row :integer
|
||||
# type :string
|
||||
# value :string
|
||||
# value_json :jsonb
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# dossier_id :integer
|
||||
# etablissement_id :integer
|
||||
# external_id :string
|
||||
# parent_id :bigint
|
||||
# type_de_champ_id :integer
|
||||
#
|
||||
class Champs::MesriChamp < Champs::TextChamp
|
||||
# see https://github.com/betagouv/api-particulier/blob/master/src/presentation/middlewares/mesri-input-validation.middleware.ts
|
||||
store_accessor :value_json, :ine
|
||||
|
||||
def blank?
|
||||
external_id.nil?
|
||||
end
|
||||
|
||||
def fetch_external_data?
|
||||
true
|
||||
end
|
||||
|
||||
def fetch_external_data
|
||||
return if !valid?
|
||||
|
||||
APIParticulier::MesriAdapter.new(
|
||||
procedure.api_particulier_token,
|
||||
ine,
|
||||
procedure.api_particulier_sources
|
||||
).to_params
|
||||
end
|
||||
|
||||
def external_id
|
||||
{ ine: ine }.to_json if ine.present?
|
||||
end
|
||||
end
|
|
@ -734,6 +734,10 @@ class Procedure < ApplicationRecord
|
|||
api_particulier_sources['pole_emploi'].present?
|
||||
end
|
||||
|
||||
def mesri_enabled?
|
||||
api_particulier_sources['mesri'].present?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_for_publication?
|
||||
|
|
|
@ -52,7 +52,8 @@ class TypeDeChamp < ApplicationRecord
|
|||
annuaire_education: 'annuaire_education',
|
||||
cnaf: 'cnaf',
|
||||
dgfip: 'dgfip',
|
||||
pole_emploi: 'pole_emploi'
|
||||
pole_emploi: 'pole_emploi',
|
||||
mesri: 'mesri'
|
||||
}
|
||||
|
||||
belongs_to :revision, class_name: 'ProcedureRevision', optional: true
|
||||
|
@ -330,6 +331,8 @@ class TypeDeChamp < ApplicationRecord
|
|||
procedure.dgfip_enabled?
|
||||
when TypeDeChamp.type_champs.fetch(:pole_emploi)
|
||||
procedure.pole_emploi_enabled?
|
||||
when TypeDeChamp.type_champs.fetch(:mesri)
|
||||
procedure.mesri_enabled?
|
||||
else
|
||||
true
|
||||
end
|
||||
|
|
2
app/models/types_de_champ/mesri_type_de_champ.rb
Normal file
2
app/models/types_de_champ/mesri_type_de_champ.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
class TypesDeChamp::MesriTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
||||
end
|
11
app/views/shared/champs/mesri/_admissions.html.haml
Normal file
11
app/views/shared/champs/mesri/_admissions.html.haml
Normal file
|
@ -0,0 +1,11 @@
|
|||
%table.mesri
|
||||
%caption #{t("api_particulier.providers.mesri.scopes.#{scope}.libelle")} :
|
||||
- admissions.each do |admission|
|
||||
- admission.slice('statut', 'regime', 'dateDebutAdmission', 'dateFinAdmission', 'codeCommune').keys.each do |key|
|
||||
%tr
|
||||
%th= t("api_particulier.providers.mesri.scopes.#{scope}.#{key}")
|
||||
- case key
|
||||
- when 'dateDebutAdmission', 'dateFinAdmission'
|
||||
%td= try_format_date(Date.strptime(admission[key], "%Y-%m-%d"))
|
||||
- else
|
||||
%td= admission[key]
|
7
app/views/shared/champs/mesri/_etablissements.html.haml
Normal file
7
app/views/shared/champs/mesri/_etablissements.html.haml
Normal file
|
@ -0,0 +1,7 @@
|
|||
%table.mesri
|
||||
%caption #{t("api_particulier.providers.mesri.scopes.#{scope}.libelle")} :
|
||||
- etablissements.each do |etablissement|
|
||||
- etablissement.slice('uai', 'nom').keys.each do |key|
|
||||
%tr
|
||||
%th= t("api_particulier.providers.mesri.scopes.#{scope}.#{key}")
|
||||
%td= etablissement[key]
|
6
app/views/shared/champs/mesri/_identifiant.html.haml
Normal file
6
app/views/shared/champs/mesri/_identifiant.html.haml
Normal file
|
@ -0,0 +1,6 @@
|
|||
%table.mesri
|
||||
%caption #{t("api_particulier.providers.mesri.scopes.#{scope}.libelle")} :
|
||||
- identifiant.slice('ine').keys.each do |key|
|
||||
%tr
|
||||
%th= t("api_particulier.providers.mesri.scopes.#{scope}.#{key}")
|
||||
%td= identifiant[key]
|
10
app/views/shared/champs/mesri/_identite.html.haml
Normal file
10
app/views/shared/champs/mesri/_identite.html.haml
Normal file
|
@ -0,0 +1,10 @@
|
|||
%table.mesri
|
||||
%caption #{t("api_particulier.providers.mesri.scopes.#{scope}.libelle")} :
|
||||
- identite.slice('nom', 'prenom', 'dateNaissance').keys.each do |key|
|
||||
%tr
|
||||
%th= t("api_particulier.providers.mesri.scopes.#{scope}.#{key}")
|
||||
- case key
|
||||
- when 'dateNaissance'
|
||||
%td= try_format_date(Date.strptime(identite[key], "%Y-%m-%d"))
|
||||
- else
|
||||
%td= identite[key]
|
11
app/views/shared/champs/mesri/_inscriptions.html.haml
Normal file
11
app/views/shared/champs/mesri/_inscriptions.html.haml
Normal file
|
@ -0,0 +1,11 @@
|
|||
%table.mesri
|
||||
%caption #{t("api_particulier.providers.mesri.scopes.#{scope}.libelle")} :
|
||||
- inscriptions.each do |inscription|
|
||||
- inscription.slice('statut', 'regime', 'dateDebutInscription', 'dateFinInscription', 'codeCommune').keys.each do |key|
|
||||
%tr
|
||||
%th= t("api_particulier.providers.mesri.scopes.#{scope}.#{key}")
|
||||
- case key
|
||||
- when 'dateDebutInscription', 'dateFinInscription'
|
||||
%td= try_format_date(Date.strptime(inscription[key], "%Y-%m-%d"))
|
||||
- else
|
||||
%td= inscription[key]
|
25
app/views/shared/champs/mesri/_show.html.haml
Normal file
25
app/views/shared/champs/mesri/_show.html.haml
Normal file
|
@ -0,0 +1,25 @@
|
|||
- if champ.blank?
|
||||
%p= t('.not_filled')
|
||||
- elsif champ.data.blank?
|
||||
%p= t('.fetching_data', ine: champ.ine)
|
||||
- else
|
||||
- if profile == 'usager'
|
||||
- sources = champ.procedure.api_particulier_sources['mesri'].keys
|
||||
- i18n_sources = sources.map { |s| I18n.t("#{s}.libelle", scope: 'api_particulier.providers.mesri.scopes') }
|
||||
%p= t('.data_fetched', sources: i18n_sources.to_sentence, ine: champ.ine)
|
||||
|
||||
- if profile == 'instructeur'
|
||||
%p= t('.data_fetched_title')
|
||||
|
||||
- champ.data.slice('identifiant', 'identite', 'inscriptions', 'admissions', 'etablissements').keys.each do |scope|
|
||||
- case scope
|
||||
- when 'identifiant'
|
||||
= render partial: 'shared/champs/mesri/identifiant', locals: { scope: scope, identifiant: champ.data[scope] }
|
||||
- when 'identite'
|
||||
= render partial: 'shared/champs/mesri/identite', locals: { scope: scope, identite: champ.data[scope] }
|
||||
- when 'inscriptions'
|
||||
= render partial: 'shared/champs/mesri/inscriptions', locals: { scope: scope, inscriptions: champ.data[scope] }
|
||||
- when 'admissions'
|
||||
= render partial: 'shared/champs/mesri/admissions', locals: { scope: scope, admissions: champ.data[scope] }
|
||||
- when 'etablissements'
|
||||
= render partial: 'shared/champs/mesri/etablissements', locals: { scope: scope, etablissements: champ.data[scope] }
|
|
@ -42,6 +42,8 @@
|
|||
= render partial: "shared/champs/dgfip/show", locals: { champ: c, profile: profile }
|
||||
- when TypeDeChamp.type_champs.fetch(:pole_emploi)
|
||||
= render partial: "shared/champs/pole_emploi/show", locals: { champ: c, profile: profile }
|
||||
- when TypeDeChamp.type_champs.fetch(:mesri)
|
||||
= render partial: "shared/champs/mesri/show", locals: { champ: c, profile: profile }
|
||||
- when TypeDeChamp.type_champs.fetch(:address)
|
||||
= render partial: "shared/champs/address/show", locals: { champ: c }
|
||||
- when TypeDeChamp.type_champs.fetch(:communes)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
.mesri-inputs
|
||||
%div
|
||||
= form.label :ine, t('.ine_label')
|
||||
%p.notice= t('.ine_notice')
|
||||
= form.text_field :ine,
|
||||
required: champ.mandatory?,
|
||||
aria: { describedby: describedby_id(champ) }
|
Loading…
Add table
Add a link
Reference in a new issue