[#2180] Expose migrated types PJ as legacy types PJ in procedure API

This commit is contained in:
Frederic Merizen 2019-01-10 15:55:04 +01:00
parent 5e37400834
commit 082255b489
3 changed files with 57 additions and 1 deletions

View file

@ -67,4 +67,21 @@ class PiecesJustificativesService
[]
end
end
def self.serialize_types_de_champ_as_type_pj(procedure)
tdcs = procedure.types_de_champ.select { |type_champ| type_champ.old_pj.present? }
tdcs.map.with_index do |type_champ, order_place|
description = type_champ.description
if /^(?<original_description>.*?)(?:[\r\n]+)Récupérer le formulaire vierge pour mon dossier : (?<lien_demarche>http.*)$/m =~ description
description = original_description
end
{
id: type_champ.old_pj[:stable_id],
libelle: type_champ.libelle,
description: description,
order_place: order_place,
lien_demarche: lien_demarche
}
end
end
end